-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy path_shared.scss
More file actions
180 lines (161 loc) · 5.5 KB
/
_shared.scss
File metadata and controls
180 lines (161 loc) · 5.5 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//
// Copyright 2021 Google LLC
// SPDX-License-Identifier: Apache-2.0
//
// go/keep-sorted start
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
@use '../../focus/focus-ring';
@use '../../ripple/ripple';
// go/keep-sorted end
@mixin styles() {
:host {
border-start-start-radius: var(--_container-shape-start-start);
border-start-end-radius: var(--_container-shape-start-end);
border-end-start-radius: var(--_container-shape-end-start);
border-end-end-radius: var(--_container-shape-end-end);
box-sizing: border-box;
cursor: pointer;
display: inline-flex;
gap: 8px;
// min-height instead of height so that label can wrap and expand height
min-height: var(--_container-height);
// max-width set to 100% to prevent label from overflowing
max-width: 100%;
outline: none;
// Add extra space between label and the edge for if the label text wraps.
// The padding added should be relative to the height of the container and
// the height of its content on a single line (label or icon, whichever is
// bigger).
$single-line-height: max(var(--_label-text-line-height), var(--_icon-size));
padding-block: calc((var(--_container-height) - $single-line-height) / 2);
padding-inline-start: var(--_leading-space);
padding-inline-end: var(--_trailing-space);
place-content: center;
place-items: center;
position: relative;
font-family: var(--_label-text-font);
font-size: var(--_label-text-size);
line-height: var(--_label-text-line-height);
font-weight: var(--_label-text-weight);
// Long labels are cut off with ellipsis by default. `text-overflow` and
// `text-wrap` can customize this.
text-overflow: ellipsis;
text-wrap: nowrap;
user-select: none;
-webkit-tap-highlight-color: transparent;
// Override vertical-align with shortest value "top". Vertical-align's
// default "baseline" value causes buttons to be misaligned next to each
// other if one button has an icon and the other does not.
vertical-align: top;
@include ripple.theme(
(
hover-color: var(--_hover-state-layer-color),
pressed-color: var(--_pressed-state-layer-color),
hover-opacity: var(--_hover-state-layer-opacity),
pressed-opacity: var(--_pressed-state-layer-opacity),
)
);
}
md-focus-ring {
@include focus-ring.theme(
(
'shape-start-start': var(--_container-shape-start-start),
'shape-start-end': var(--_container-shape-start-end),
'shape-end-end': var(--_container-shape-end-end),
'shape-end-start': var(--_container-shape-end-start),
)
);
}
:host(:is([disabled], [soft-disabled])) {
cursor: default;
pointer-events: none;
}
.button {
border-radius: inherit;
cursor: inherit;
display: inline-flex;
align-items: center;
justify-content: center;
border: none;
outline: none;
-webkit-appearance: none;
vertical-align: middle;
background: transparent;
text-decoration: none;
// Buttons have a default min-width of 64px. This can be overridden by
// setting a smaller min-width on the host. The 64px button will be centered
// within the bounds of the smaller host element.
min-width: calc(64px - var(--_leading-space) - var(--_trailing-space));
width: 100%;
z-index: 0; // Place content on top of elevation and ripple
height: 100%;
font: inherit;
color: var(--_label-text-color);
padding: 0;
gap: inherit;
// Override the user-agent text-transform: none of <button> and <a>
text-transform: inherit;
&::-moz-focus-inner {
padding: 0;
border: 0;
}
}
:host(:hover) .button {
color: var(--_hover-label-text-color);
}
:host(:focus-within) .button {
color: var(--_focus-label-text-color);
}
:host(:active) .button {
color: var(--_pressed-label-text-color);
}
.background {
// Background color. Separate node for disabled opacity styles.
background: var(--_container-color);
border-radius: inherit;
inset: 0;
position: absolute;
}
.label {
overflow: hidden;
}
// Inherit text-overflow down through label and slotted content so that it
// can be customized on the host.
:is(.button, .label, .label slot),
.label ::slotted(*) {
text-overflow: inherit;
}
:host(:is([disabled], [soft-disabled])) .label {
color: var(--_disabled-label-text-color);
opacity: var(--_disabled-label-text-opacity);
}
:host(:is([disabled], [soft-disabled])) .background {
background: var(--_disabled-container-color);
opacity: var(--_disabled-container-opacity);
}
@media (forced-colors: active) {
.background {
// Use CanvasText to increase visibility of buttons when the background
// is not rendered. Buttons that use outlines by default should change The
// outline color to GrayText when disabled.
border: 1px solid CanvasText;
}
:host(:is([disabled], [soft-disabled])) {
--_disabled-icon-color: GrayText;
--_disabled-icon-opacity: 1;
--_disabled-container-opacity: 1;
--_disabled-label-text-color: GrayText;
--_disabled-label-text-opacity: 1;
}
}
:host([has-icon]:not([trailing-icon])) {
padding-inline-start: var(--_with-leading-icon-leading-space);
padding-inline-end: var(--_with-leading-icon-trailing-space);
}
:host([has-icon][trailing-icon]) {
padding-inline-start: var(--_with-trailing-icon-leading-space);
padding-inline-end: var(--_with-trailing-icon-trailing-space);
}
}