Alex Rudenko | e4465d1 | 2021-08-09 11:37:37 | [diff] [blame] | 1 | /* |
| 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 Rudenko | 0bd7a1b | 2024-01-04 06:58:33 | [diff] [blame] | 7 | /** |
| 8 | * Design: http://go/cdt-design-button |
| 9 | */ |
Alex Rudenko | e4465d1 | 2021-08-09 11:37:37 | [diff] [blame] | 10 | * { |
| 11 | margin: 0; |
| 12 | padding: 0; |
| 13 | box-sizing: border-box; |
| 14 | } |
| 15 | |
Alex Rudenko | dc7c959 | 2021-09-30 09:00:55 | [diff] [blame] | 16 | /** |
| 17 | * Reset default UA styles for focused elements. |
| 18 | * The button styles below explicitly implement custom focus styles. |
| 19 | */ |
Alex Rudenko | e4465d1 | 2021-08-09 11:37:37 | [diff] [blame] | 20 | *:focus, |
Alex Rudenko | dc7c959 | 2021-09-30 09:00:55 | [diff] [blame] | 21 | *:focus-visible, |
| 22 | :host(:focus), |
| 23 | :host(:focus-visible) { |
Alex Rudenko | e4465d1 | 2021-08-09 11:37:37 | [diff] [blame] | 24 | outline: none; |
| 25 | } |
| 26 | |
Alex Rudenko | e6ba352 | 2021-10-15 06:09:48 | [diff] [blame] | 27 | :host { |
| 28 | display: inline-flex; |
| 29 | flex-direction: row; |
| 30 | } |
| 31 | |
Alex Rudenko | e4465d1 | 2021-08-09 11:37:37 | [diff] [blame] | 32 | button { |
Ergün Erdoğmuş | 0cd36dc | 2022-05-03 09:54:16 | [diff] [blame] | 33 | /* |
| 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 Rudenko | 9d873e5 | 2023-05-09 14:26:17 | [diff] [blame] | 45 | --button-border-size: 1px; |
| 46 | --button-height: 24px; |
| 47 | --button-width: 100%; |
Ergün Erdoğmuş | 0cd36dc | 2022-05-03 09:54:16 | [diff] [blame] | 48 | |
Alex Rudenko | e4465d1 | 2021-08-09 11:37:37 | [diff] [blame] | 49 | align-items: center; |
Alex Rudenko | 0bd7a1b | 2024-01-04 06:58:33 | [diff] [blame] | 50 | background: transparent; |
Kateryna Prokopenko | 211fe2e | 2023-08-30 13:56:17 | [diff] [blame] | 51 | border-radius: 12px calc(var(--button-has-right-border-radius) * 12px) calc(var(--button-has-right-border-radius) * 12px) 12px; |
Alex Rudenko | cc459b9 | 2021-08-11 13:53:48 | [diff] [blame] | 52 | display: inline-flex; |
| 53 | font-family: inherit; |
Alex Rudenko | e4465d1 | 2021-08-09 11:37:37 | [diff] [blame] | 54 | font-size: 12px; |
Riho Isawa | af47cc8 | 2021-10-27 02:27:16 | [diff] [blame] | 55 | font-weight: 500; |
Alex Rudenko | 9d873e5 | 2023-05-09 14:26:17 | [diff] [blame] | 56 | height: var(--button-height); |
Alex Rudenko | 50b3a3e | 2021-09-29 11:01:46 | [diff] [blame] | 57 | justify-content: center; |
Alex Rudenko | 0bd7a1b | 2024-01-04 06:58:33 | [diff] [blame] | 58 | line-height: 14px; |
| 59 | padding: 0; |
Benedikt Meurer | c635aa8 | 2022-12-13 08:20:57 | [diff] [blame] | 60 | white-space: nowrap; |
Alex Rudenko | 0bd7a1b | 2024-01-04 06:58:33 | [diff] [blame] | 61 | width: var(--button-width); |
Alex Rudenko | 3aa078e | 2024-01-03 13:52:47 | [diff] [blame] | 62 | |
| 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 Rudenko | 3aa078e | 2024-01-03 13:52:47 | [diff] [blame] | 79 | border: none; |
| 80 | overflow: hidden; |
Alex Rudenko | 3aa078e | 2024-01-03 13:52:47 | [diff] [blame] | 81 | |
| 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 Rudenko | 3aa078e | 2024-01-03 13:52:47 | [diff] [blame] | 137 | &: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 Rudenko | 3aa078e | 2024-01-03 13:52:47 | [diff] [blame] | 149 | devtools-icon { |
| 150 | color: var(--icon-disabled); |
| 151 | } |
| 152 | } |
| 153 | |
Alex Rudenko | 0bd7a1b | 2024-01-04 06:58:33 | [diff] [blame] | 154 | &.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 Beyer | 9e87974 | 2024-01-11 10:23:39 | [diff] [blame^] | 163 | &.small { |
Alex Rudenko | 0bd7a1b | 2024-01-04 06:58:33 | [diff] [blame] | 164 | 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 Rudenko | 3aa078e | 2024-01-03 13:52:47 | [diff] [blame] | 178 | &: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 Rudenko | 5856ef3 | 2024-01-08 08:10:08 | [diff] [blame] | 230 | |
| 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 Rudenko | cc459b9 | 2021-08-11 13:53:48 | [diff] [blame] | 256 | } |
| 257 | |
Alex Rudenko | 3aa078e | 2024-01-03 13:52:47 | [diff] [blame] | 258 | .spinner { |
Riho Isawa | bb8f398 | 2021-11-26 11:58:16 | [diff] [blame] | 259 | display: block; |
| 260 | width: 12px; |
| 261 | height: 12px; |
| 262 | border-radius: 6px; |
Kateryna Prokopenko | 5280530 | 2023-10-09 14:30:18 | [diff] [blame] | 263 | border: 2px solid var(--sys-color-cdt-base-container); |
Riho Isawa | bb8f398 | 2021-11-26 11:58:16 | [diff] [blame] | 264 | animation: spinner-animation 1s linear infinite; |
| 265 | border-right-color: transparent; |
Alex Rudenko | 9d873e5 | 2023-05-09 14:26:17 | [diff] [blame] | 266 | margin-right: 4px; |
Alex Rudenko | 3aa078e | 2024-01-03 13:52:47 | [diff] [blame] | 267 | |
| 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 Isawa | bb8f398 | 2021-11-26 11:58:16 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | @keyframes spinner-animation { |
| 280 | from { |
| 281 | transform: rotate(0); |
| 282 | } |
| 283 | |
| 284 | to { |
| 285 | transform: rotate(360deg); |
| 286 | } |
| 287 | } |