-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathbutton-mixin.scss
161 lines (130 loc) · 3.67 KB
/
button-mixin.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
* SPDX-FileCopyrightText: 2023 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
@import 'common-variables';
@import 'legacy/mixins/fonts';
@import 'mixins/shadow-dom/component';
@import 'mixins/hover';
@mixin btn-variant($name, $enable-border: true) {
:host {
.btn-#{$name} {
border-radius: var(--theme-btn--border-radius);
&,
&.focus,
&:focus-visible {
background-color: var(--theme-btn-#{$name}--background);
color: var(--theme-btn-#{$name}--color);
--ix-button-color: var(--theme-btn-#{$name}--color);
--ix-icon-color: var(--ix-button-color);
@if $enable-border {
border-width: var(--theme-btn--border-thickness);
border-color: var(--theme-btn-#{$name}--border-color);
border-style: solid;
} @else {
border-color: transparent;
}
}
@include focus-visible {
outline: 1px solid var(--theme-color-focus-bdr);
outline-offset: var(--theme-btn--focus--outline-offset);
}
&.selected {
background-color: var(--theme-color-ghost--selected);
color: var(--theme-color-dynamic);
@include hover {
background-color: var(--theme-color-ghost--selected-hover);
color: var(--theme-color-dynamic);
}
@include active {
background-color: var(--theme-color-ghost--selected-active);
color: var(--theme-color-dynamic);
}
}
@include hover {
@if $enable-border {
border-color: var(--theme-btn-#{$name}--border-color--hover);
}
background-color: var(--theme-btn-#{$name}--background--hover);
color: var(--theme-btn-#{$name}--color--hover);
}
@include active {
@if $enable-border {
border-color: var(--theme-btn-#{$name}--border-color--active);
}
background-color: var(--theme-btn-#{$name}--background--active);
color: var(--theme-btn-#{$name}--color--active);
}
}
}
:host(.disabled) {
.btn-#{$name} {
&.disabled,
&:disabled {
pointer-events: none;
@if $enable-border {
border-color: var(--theme-btn-#{$name}--border-color--disabled);
}
background-color: var(--theme-btn-#{$name}--background--disabled);
color: var(--theme-btn-#{$name}--color--disabled);
opacity: 1;
--ix-button-color: var(--theme-btn-#{$name}--color--disabled);
}
}
}
}
@mixin btn {
:host {
@include ix-component;
display: inline-block;
height: 2rem;
vertical-align: middle;
cursor: pointer;
@include text-default-title;
button {
all: unset;
box-sizing: border-box;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
overflow: hidden;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
padding: 0 0.5rem;
}
ix-spinner {
margin-right: 0.25rem;
}
ix-icon {
margin-right: 0.25rem;
}
.content {
display: inline-block;
position: relative;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.content-start {
width: 100%;
}
}
:host(.disabled) {
cursor: default;
}
}
@mixin all-btn-variants {
@include btn;
$button-categories: (primary, secondary);
@each $category in $button-categories {
@include btn-variant($category);
@include btn-variant('outline-#{$category}');
@include btn-variant('invisible-#{$category}', false);
}
}