|
1 | 1 | /** SASS for the <button> HTML element |
2 | 2 | * |
3 | | - * Found in scss/components/_accordion.scss#74: `// Type button` |
4 | 3 | * Found in scss/components/_accordion.scss#75: `&[role="button"] {` |
5 | 4 | * Found in scss/components/_dropdown.scss#18: `> button,` |
6 | 5 | * Found in scss/components/_group.scss#43: `button,` |
7 | 6 | * Found in scss/components/_group.scss#46: `[type="button"],` |
8 | 7 | * Found in scss/components/_group.scss#47: `[role="button"],` |
9 | | - * Found in scss/components/_group.scss#55: `button,` |
10 | | - * Found in scss/components/_group.scss#58: `[type="button"],` |
11 | | - * Found in scss/components/_group.scss#59: `[role="button"] {` |
12 | | - * Found in scss/components/_group.scss#64: `// Group box shadow when a button is focused` |
13 | | - * Found in scss/components/_group.scss#65: `&:has(button:focus, [type="submit"]:focus, [type="button"]:focus, [role="button"]:focus) {` |
14 | | - * Found in scss/components/_group.scss#67: `#{\$css-var-prefix}group-box-shadow-focus-with-button` |
15 | | - * Found in scss/components/_group.scss#77: `&:has(input:not([type="submit"], [type="button"]):focus, select:focus) {` |
16 | | - * Found in scss/components/_group.scss#82: `// Adapt box shadow for buttons` |
17 | | - * Found in scss/components/_group.scss#83: `button,` |
18 | | - * Found in scss/components/_group.scss#85: `[type="button"],` |
19 | | - * Found in scss/components/_group.scss#86: `[role="button"] {` |
20 | | - * Found in scss/components/_group.scss#87: `#{\$css-var-prefix}button-box-shadow: 0 0 0 var(#{\$css-var-prefix}border-width)` |
21 | | - * Found in scss/components/_group.scss#89: `#{\$css-var-prefix}button-hover-box-shadow: 0 0 0 var(#{\$css-var-prefix}border-width)` |
22 | | - * Found in scss/components/_group.scss#94: `// Remove button box shadow if we have a group box shadow` |
23 | | - * Found in scss/components/_group.scss#95: `button,` |
24 | | - * Found in scss/components/_group.scss#98: `[type="button"],` |
25 | | - * Found in scss/components/_group.scss#99: `[role="button"] {` |
26 | 8 | * Found in scss/components/_loading.scss#36: `#{\$parent-selector} button,` |
27 | 9 | * Found in scss/components/_loading.scss#38: `#{\$parent-selector} [type="button"],` |
28 | 10 | * Found in scss/components/_loading.scss#40: `#{\$parent-selector} [role="button"],` |
29 | 11 | * Found in scss/components/_modal.scss#38: `".close, :is(a, button)[rel=prev]",` |
30 | 12 | * Found in scss/components/_modal.scss#39: `":is(a, button)[rel=prev]"` |
31 | 13 | * Found in scss/components/_modal.scss#74: `button,` |
32 | 14 | * Found in scss/components/_modal.scss#75: `[role="button"] {` |
33 | | - * Found in scss/components/_nav.scss#64: `// Minimal support for buttons and forms elements` |
34 | 15 | * Found in scss/components/_nav.scss#65: `button,` |
35 | 16 | * Found in scss/components/_nav.scss#66: `[role="button"],` |
36 | 17 | * Found in scss/components/_nav.scss#67: `[type="button"],` |
37 | | - * Found in scss/components/_nav.scss#139: `// Minimal support for links as buttons` |
38 | 18 | * Found in scss/components/_nav.scss#140: `[role="button"] {` |
39 | 19 | * Found in scss/components/_tooltip.scss#12: `&:not(a, button, input, [role="button"]) {` |
40 | | - * Found in scss/content/_button.scss#4: `@if map.get($modules, "content/button") {` |
41 | | - * Found in scss/content/_button.scss#17: `#{\$parent-selector} button {` |
42 | | - * Found in scss/content/_button.scss#24: `// Correct the inability to style buttons in iOS and Safari` |
43 | | - * Found in scss/content/_button.scss#25: `#{\$parent-selector} button,` |
44 | | - * Found in scss/content/_button.scss#28: `#{\$parent-selector} [type="button"] {` |
45 | | - * Found in scss/content/_button.scss#29: `-webkit-appearance: button;` |
46 | | - * Found in scss/content/_button.scss#35: `#{\$parent-selector} button,` |
47 | | - * Found in scss/content/_button.scss#38: `#{\$parent-selector} [type="button"],` |
48 | | - * Found in scss/content/_button.scss#39: `#{\$parent-selector} [type="file"]::file-selector-button,` |
49 | | - * Found in scss/content/_button.scss#40: `#{\$parent-selector} [role="button"] {` |
50 | | - * Found in scss/content/_button.scss#44: `#{\$css-var-prefix}box-shadow: var(#{\$css-var-prefix}button-box-shadow, 0 0 0 rgba(0, 0, 0, 0));` |
51 | | - * Found in scss/content/_button.scss#74: `#{\$css-var-prefix}button-hover-box-shadow,` |
52 | | - * Found in scss/content/_button.scss#83: `var(#{\$css-var-prefix}button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)),` |
53 | | - * Found in scss/content/_button.scss#90: `#{\$parent-selector} [type="button"] {` |
54 | | - * Found in scss/content/_button.scss#97: `#{\$parent-selector} :is(button, [type="submit"], [type="button"], [role="button"]).secondary,` |
55 | | - * Found in scss/content/_button.scss#99: `#{\$parent-selector} [type="file"]::file-selector-button {` |
56 | | - * Found in scss/content/_button.scss#114: `var(#{\$css-var-prefix}button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)),` |
57 | | - * Found in scss/content/_button.scss#120: `#{\$parent-selector} :is(button, [type="submit"], [type="button"], [role="button"]).contrast {` |
58 | | - * Found in scss/content/_button.scss#134: `var(#{\$css-var-prefix}button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)),` |
59 | | - * Found in scss/content/_button.scss#140: `#{\$parent-selector} :is(button, [type="submit"], [type="button"], [role="button"]).outline,` |
60 | | - * Found in scss/content/_button.scss#155: `:is(button, [type="submit"], [type="button"], [role="button"]).outline.secondary,` |
61 | | - * Found in scss/content/_button.scss#168: `:is(button, [type="submit"], [type="button"], [role="button"]).outline.contrast {` |
62 | | - * Found in scss/content/_button.scss#178: `// Secondary button without .class` |
63 | | - * Found in scss/content/_button.scss#180: `#{\$parent-selector} [type="file"]::file-selector-button {` |
64 | | - * Found in scss/content/_button.scss#194: `var(#{\$css-var-prefix}button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)),` |
65 | | - * Found in scss/content/_button.scss#202: `:where(button, [type="submit"], [type="reset"], [type="button"], [role="button"])[disabled],` |
66 | | - * Found in scss/content/_button.scss#205: `:is(button, [type="submit"], [type="button"], [type="reset"], [role="button"]) {` |
67 | 20 | * Found in scss/content/_link.scss#9: `#{\$parent-selector} :where(a:not([role="button"])),` |
68 | 21 | * Found in scss/content/_link.scss#65: `&[role="button"] {` |
69 | | - * Found in scss/forms/_basics.scss#61: `// Correct the cursor style of increment and decrement buttons in Safari` |
70 | 22 | * Found in scss/forms/_basics.scss#62: `#{\$parent-selector} ::-webkit-inner-spin-button,` |
71 | 23 | * Found in scss/forms/_basics.scss#63: `#{\$parent-selector} ::-webkit-outer-spin-button {` |
72 | 24 | * Found in scss/forms/_basics.scss#81: `#{\$parent-selector} ::-webkit-file-upload-button {` |
|
97 | 49 | -ms-touch-action: manipulation; |
98 | 50 | } |
99 | 51 | } |
| 52 | + |
| 53 | +@if map.get($modules, "content/button") { |
| 54 | + // 1. Change the font styles in all browsers |
| 55 | + // 2. Remove the margin on controls in Safari |
| 56 | + // 3. Show the overflow in Edge |
| 57 | + #{$parent-selector} button { |
| 58 | + margin: 0; // 2 |
| 59 | + overflow: visible; // 3 |
| 60 | + font-family: inherit; // 1 |
| 61 | + text-transform: none; // 1 |
| 62 | + } |
| 63 | + |
| 64 | + // Correct the inability to style buttons in iOS and Safari |
| 65 | + #{$parent-selector} button, |
| 66 | + #{$parent-selector} [type="submit"], |
| 67 | + #{$parent-selector} [type="reset"], |
| 68 | + #{$parent-selector} [type="button"] { |
| 69 | + -webkit-appearance: button; |
| 70 | + } |
| 71 | + |
| 72 | + // Pico |
| 73 | + // –––––––––––––––––––– |
| 74 | + |
| 75 | + #{$parent-selector} button, |
| 76 | + #{$parent-selector} [type="submit"], |
| 77 | + #{$parent-selector} [type="reset"], |
| 78 | + #{$parent-selector} [type="button"], |
| 79 | + #{$parent-selector} [type="file"]::file-selector-button, |
| 80 | + #{$parent-selector} [role="button"] { |
| 81 | + #{$css-var-prefix}background-color: var(#{$css-var-prefix}primary-background); |
| 82 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}primary-border); |
| 83 | + #{$css-var-prefix}color: var(#{$css-var-prefix}primary-inverse); |
| 84 | + #{$css-var-prefix}box-shadow: var(#{$css-var-prefix}button-box-shadow, 0 0 0 rgba(0, 0, 0, 0)); |
| 85 | + padding: var(#{$css-var-prefix}form-element-spacing-vertical) |
| 86 | + var(#{$css-var-prefix}form-element-spacing-horizontal); |
| 87 | + border: var(#{$css-var-prefix}border-width) solid var(#{$css-var-prefix}border-color); |
| 88 | + border-radius: var(#{$css-var-prefix}border-radius); |
| 89 | + outline: none; |
| 90 | + background-color: var(#{$css-var-prefix}background-color); |
| 91 | + box-shadow: var(#{$css-var-prefix}box-shadow); |
| 92 | + color: var(#{$css-var-prefix}color); |
| 93 | + font-weight: var(#{$css-var-prefix}font-weight); |
| 94 | + font-size: 1rem; |
| 95 | + line-height: var(#{$css-var-prefix}line-height); |
| 96 | + text-align: center; |
| 97 | + text-decoration: none; |
| 98 | + cursor: pointer; |
| 99 | + user-select: none; |
| 100 | + |
| 101 | + @if $enable-transitions { |
| 102 | + transition: |
| 103 | + background-color var(#{$css-var-prefix}transition), |
| 104 | + border-color var(#{$css-var-prefix}transition), |
| 105 | + color var(#{$css-var-prefix}transition), |
| 106 | + box-shadow var(#{$css-var-prefix}transition); |
| 107 | + } |
| 108 | + |
| 109 | + &:is([aria-current]:not([aria-current="false"])), |
| 110 | + &:is(:hover, :active, :focus) { |
| 111 | + #{$css-var-prefix}background-color: var(#{$css-var-prefix}primary-hover-background); |
| 112 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}primary-hover-border); |
| 113 | + #{$css-var-prefix}box-shadow: var( |
| 114 | + #{$css-var-prefix}button-hover-box-shadow, |
| 115 | + 0 0 0 rgba(0, 0, 0, 0) |
| 116 | + ); |
| 117 | + #{$css-var-prefix}color: var(#{$css-var-prefix}primary-inverse); |
| 118 | + } |
| 119 | + |
| 120 | + &:focus, |
| 121 | + &:is([aria-current]:not([aria-current="false"])):focus { |
| 122 | + #{$css-var-prefix}box-shadow: |
| 123 | + var(#{$css-var-prefix}button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)), |
| 124 | + 0 0 0 var(#{$css-var-prefix}outline-width) var(#{$css-var-prefix}primary-focus); |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + #{$parent-selector} [type="submit"], |
| 129 | + #{$parent-selector} [type="reset"], |
| 130 | + #{$parent-selector} [type="button"] { |
| 131 | + margin-bottom: var(#{$css-var-prefix}spacing); |
| 132 | + } |
| 133 | + |
| 134 | + // .secondary, .contrast & .outline |
| 135 | + @if $enable-classes { |
| 136 | + // Secondary |
| 137 | + #{$parent-selector} :is(button, [type="submit"], [type="button"], [role="button"]).secondary, |
| 138 | + #{$parent-selector} [type="reset"], |
| 139 | + #{$parent-selector} [type="file"]::file-selector-button { |
| 140 | + #{$css-var-prefix}background-color: var(#{$css-var-prefix}secondary-background); |
| 141 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}secondary-border); |
| 142 | + #{$css-var-prefix}color: var(#{$css-var-prefix}secondary-inverse); |
| 143 | + cursor: pointer; |
| 144 | + |
| 145 | + &:is([aria-current]:not([aria-current="false"]), :hover, :active, :focus) { |
| 146 | + #{$css-var-prefix}background-color: var(#{$css-var-prefix}secondary-hover-background); |
| 147 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}secondary-hover-border); |
| 148 | + #{$css-var-prefix}color: var(#{$css-var-prefix}secondary-inverse); |
| 149 | + } |
| 150 | + |
| 151 | + &:focus, |
| 152 | + &:is([aria-current]:not([aria-current="false"])):focus { |
| 153 | + #{$css-var-prefix}box-shadow: |
| 154 | + var(#{$css-var-prefix}button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)), |
| 155 | + 0 0 0 var(#{$css-var-prefix}outline-width) var(#{$css-var-prefix}secondary-focus); |
| 156 | + } |
| 157 | + } |
| 158 | + |
| 159 | + // Contrast |
| 160 | + #{$parent-selector} :is(button, [type="submit"], [type="button"], [role="button"]).contrast { |
| 161 | + #{$css-var-prefix}background-color: var(#{$css-var-prefix}contrast-background); |
| 162 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}contrast-border); |
| 163 | + #{$css-var-prefix}color: var(#{$css-var-prefix}contrast-inverse); |
| 164 | + |
| 165 | + &:is([aria-current]:not([aria-current="false"]), :hover, :active, :focus) { |
| 166 | + #{$css-var-prefix}background-color: var(#{$css-var-prefix}contrast-hover-background); |
| 167 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}contrast-hover-border); |
| 168 | + #{$css-var-prefix}color: var(#{$css-var-prefix}contrast-inverse); |
| 169 | + } |
| 170 | + |
| 171 | + &:focus, |
| 172 | + &:is([aria-current]:not([aria-current="false"])):focus { |
| 173 | + #{$css-var-prefix}box-shadow: |
| 174 | + var(#{$css-var-prefix}button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)), |
| 175 | + 0 0 0 var(#{$css-var-prefix}outline-width) var(#{$css-var-prefix}contrast-focus); |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + // Outline (primary) |
| 180 | + #{$parent-selector} :is(button, [type="submit"], [type="button"], [role="button"]).outline, |
| 181 | + [type="reset"].outline { |
| 182 | + #{$css-var-prefix}background-color: transparent; |
| 183 | + #{$css-var-prefix}color: var(#{$css-var-prefix}primary); |
| 184 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}primary); |
| 185 | + |
| 186 | + &:is([aria-current]:not([aria-current="false"]), :hover, :active, :focus) { |
| 187 | + #{$css-var-prefix}background-color: transparent; |
| 188 | + #{$css-var-prefix}color: var(#{$css-var-prefix}primary-hover); |
| 189 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}primary-hover); |
| 190 | + } |
| 191 | + } |
| 192 | + |
| 193 | + // Outline (secondary) |
| 194 | + #{$parent-selector} |
| 195 | + :is(button, [type="submit"], [type="button"], [role="button"]).outline.secondary, |
| 196 | + [type="reset"].outline { |
| 197 | + #{$css-var-prefix}color: var(#{$css-var-prefix}secondary); |
| 198 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}secondary); |
| 199 | + |
| 200 | + &:is([aria-current]:not([aria-current="false"]), :hover, :active, :focus) { |
| 201 | + #{$css-var-prefix}color: var(#{$css-var-prefix}secondary-hover); |
| 202 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}secondary-hover); |
| 203 | + } |
| 204 | + } |
| 205 | + |
| 206 | + // Outline (contrast) |
| 207 | + #{$parent-selector} |
| 208 | + :is(button, [type="submit"], [type="button"], [role="button"]).outline.contrast { |
| 209 | + #{$css-var-prefix}color: var(#{$css-var-prefix}contrast); |
| 210 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}contrast); |
| 211 | + |
| 212 | + &:is([aria-current]:not([aria-current="false"]), :hover, :active, :focus) { |
| 213 | + #{$css-var-prefix}color: var(#{$css-var-prefix}contrast-hover); |
| 214 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}contrast-hover); |
| 215 | + } |
| 216 | + } |
| 217 | + } @else { |
| 218 | + // Secondary button without .class |
| 219 | + #{$parent-selector} [type="reset"], |
| 220 | + #{$parent-selector} [type="file"]::file-selector-button { |
| 221 | + #{$css-var-prefix}background-color: var(#{$css-var-prefix}secondary-background); |
| 222 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}secondary-border); |
| 223 | + #{$css-var-prefix}color: var(#{$css-var-prefix}secondary-inverse); |
| 224 | + cursor: pointer; |
| 225 | + |
| 226 | + &:is([aria-current]:not([aria-current="false"]), :hover, :active, :focus) { |
| 227 | + #{$css-var-prefix}background-color: var(#{$css-var-prefix}secondary-hover-background); |
| 228 | + #{$css-var-prefix}border-color: var(#{$css-var-prefix}secondary-hover-border); |
| 229 | + #{$css-var-prefix}color: var(#{$css-var-prefix}secondary-inverse); |
| 230 | + } |
| 231 | + |
| 232 | + &:focus { |
| 233 | + #{$css-var-prefix}box-shadow: |
| 234 | + var(#{$css-var-prefix}button-hover-box-shadow, 0 0 0 rgba(0, 0, 0, 0)), |
| 235 | + 0 0 0 var(#{$css-var-prefix}outline-width) var(#{$css-var-prefix}secondary-focus); |
| 236 | + } |
| 237 | + } |
| 238 | + } |
| 239 | + |
| 240 | + // Button [disabled] |
| 241 | + #{$parent-selector} |
| 242 | + :where(button, [type="submit"], [type="reset"], [type="button"], [role="button"])[disabled], |
| 243 | + #{$parent-selector} |
| 244 | + :where(fieldset[disabled]) |
| 245 | + :is(button, [type="submit"], [type="button"], [type="reset"], [role="button"]) { |
| 246 | + opacity: 0.5; |
| 247 | + pointer-events: none; |
| 248 | + } |
| 249 | +} |
0 commit comments