material-inspired-component-library 8.1.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/README.md +106 -18
  2. package/components/README.md +1 -1
  3. package/components/accordion/README.md +6 -6
  4. package/components/alert/README.md +10 -10
  5. package/components/alert/index.scss +27 -52
  6. package/components/appbar/README.md +19 -6
  7. package/components/appbar/index.scss +40 -44
  8. package/components/badge/README.md +12 -10
  9. package/components/badge/index.scss +21 -25
  10. package/components/bottomsheet/README.md +26 -1
  11. package/components/bottomsheet/index.scss +58 -44
  12. package/components/button/README.md +70 -10
  13. package/components/button/_shared.scss +210 -0
  14. package/components/button/index.scss +75 -389
  15. package/components/card/README.md +97 -85
  16. package/components/card/index.scss +46 -65
  17. package/components/checkbox/README.md +25 -14
  18. package/{tools/shapes/check.mjs → components/checkbox/_label.scss} +37 -42
  19. package/components/checkbox/index.scss +66 -66
  20. package/components/chip/README.md +186 -0
  21. package/components/chip/index.scss +285 -0
  22. package/components/datepicker/README.md +79 -0
  23. package/components/datepicker/index.scss +346 -315
  24. package/components/dialog/README.md +20 -10
  25. package/components/dialog/index.scss +55 -66
  26. package/components/divider/README.md +16 -15
  27. package/components/divider/index.scss +9 -25
  28. package/components/iconbutton/README.md +63 -12
  29. package/components/iconbutton/index.scss +142 -303
  30. package/components/list/README.md +89 -156
  31. package/components/list/index.scss +34 -36
  32. package/components/menu/README.md +81 -155
  33. package/components/menu/index.scss +52 -58
  34. package/components/navigationbar/README.md +108 -0
  35. package/components/navigationbar/index.scss +185 -0
  36. package/components/navigationrail/README.md +62 -37
  37. package/components/navigationrail/_navitem.scss +96 -0
  38. package/components/navigationrail/index.scss +78 -132
  39. package/components/progressindicator/README.md +83 -47
  40. package/components/progressindicator/index.scss +622 -172
  41. package/components/radio/README.md +11 -9
  42. package/components/radio/index.scss +36 -33
  43. package/components/select/README.md +12 -7
  44. package/components/select/index.scss +26 -34
  45. package/components/shapes/README.md +3 -3
  46. package/components/shapes/index.scss +0 -1
  47. package/components/sidesheet/README.md +21 -9
  48. package/components/sidesheet/index.scss +38 -46
  49. package/components/slider/README.md +21 -0
  50. package/components/slider/index.scss +108 -139
  51. package/components/snackbar/README.md +32 -35
  52. package/components/snackbar/index.scss +10 -22
  53. package/components/stepper/README.md +14 -7
  54. package/components/stepper/index.scss +58 -39
  55. package/components/switch/README.md +22 -15
  56. package/components/switch/index.scss +68 -60
  57. package/components/textfield/README.md +48 -5
  58. package/components/textfield/index.scss +192 -248
  59. package/components/timepicker/README.md +53 -23
  60. package/components/timepicker/index.scss +110 -128
  61. package/dist/alert.css +1 -1
  62. package/dist/alert.js +1 -1
  63. package/dist/appbar.css +1 -1
  64. package/dist/appbar.js +1 -1
  65. package/dist/badge.css +1 -1
  66. package/dist/badge.js +1 -1
  67. package/dist/base.css +1 -0
  68. package/dist/base.js +1 -0
  69. package/dist/bottomsheet.css +1 -1
  70. package/dist/bottomsheet.js +1 -1
  71. package/dist/button.css +1 -1
  72. package/dist/button.js +1 -1
  73. package/dist/card.css +1 -1
  74. package/dist/card.js +1 -1
  75. package/dist/checkbox.css +1 -1
  76. package/dist/checkbox.js +1 -1
  77. package/dist/chip.css +1 -0
  78. package/dist/chip.js +1 -0
  79. package/dist/components/button/index.d.ts +1 -1
  80. package/dist/components/iconbutton/index.d.ts +2 -7
  81. package/dist/components/slider/index.d.ts +1 -1
  82. package/dist/components/textfield/index.d.ts +2 -2
  83. package/dist/datepicker.css +1 -1
  84. package/dist/datepicker.js +1 -1
  85. package/dist/dialog.css +1 -1
  86. package/dist/dialog.js +1 -1
  87. package/dist/divider.css +1 -1
  88. package/dist/divider.js +1 -1
  89. package/dist/field.css +1 -0
  90. package/dist/field.js +1 -0
  91. package/dist/foundations/form/index.js +1 -1
  92. package/dist/foundations/runtime.d.ts +15 -0
  93. package/dist/foundations/runtime.js +1 -0
  94. package/dist/iconbutton.css +1 -1
  95. package/dist/iconbutton.js +1 -1
  96. package/dist/layout.css +1 -1
  97. package/dist/layout.js +1 -1
  98. package/dist/list.css +1 -1
  99. package/dist/list.js +1 -1
  100. package/dist/menu.css +1 -1
  101. package/dist/menu.js +1 -1
  102. package/dist/micl.css +1 -1
  103. package/dist/micl.d.ts +14 -5
  104. package/dist/micl.js +1 -1
  105. package/dist/navigationbar.css +1 -0
  106. package/dist/navigationbar.js +1 -0
  107. package/dist/navigationrail.css +1 -1
  108. package/dist/navigationrail.js +1 -1
  109. package/dist/progressindicator.css +1 -1
  110. package/dist/progressindicator.js +1 -1
  111. package/dist/radio.css +1 -1
  112. package/dist/radio.js +1 -1
  113. package/dist/scrollbar.js +1 -1
  114. package/dist/select.css +1 -1
  115. package/dist/select.js +1 -1
  116. package/dist/shapes.css +1 -1
  117. package/dist/shapes.js +1 -1
  118. package/dist/sidesheet.css +1 -1
  119. package/dist/sidesheet.js +1 -1
  120. package/dist/slider.css +1 -1
  121. package/dist/slider.js +1 -1
  122. package/dist/snackbar.css +1 -1
  123. package/dist/snackbar.js +1 -1
  124. package/dist/stepper.css +1 -1
  125. package/dist/stepper.js +1 -1
  126. package/dist/switch.css +1 -1
  127. package/dist/switch.js +1 -1
  128. package/dist/textfield.css +1 -1
  129. package/dist/textfield.js +1 -1
  130. package/dist/timepicker.css +1 -1
  131. package/dist/timepicker.js +1 -1
  132. package/foundations/_index.scss +35 -0
  133. package/foundations/{index.scss → base/index.scss} +21 -56
  134. package/foundations/field/index.scss +37 -0
  135. package/foundations/layout/index.scss +64 -65
  136. package/package.json +23 -9
  137. package/styles/statelayer.scss +20 -5
  138. package/styles.scss +5 -2
  139. package/.claude/settings.local.json +0 -14
  140. package/.editorconfig +0 -12
  141. package/.gitattributes +0 -9
  142. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
  143. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  144. package/CLAUDE.md +0 -53
  145. package/CODE_OF_CONDUCT.md +0 -128
  146. package/components/bottomsheet/index.ts +0 -153
  147. package/components/button/index.ts +0 -79
  148. package/components/checkbox/index.ts +0 -148
  149. package/components/datepicker/index.ts +0 -693
  150. package/components/iconbutton/index.ts +0 -77
  151. package/components/list/index.ts +0 -138
  152. package/components/menu/index.ts +0 -145
  153. package/components/navigationrail/index.ts +0 -87
  154. package/components/progressindicator/index.ts +0 -77
  155. package/components/slider/index.ts +0 -149
  156. package/components/snackbar/index.ts +0 -118
  157. package/components/stepper/index.ts +0 -248
  158. package/components/textfield/index.ts +0 -188
  159. package/components/timepicker/index.ts +0 -413
  160. package/dist/components/progressindicator/index.d.ts +0 -6
  161. package/dist/foundations.css +0 -1
  162. package/dist/foundations.js +0 -1
  163. package/docs/accordion.html +0 -344
  164. package/docs/alert.html +0 -177
  165. package/docs/bottomsheet.html +0 -240
  166. package/docs/button.html +0 -290
  167. package/docs/card-awards.webp +0 -0
  168. package/docs/card-cabinet.webp +0 -0
  169. package/docs/card-city.webp +0 -0
  170. package/docs/card-fingerprint.webp +0 -0
  171. package/docs/card-holiday.webp +0 -0
  172. package/docs/card-names.webp +0 -0
  173. package/docs/card.html +0 -159
  174. package/docs/checkbox.html +0 -147
  175. package/docs/datepicker.html +0 -274
  176. package/docs/dialog.html +0 -195
  177. package/docs/divider.html +0 -139
  178. package/docs/docs.css +0 -26
  179. package/docs/docs.js +0 -139
  180. package/docs/iconbutton.html +0 -329
  181. package/docs/index.html +0 -431
  182. package/docs/list.html +0 -310
  183. package/docs/menu.html +0 -574
  184. package/docs/micl.css +0 -1
  185. package/docs/micl.js +0 -1
  186. package/docs/navigationrail.html +0 -138
  187. package/docs/progressindicator.html +0 -288
  188. package/docs/radio.html +0 -123
  189. package/docs/select.html +0 -337
  190. package/docs/shapes.css +0 -1
  191. package/docs/shapes.html +0 -159
  192. package/docs/shapes.js +0 -1
  193. package/docs/sidesheet.html +0 -149
  194. package/docs/slider.html +0 -141
  195. package/docs/snackbar.html +0 -102
  196. package/docs/stepper.html +0 -319
  197. package/docs/switch.html +0 -196
  198. package/docs/textfield.html +0 -208
  199. package/docs/themes/airblue/dark-hc.css +0 -51
  200. package/docs/themes/airblue/dark-mc.css +0 -51
  201. package/docs/themes/airblue/dark.css +0 -51
  202. package/docs/themes/airblue/light-hc.css +0 -51
  203. package/docs/themes/airblue/light-mc.css +0 -51
  204. package/docs/themes/airblue/light.css +0 -51
  205. package/docs/themes/airblue/theme.css +0 -306
  206. package/docs/themes/barnred/dark-hc.css +0 -51
  207. package/docs/themes/barnred/dark-mc.css +0 -51
  208. package/docs/themes/barnred/dark.css +0 -51
  209. package/docs/themes/barnred/light-hc.css +0 -51
  210. package/docs/themes/barnred/light-mc.css +0 -51
  211. package/docs/themes/barnred/light.css +0 -51
  212. package/docs/themes/barnred/theme.css +0 -306
  213. package/docs/themes/citrine/dark-hc.css +0 -51
  214. package/docs/themes/citrine/dark-mc.css +0 -51
  215. package/docs/themes/citrine/dark.css +0 -51
  216. package/docs/themes/citrine/light-hc.css +0 -51
  217. package/docs/themes/citrine/light-mc.css +0 -51
  218. package/docs/themes/citrine/light.css +0 -51
  219. package/docs/themes/citrine/theme.css +0 -306
  220. package/docs/themes/gray/dark-hc.css +0 -51
  221. package/docs/themes/gray/dark-mc.css +0 -51
  222. package/docs/themes/gray/dark.css +0 -51
  223. package/docs/themes/gray/light-hc.css +0 -51
  224. package/docs/themes/gray/light-mc.css +0 -51
  225. package/docs/themes/gray/light.css +0 -51
  226. package/docs/themes/gray/theme.css +0 -306
  227. package/docs/themes/greenery/dark-hc.css +0 -51
  228. package/docs/themes/greenery/dark-mc.css +0 -51
  229. package/docs/themes/greenery/dark.css +0 -51
  230. package/docs/themes/greenery/light-hc.css +0 -51
  231. package/docs/themes/greenery/light-mc.css +0 -51
  232. package/docs/themes/greenery/light.css +0 -51
  233. package/docs/themes/greenery/theme.css +0 -306
  234. package/docs/themes/hermana/dark-hc.css +0 -51
  235. package/docs/themes/hermana/dark-mc.css +0 -51
  236. package/docs/themes/hermana/dark.css +0 -51
  237. package/docs/themes/hermana/light-hc.css +0 -51
  238. package/docs/themes/hermana/light-mc.css +0 -51
  239. package/docs/themes/hermana/light.css +0 -51
  240. package/docs/themes/hermana/theme.css +0 -306
  241. package/docs/themes/illuminating/dark-hc.css +0 -51
  242. package/docs/themes/illuminating/dark-mc.css +0 -51
  243. package/docs/themes/illuminating/dark.css +0 -51
  244. package/docs/themes/illuminating/light-hc.css +0 -51
  245. package/docs/themes/illuminating/light-mc.css +0 -51
  246. package/docs/themes/illuminating/light.css +0 -51
  247. package/docs/themes/illuminating/theme.css +0 -306
  248. package/docs/themes/magenta/dark-hc.css +0 -51
  249. package/docs/themes/magenta/dark-mc.css +0 -51
  250. package/docs/themes/magenta/dark.css +0 -51
  251. package/docs/themes/magenta/light-hc.css +0 -51
  252. package/docs/themes/magenta/light-mc.css +0 -51
  253. package/docs/themes/magenta/light.css +0 -51
  254. package/docs/themes/magenta/theme.css +0 -306
  255. package/docs/themes/mocha/dark-hc.css +0 -51
  256. package/docs/themes/mocha/dark-mc.css +0 -51
  257. package/docs/themes/mocha/dark.css +0 -51
  258. package/docs/themes/mocha/light-hc.css +0 -51
  259. package/docs/themes/mocha/light-mc.css +0 -51
  260. package/docs/themes/mocha/light.css +0 -51
  261. package/docs/themes/mocha/theme.css +0 -306
  262. package/docs/themes/olivegreen/dark-hc.css +0 -51
  263. package/docs/themes/olivegreen/dark-mc.css +0 -51
  264. package/docs/themes/olivegreen/dark.css +0 -51
  265. package/docs/themes/olivegreen/light-hc.css +0 -51
  266. package/docs/themes/olivegreen/light-mc.css +0 -51
  267. package/docs/themes/olivegreen/light.css +0 -51
  268. package/docs/themes/olivegreen/theme.css +0 -306
  269. package/docs/themes/peri/dark-hc.css +0 -51
  270. package/docs/themes/peri/dark-mc.css +0 -51
  271. package/docs/themes/peri/dark.css +0 -51
  272. package/docs/themes/peri/light-hc.css +0 -51
  273. package/docs/themes/peri/light-mc.css +0 -51
  274. package/docs/themes/peri/light.css +0 -51
  275. package/docs/themes/peri/theme.css +0 -306
  276. package/docs/timepicker.html +0 -160
  277. package/foundations/form/index.ts +0 -174
  278. package/foundations/layout/README.md +0 -127
  279. package/intl.d.ts +0 -9
  280. package/micl.ts +0 -221
  281. package/styles/README.md +0 -196
  282. package/tools/shapes/generate.mjs +0 -828
  283. package/tsconfig.json +0 -116
  284. package/webpack.config.js +0 -104
@@ -23,7 +23,7 @@ Or import all MICL styles:
23
23
  ```
24
24
 
25
25
  ### JavaScript
26
- This component requires JavaScript for interactive features like the **toggle logic**:
26
+ This component requires JavaScript to support the **toggle logic**:
27
27
 
28
28
  ```JavaScript
29
29
  import micl from "material-inspired-component-library/dist/micl";
@@ -40,7 +40,7 @@ Buttons come in **five sizes**: extra small (`xs`), small (`s`), medium (`m`), l
40
40
  **Example: An extra-large text button**
41
41
 
42
42
  ```HTML
43
- <button type="button" class="micl-button-text-xl>Save</button>
43
+ <button type="button" class="micl-button-text-xl">Save</button>
44
44
  ```
45
45
 
46
46
  Material Design provides **five distinct styles**: `text`, `elevated`, `filled`, `tonal` and `outlined`. To use a style other than the `text` style used above, apply the corresponding class to the button:
@@ -56,9 +56,9 @@ By default, buttons have a **rounded shape**. For a more square-like appearance,
56
56
  Adding the `disabled` boolean attribute to the button causes the button to be displayed in a disabled state.
57
57
 
58
58
  ### Toggle Button
59
- A toggle button has two states: **on** (selected) and **off** (unselected). To create one, add the `micl-button--toggle` class.
60
- - **Off state**: The button has the `micl-button--toggle` class.
61
- - **On state**: The button has both the `micl-button--toggle` and `micl-button--selected` classes.
59
+ A toggle button has two states: **on** (pressed) and **off** (unpressed). To create one, add the `micl-button--toggle` class and an `aria-pressed` attribute.
60
+ - **Off state**: The button has the `micl-button--toggle` class and `aria-pressed="false"`.
61
+ - **On state**: The button has the `micl-button--toggle` class and `aria-pressed="true"`.
62
62
 
63
63
  **Example: A selected toggle button**
64
64
 
@@ -66,13 +66,14 @@ A toggle button has two states: **on** (selected) and **off** (unselected). To c
66
66
  <button
67
67
  type="button"
68
68
  id="id0"
69
- class="micl-button-tonal-s micl-button--toggle micl-button--selected"
69
+ class="micl-button-tonal-s micl-button--toggle"
70
+ aria-pressed="true"
70
71
  commandfor="id0"
71
72
  command="--micl-toggle"
72
73
  >Selected</button>
73
74
  ```
74
75
 
75
- The self-targeting `command` property (`--micl-toggle`) toggles the button state whenever the user interacts with the button.
76
+ The self-targeting `command` property (`--micl-toggle`) flips `aria-pressed` whenever the user interacts with the button.
76
77
 
77
78
  ## Icons
78
79
  To add a leading icon to a button, include an element with the `micl-button__icon` class inside the `<button>`:
@@ -84,14 +85,14 @@ To add a leading icon to a button, include an element with the `micl-button__ico
84
85
  </button>
85
86
  ```
86
87
 
87
- To use different icons for the **on** state and the **off** state in a toggle button, remove the icon name from the `micl-button__icon` element and add the `data-miclicon` (the name of the **on** icon) and `data-micliconselected` (the name of the **off** icon) attributes:
88
+ To use different icons for the **on** state and the **off** state in a toggle button, remove the icon name from the `micl-button__icon` element and add the `data-miclicon` (the name of the **off** icon) and `data-micliconselected` (the name of the **on** icon) attributes:
88
89
 
89
90
  ```HTML
90
91
  ...
91
92
  <span
92
93
  class="micl-button__icon material-symbols-outlined"
93
- data-miclicon="icon_for_on"
94
- data-micliconselected="icon_for_off"
94
+ data-miclicon="icon_for_off"
95
+ data-micliconselected="icon_for_on"
95
96
  aria-hidden="true"
96
97
  ><span>
97
98
  ...
@@ -114,5 +115,64 @@ You can also use other icon libraries. For example, with the [Bootstrap Icons li
114
115
  </button>
115
116
  ```
116
117
 
118
+ ## Theming
119
+ Each button style can be themed with CSS custom properties that follow the Material Design 3 component-token naming convention. Note that the `selected-*` and `unselected-*` properties only apply to [toggle buttons](#toggle-button).
120
+
121
+ ### Text
122
+ | Custom property | Meaning | Default |
123
+ |---|---|---|
124
+ | `--md-comp-text-button-label-text-color` | Label & icon colour | `--md-sys-color-primary` |
125
+ | `--md-comp-text-button-disabled-label-text-color` | Label & icon colour when disabled | `--md-sys-color-on-surface-variant` |
126
+ | `--md-comp-text-button-disabled-label-text-opacity` | Label & icon opacity when disabled | `38%` |
127
+
128
+ ### Elevated
129
+ | Custom property | Meaning | Default |
130
+ |---|---|---|
131
+ | `--md-comp-elevated-button-container-color` | Container background | `--md-sys-color-surface-container-low` |
132
+ | `--md-comp-elevated-button-container-elevation` | Container elevation (shadow) | `--md-sys-elevation-level1` |
133
+ | `--md-comp-elevated-button-label-text-color` | Label & icon colour | `--md-sys-color-primary` |
134
+ | `--md-comp-elevated-button-selected-container-color` | Container background when selected | `--md-sys-color-primary` |
135
+ | `--md-comp-elevated-button-selected-label-text-color` | Label & icon colour when selected | `--md-sys-color-on-primary` |
136
+ | `--md-comp-elevated-button-disabled-container-color` | Container background when disabled | `--md-sys-color-on-surface` |
137
+ | `--md-comp-elevated-button-disabled-container-opacity` | Container opacity when disabled | `10%` |
138
+ | `--md-comp-elevated-button-disabled-label-text-color` | Label & icon colour when disabled | `--md-sys-color-on-surface-variant` |
139
+ | `--md-comp-elevated-button-disabled-label-text-opacity` | Label & icon opacity when disabled | `38%` |
140
+
141
+ ### Filled
142
+ | Custom property | Meaning | Default |
143
+ |---|---|---|
144
+ | `--md-comp-filled-button-container-color` | Container background (also the selected state) | `--md-sys-color-primary` |
145
+ | `--md-comp-filled-button-label-text-color` | Label & icon colour (also the selected state) | `--md-sys-color-on-primary` |
146
+ | `--md-comp-filled-button-unselected-container-color` | Container background when an unselected toggle | `--md-sys-color-surface-container` |
147
+ | `--md-comp-filled-button-unselected-label-text-color` | Label & icon colour when an unselected toggle | `--md-sys-color-on-surface-variant` |
148
+ | `--md-comp-filled-button-disabled-container-color` | Container background when disabled | `--md-sys-color-on-surface` |
149
+ | `--md-comp-filled-button-disabled-container-opacity` | Container opacity when disabled | `10%` |
150
+ | `--md-comp-filled-button-disabled-label-text-color` | Label & icon colour when disabled | `--md-sys-color-on-surface-variant` |
151
+ | `--md-comp-filled-button-disabled-label-text-opacity` | Label & icon opacity when disabled | `38%` |
152
+
153
+ ### Tonal
154
+ | Custom property | Meaning | Default |
155
+ |---|---|---|
156
+ | `--md-comp-filled-tonal-button-container-color` | Container background | `--md-sys-color-secondary-container` |
157
+ | `--md-comp-filled-tonal-button-label-text-color` | Label & icon colour | `--md-sys-color-on-secondary-container` |
158
+ | `--md-comp-filled-tonal-button-selected-container-color` | Container background when selected | `--md-sys-color-secondary` |
159
+ | `--md-comp-filled-tonal-button-selected-label-text-color` | Label & icon colour when selected | `--md-sys-color-on-secondary` |
160
+ | `--md-comp-filled-tonal-button-disabled-container-color` | Container background when disabled | `--md-sys-color-on-surface` |
161
+ | `--md-comp-filled-tonal-button-disabled-container-opacity` | Container opacity when disabled | `10%` |
162
+ | `--md-comp-filled-tonal-button-disabled-label-text-color` | Label & icon colour when disabled | `--md-sys-color-on-surface-variant` |
163
+ | `--md-comp-filled-tonal-button-disabled-label-text-opacity` | Label & icon opacity when disabled | `38%` |
164
+
165
+ ### Outlined
166
+ | Custom property | Meaning | Default |
167
+ |---|---|---|
168
+ | `--md-comp-outlined-button-outline-color` | Outline (border) colour | `--md-sys-color-outline-variant` |
169
+ | `--md-comp-outlined-button-label-text-color` | Label & icon colour | `--md-sys-color-on-surface-variant` |
170
+ | `--md-comp-outlined-button-selected-container-color` | Container background when selected | `--md-sys-color-inverse-surface` |
171
+ | `--md-comp-outlined-button-selected-label-text-color` | Label & icon colour when selected | `--md-sys-color-inverse-on-surface` |
172
+ | `--md-comp-outlined-button-selected-disabled-container-color` | Container background when selected and disabled | `--md-sys-color-on-surface` |
173
+ | `--md-comp-outlined-button-selected-disabled-container-opacity` | Container opacity when selected and disabled | `10%` |
174
+ | `--md-comp-outlined-button-disabled-label-text-color` | Label & icon colour when disabled | `--md-sys-color-on-surface-variant` |
175
+ | `--md-comp-outlined-button-disabled-label-text-opacity` | Label & icon opacity when disabled | `38%` |
176
+
117
177
  ## Compatibility
118
178
  This component utilizes relative RGB color values, which may not be fully supported in your browser. Please check [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#browser_compatibility) for details.
@@ -0,0 +1,210 @@
1
+ //
2
+ // Copyright © 2025 Hermana AS
3
+ //
4
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ // of this software and associated documentation files (the "Software"), to deal
6
+ // in the Software without restriction, including without limitation the rights
7
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ // copies of the Software, and to permit persons to whom the Software is
9
+ // furnished to do so, subject to the following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included in all
12
+ // copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ // SOFTWARE.
21
+
22
+ // The shared foundation of the Button component: the state selectors and the
23
+ // %micl-button-* placeholders, which the Chip component extends as well.
24
+
25
+ @use '../../styles/elevation';
26
+ @use '../../styles/motion';
27
+ @use '../../styles/statelayer';
28
+ @use '../../styles/typography';
29
+
30
+ $disabled: ':is(:disabled, :has(input:disabled, > button:disabled))';
31
+ $enabled: ':not(:disabled, :has(input:disabled, > button:disabled))';
32
+ $focused: ':is(:focus-visible, :has(input:focus-visible))';
33
+
34
+ @include elevation.level(0);
35
+ @include elevation.level(1);
36
+ @include elevation.level(2);
37
+
38
+ @include statelayer.token('hover-state-layer-opacity');
39
+ @include statelayer.token('focus-state-layer-opacity');
40
+ @include statelayer.token('pressed-state-layer-opacity');
41
+ @include statelayer.token('disabled-state-layer-opacity');
42
+ @include statelayer.token('focus-indicator-thickness');
43
+ @include statelayer.token('ripple-opacity-factor');
44
+ @include statelayer.token('ripple-duration');
45
+ @include statelayer.property;
46
+ @include statelayer.keyframes;
47
+
48
+ @include typography.scale('label-large');
49
+
50
+ %micl-button-base {
51
+ --md-comp-button-motion-effects: #{motion.$md-sys-motion-expressive-fast-spatial};
52
+ --md-comp-button-motion-duration: #{motion.$md-sys-motion-expressive-fast-spatial-duration};
53
+ --micl-ripple: 1;
54
+
55
+ box-sizing: border-box;
56
+ position: relative;
57
+ display: inline-flex;
58
+ flex-shrink: 0;
59
+ align-items: center;
60
+ justify-content: center;
61
+ padding: 0;
62
+ border: none;
63
+ border-radius: calc(var(--micl-height) / 2);
64
+ background-image:
65
+ radial-gradient(
66
+ circle at var(--micl-x, center) var(--micl-y, center),
67
+ transparent 0%,
68
+ rgb(from var(--statelayer-color) r g b / calc(var(--statelayer-opacity) * var(--md-sys-state-ripple-opacity-factor))) 10%,
69
+ transparent 10%
70
+ ),
71
+ linear-gradient(rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)));
72
+ background-repeat: no-repeat;
73
+ background-position: var(--micl-x, center) var(--micl-y, center), 0 0;
74
+ background-size: 0%, 100%;
75
+ -webkit-tap-highlight-color: transparent;
76
+ cursor: pointer;
77
+ transition:
78
+ border-radius var(--md-comp-button-motion-duration) var(--md-comp-button-motion-effects),
79
+ box-shadow var(--md-comp-button-motion-duration) var(--md-comp-button-motion-effects),
80
+ background-size 0ms,
81
+ --statelayer-opacity var(--md-comp-button-motion-duration) linear;
82
+
83
+ &#{$disabled} {
84
+ cursor: default;
85
+ }
86
+ &#{$enabled} {
87
+ &:hover {
88
+ --statelayer-opacity: var(--md-sys-state-hover-state-layer-opacity, 8%);
89
+
90
+ .micl-button__icon {
91
+ font-variation-settings: 'FILL' 1;
92
+ }
93
+ }
94
+ &#{$focused} {
95
+ --statelayer-opacity: var(--md-sys-state-focus-state-layer-opacity, 10%);
96
+
97
+ outline: var(--md-sys-state-focus-indicator-thickness, 3px) solid var(--md-sys-color-secondary);
98
+ outline-offset: 2px;
99
+ }
100
+ &:active {
101
+ --statelayer-opacity: var(--md-sys-state-pressed-state-layer-opacity, 10%);
102
+ }
103
+ &.micl-rippling {
104
+ animation: micl-ripple calc(var(--md-sys-state-ripple-duration) * 1.333);
105
+ }
106
+ }
107
+ .micl-button__icon {
108
+ font-variation-settings: 'FILL' 0;
109
+ transition: font-variation-settings var(--md-comp-button-motion-duration) linear;
110
+ }
111
+ &.micl-button--toggle:not([aria-pressed="true"]) .micl-button__icon::before {
112
+ content: attr(data-miclicon);
113
+ }
114
+ &.micl-button--toggle[aria-pressed="true"] .micl-button__icon::before {
115
+ content: attr(data-micliconselected);
116
+ }
117
+ }
118
+
119
+ // Buttons smaller than the minimum touch target extend their interactive area with a
120
+ // transparent ::before overlay.
121
+ %micl-button-target {
122
+ &::before {
123
+ content: "";
124
+ position: absolute;
125
+ block-size: var(--md-sys-target-size, 48px);
126
+ inline-size: 100%;
127
+ min-inline-size: var(--md-sys-target-size, 48px);
128
+ inset: calc((var(--micl-height) - var(--md-sys-target-size, 48px)) / 2) 0 0 calc((min(100%, var(--md-sys-target-size, 48px)) - var(--md-sys-target-size, 48px)) / 2);
129
+ background-color: transparent;
130
+ }
131
+ }
132
+
133
+ %micl-button-xs {
134
+ @include typography.label-large;
135
+ @extend %micl-button-target;
136
+
137
+ --micl-width: 32px;
138
+ --micl-height: 32px;
139
+
140
+ min-inline-size: var(--micl-width);
141
+ block-size: var(--micl-height);
142
+ min-block-size: var(--micl-height);
143
+ column-gap: 4px;
144
+ padding-inline: 12px;
145
+
146
+ .micl-button__icon {
147
+ font-size: 20px;
148
+ inline-size: 20px;
149
+ }
150
+ }
151
+
152
+ %micl-button-elevated {
153
+ --statelayer-color: var(--md-sys-color-primary);
154
+
155
+ background-color: var(--md-comp-elevated-button-container-color, var(--md-sys-color-surface-container-low));
156
+ color: var(--md-comp-elevated-button-label-text-color, var(--md-sys-color-primary));
157
+ box-shadow: var(--md-comp-elevated-button-container-elevation, var(--md-sys-elevation-level1));
158
+
159
+ &#{$disabled} {
160
+ background-color: var(--md-comp-elevated-button-disabled-container-color, rgb(from var(--md-sys-color-on-surface) r g b / var(--md-comp-elevated-button-disabled-container-opacity, 10%)));
161
+ color: var(--md-comp-elevated-button-disabled-label-text-color, rgb(from var(--md-sys-color-on-surface-variant) r g b / var(--md-comp-elevated-button-disabled-label-text-opacity, 38%)));
162
+ box-shadow: var(--md-sys-elevation-level0);
163
+ }
164
+ &#{$enabled} {
165
+ &:hover:not(:active) {
166
+ box-shadow: var(--md-sys-elevation-level2);
167
+ }
168
+ &.micl-button--toggle[aria-pressed="true"] {
169
+ --statelayer-color: var(--md-sys-color-on-primary);
170
+
171
+ background-color: var(--md-comp-elevated-button-selected-container-color, var(--md-sys-color-primary));
172
+ color: var(--md-comp-elevated-button-selected-label-text-color, var(--md-sys-color-on-primary));
173
+
174
+ .micl-button__icon {
175
+ font-variation-settings: 'FILL' 1;
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+ %micl-button-outlined {
182
+ --statelayer-color: var(--md-sys-color-on-surface-variant);
183
+
184
+ background-color: transparent;
185
+ color: var(--md-comp-outlined-button-label-text-color, var(--md-sys-color-on-surface-variant));
186
+ border: 1px solid var(--md-comp-outlined-button-outline-color, var(--md-sys-color-outline-variant));
187
+
188
+ &#{$disabled} {
189
+ background-color: transparent;
190
+ color: var(--md-comp-outlined-button-disabled-label-text-color, rgb(from var(--md-sys-color-on-surface-variant) r g b / var(--md-comp-outlined-button-disabled-label-text-opacity, 38%)));
191
+
192
+ &.micl-button--toggle[aria-pressed="true"] {
193
+ border: none;
194
+ background-color: var(--md-comp-outlined-button-selected-disabled-container-color, rgb(from var(--md-sys-color-on-surface) r g b / var(--md-comp-outlined-button-selected-disabled-container-opacity, 10%)));
195
+ }
196
+ }
197
+ &#{$enabled} {
198
+ &.micl-button--toggle[aria-pressed="true"] {
199
+ --statelayer-color: var(--md-sys-color-inverse-on-surface);
200
+
201
+ border: none;
202
+ background-color: var(--md-comp-outlined-button-selected-container-color, var(--md-sys-color-inverse-surface));
203
+ color: var(--md-comp-outlined-button-selected-label-text-color, var(--md-sys-color-inverse-on-surface));
204
+
205
+ .micl-button__icon {
206
+ font-variation-settings: 'FILL' 1;
207
+ }
208
+ }
209
+ }
210
+ }