blob: 5231d6df9db4975f47c20bb6f4df3785f907eb5b [file] [log] [blame]
Alex Rudenkoe4465d12021-08-09 11:37:371/*
2 * Copyright 2021 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
Alex Rudenko0bd7a1b2024-01-04 06:58:337/**
8* Design: http://go/cdt-design-button
9*/
Alex Rudenkoe4465d12021-08-09 11:37:3710* {
11 margin: 0;
12 padding: 0;
13 box-sizing: border-box;
14}
15
Alex Rudenkodc7c9592021-09-30 09:00:5516/**
17* Reset default UA styles for focused elements.
18* The button styles below explicitly implement custom focus styles.
19*/
Alex Rudenkoe4465d12021-08-09 11:37:3720*:focus,
Alex Rudenkodc7c9592021-09-30 09:00:5521*:focus-visible,
22:host(:focus),
23:host(:focus-visible) {
Alex Rudenkoe4465d12021-08-09 11:37:3724 outline: none;
25}
26
Alex Rudenkoe6ba3522021-10-15 06:09:4827:host {
28 display: inline-flex;
29 flex-direction: row;
30}
31
Alex Rudenkoe4465d12021-08-09 11:37:3732button {
Ergün Erdoğmuş0cd36dc2022-05-03 09:54:1633 /*
34 --override-button-no-right-border-radius decides
35 whether button has border radius on the right or not.
36
37 It works as a boolean variable:
38 * If it is 1, `--button-has-right-border-radius` becomes a 0 multiplier
39 for the border-radius-top-right and border-radius-bottom-right properties.
40 * If it is not set or 0, it becomes a 1 multiplier
41 for the same properties which means they'll continue to have the given
42 border radius.
43 */
44 --button-has-right-border-radius: calc(1 - var(--override-button-no-right-border-radius, 0));
Alex Rudenko9d873e52023-05-09 14:26:1745 --button-border-size: 1px;
46 --button-height: 24px;
47 --button-width: 100%;
Ergün Erdoğmuş0cd36dc2022-05-03 09:54:1648
Alex Rudenkoe4465d12021-08-09 11:37:3749 align-items: center;
Alex Rudenko0bd7a1b2024-01-04 06:58:3350 background: transparent;
Kateryna Prokopenko211fe2e2023-08-30 13:56:1751 border-radius: 12px calc(var(--button-has-right-border-radius) * 12px) calc(var(--button-has-right-border-radius) * 12px) 12px;
Alex Rudenkocc459b92021-08-11 13:53:4852 display: inline-flex;
53 font-family: inherit;
Alex Rudenkoe4465d12021-08-09 11:37:3754 font-size: 12px;
Riho Isawaaf47cc82021-10-27 02:27:1655 font-weight: 500;
Alex Rudenko9d873e52023-05-09 14:26:1756 height: var(--button-height);
Alex Rudenko50b3a3e2021-09-29 11:01:4657 justify-content: center;
Alex Rudenko0bd7a1b2024-01-04 06:58:3358 line-height: 14px;
59 padding: 0;
Benedikt Meurerc635aa82022-12-13 08:20:5760 white-space: nowrap;
Alex Rudenko0bd7a1b2024-01-04 06:58:3361 width: var(--button-width);
Alex Rudenko3aa078e2024-01-03 13:52:4762
63 devtools-icon {
64 width: calc(var(--button-width) - 4px);
65 height: calc(var(--button-height) - 4px);
66 }
67
68 &.small {
69 --button-height: 20px;
70
71 border-radius: 2px calc(var(--button-has-right-border-radius) * 2px) calc(var(--button-has-right-border-radius) * 2px) 2px;
72 }
73
74 &.toolbar,
75 &.round {
76 --button-height: 24px;
77 --button-width: 24px;
78
Alex Rudenko3aa078e2024-01-03 13:52:4779 border: none;
80 overflow: hidden;
Alex Rudenko3aa078e2024-01-03 13:52:4781
82 &.small {
83 --button-height: 20px;
84 --button-width: 20px;
85 }
86 }
87
88 &.toolbar {
89 border-radius: 2px calc(var(--button-has-right-border-radius) * 2px) calc(var(--button-has-right-border-radius) * 2px) 2px;
90 }
91
92 &.round {
93 border-radius: 100%;
94
95 &.tiny {
96 --button-height: 18px;
97 --button-width: 18px;
98 }
99 }
100
101 &.primary {
102 border: var(--button-border-size) solid var(--sys-color-primary);
103 background: var(--sys-color-primary);
104 color: var(--sys-color-on-primary);
105
106 devtools-icon {
107 color: var(--sys-color-cdt-base-container);
108 }
109 }
110
111 &.tonal {
112 border: var(--button-border-size) solid transparent;
113 background: var(--sys-color-tonal-container);
114 color: var(--sys-color-on-tonal-container);
115
116 devtools-icon {
117 color: var(--sys-color-on-tonal-container);
118 }
119 }
120
121 &.secondary {
122 border: var(--button-border-size) solid var(--sys-color-tonal-outline);
123 background: var(--sys-color-cdt-base-container);
124 color: var(--sys-color-primary);
125
126 devtools-icon {
127 color: var(--icon-primary);
128 }
129 }
130
131 &.primary-toolbar {
132 devtools-icon {
133 color: var(--icon-primary);
134 }
135 }
136
Alex Rudenko3aa078e2024-01-03 13:52:47137 &:focus-visible {
138 outline: 2px solid var(--sys-color-state-focus-ring);
139 outline-offset: 2px;
140
141 &.toolbar,
142 &.round {
143 background-color: var(--sys-color-tonal-container);
144 outline: none;
145 }
146 }
147
148 &:disabled {
Alex Rudenko3aa078e2024-01-03 13:52:47149 devtools-icon {
150 color: var(--icon-disabled);
151 }
152 }
153
Alex Rudenko0bd7a1b2024-01-04 06:58:33154 &.text-with-icon {
155 padding: 0 calc(12px - var(--button-border-size)) 0 calc(8px - var(--button-border-size));
156
157 devtools-icon {
158 width: 20px;
159 height: 20px;
160 margin-right: 4px;
161 }
162
Wolfgang Beyer9e879742024-01-11 10:23:39163 &.small {
Alex Rudenko0bd7a1b2024-01-04 06:58:33164 padding: 0 calc(9px - var(--button-border-size)) 0 calc(3px - var(--button-border-size));
165
166 devtools-icon {
167 width: 16px;
168 height: 16px;
169 margin-right: 4px;
170 }
171 }
172 }
173
174 &.only-text {
175 padding: 5px 12px;
176 }
177
Alex Rudenko3aa078e2024-01-03 13:52:47178 &:hover {
179 &.primary {
180 background: color-mix(in sRGB, var(--sys-color-primary), var(--sys-color-state-hover-on-prominent) 6%);
181 border: var(--button-border-size) solid color-mix(in sRGB, var(--sys-color-primary), var(--sys-color-state-hover-on-prominent) 6%);
182 }
183
184 &.tonal {
185 background: color-mix(in sRGB, var(--sys-color-tonal-container), var(--sys-color-state-hover-on-subtle));
186 }
187
188 &.secondary {
189 background: var(--sys-color-state-hover-on-subtle);
190 }
191
192 &.toolbar,
193 &.round {
194 background-color: var(--sys-color-state-hover-on-subtle);
195 }
196
197 &.toobar {
198 devtools-icon {
199 color: var(--icon-default-hover);
200 }
201 }
202 }
203
204 &:active,
205 &.active {
206 &.primary {
207 background: color-mix(in sRGB, var(--sys-color-primary), var(--sys-color-state-ripple-primary) 32%);
208 border: var(--button-border-size) solid color-mix(in sRGB, var(--sys-color-primary), var(--sys-color-state-ripple-primary) 32%);
209 }
210
211 &.tonal {
212 background: color-mix(in sRGB, var(--sys-color-tonal-container), var(--sys-color-state-ripple-primary));
213 }
214
215 &.secondary {
216 background-color: var(--sys-color-surface-variant);
217 }
218
219 &.toolbar,
220 &.round {
221 background-color: var(--sys-color-state-ripple-neutral-on-subtle);
222 }
223
224 &.toolbar {
225 devtools-icon {
226 color: var(--icon-toggled);
227 }
228 }
229 }
Alex Rudenko5856ef32024-01-08 08:10:08230
231 &:disabled,
232 &:disabled:hover {
233 &.primary {
234 border: var(--button-border-size) solid var(--sys-color-state-disabled-container);
235 background: var(--sys-color-state-disabled-container);
236 color: var(--sys-color-state-disabled);
237 }
238
239 &.tonal {
240 border: var(--button-border-size) solid var(--sys-color-state-disabled-container);
241 background: var(--sys-color-state-disabled-container);
242 color: var(--sys-color-state-disabled);
243 }
244
245 &.secondary {
246 border: var(--button-border-size) solid var(--sys-color-state-disabled-container);
247 color: var(--sys-color-state-disabled);
248 }
249
250 &.toolbar,
251 &.round {
252 background: var(--sys-color-cdt-base-container);
253 color: var(--sys-color-state-disabled);
254 }
255 }
Alex Rudenkocc459b92021-08-11 13:53:48256}
257
Alex Rudenko3aa078e2024-01-03 13:52:47258.spinner {
Riho Isawabb8f3982021-11-26 11:58:16259 display: block;
260 width: 12px;
261 height: 12px;
262 border-radius: 6px;
Kateryna Prokopenko52805302023-10-09 14:30:18263 border: 2px solid var(--sys-color-cdt-base-container);
Riho Isawabb8f3982021-11-26 11:58:16264 animation: spinner-animation 1s linear infinite;
265 border-right-color: transparent;
Alex Rudenko9d873e52023-05-09 14:26:17266 margin-right: 4px;
Alex Rudenko3aa078e2024-01-03 13:52:47267
268 &.secondary {
269 border: 2px solid var(--sys-color-primary);
270 border-right-color: transparent;
271 }
272
273 &.disabled {
274 border: 2px solid var(--sys-color-state-disabled);
275 border-right-color: transparent;
276 }
Riho Isawabb8f3982021-11-26 11:58:16277}
278
279@keyframes spinner-animation {
280 from {
281 transform: rotate(0);
282 }
283
284 to {
285 transform: rotate(360deg);
286 }
287}