material-inspired-component-library 1.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 (174) hide show
  1. package/.editorconfig +12 -0
  2. package/.gitattributes +9 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. package/LICENSE +21 -0
  6. package/README.md +99 -0
  7. package/components/README.md +12 -0
  8. package/components/accordion/README.md +94 -0
  9. package/components/bottomsheet/README.md +77 -0
  10. package/components/bottomsheet/bottomsheet.scss +134 -0
  11. package/components/bottomsheet/index.ts +152 -0
  12. package/components/button/README.md +92 -0
  13. package/components/button/button.scss +515 -0
  14. package/components/button/index.ts +73 -0
  15. package/components/card/README.md +125 -0
  16. package/components/card/card.scss +261 -0
  17. package/components/checkbox/README.md +62 -0
  18. package/components/checkbox/checkbox.scss +275 -0
  19. package/components/checkbox/index.ts +48 -0
  20. package/components/dialog/README.md +133 -0
  21. package/components/dialog/dialog.scss +262 -0
  22. package/components/divider/README.md +52 -0
  23. package/components/divider/divider.scss +74 -0
  24. package/components/iconbutton/README.md +86 -0
  25. package/components/iconbutton/iconbutton.scss +461 -0
  26. package/components/iconbutton/index.ts +73 -0
  27. package/components/list/README.md +176 -0
  28. package/components/list/index.ts +108 -0
  29. package/components/list/list.scss +295 -0
  30. package/components/menu/README.md +96 -0
  31. package/components/menu/index.ts +77 -0
  32. package/components/menu/menu.scss +124 -0
  33. package/components/radio/README.md +53 -0
  34. package/components/radio/radio.scss +138 -0
  35. package/components/select/README.md +84 -0
  36. package/components/select/select.scss +122 -0
  37. package/components/sidesheet/README.md +99 -0
  38. package/components/sidesheet/sidesheet.scss +162 -0
  39. package/components/slider/README.md +69 -0
  40. package/components/slider/index.ts +114 -0
  41. package/components/slider/slider.scss +258 -0
  42. package/components/switch/README.md +49 -0
  43. package/components/switch/switch.scss +176 -0
  44. package/components/textfield/README.md +75 -0
  45. package/components/textfield/index.ts +81 -0
  46. package/components/textfield/textfield.scss +387 -0
  47. package/components.ts +169 -0
  48. package/dist/bottomsheet.css +1 -0
  49. package/dist/bottomsheet.js +0 -0
  50. package/dist/button.css +1 -0
  51. package/dist/button.js +0 -0
  52. package/dist/card.css +1 -0
  53. package/dist/card.js +0 -0
  54. package/dist/checkbox.css +1 -0
  55. package/dist/checkbox.js +0 -0
  56. package/dist/dialog.css +1 -0
  57. package/dist/dialog.js +0 -0
  58. package/dist/divider.css +1 -0
  59. package/dist/divider.js +0 -0
  60. package/dist/iconbutton.css +1 -0
  61. package/dist/iconbutton.js +0 -0
  62. package/dist/list.css +1 -0
  63. package/dist/list.js +0 -0
  64. package/dist/menu.css +1 -0
  65. package/dist/menu.js +0 -0
  66. package/dist/micl.css +1 -0
  67. package/dist/micl.js +1 -0
  68. package/dist/radio.css +1 -0
  69. package/dist/radio.js +0 -0
  70. package/dist/select.css +1 -0
  71. package/dist/select.js +0 -0
  72. package/dist/sidesheet.css +1 -0
  73. package/dist/sidesheet.js +0 -0
  74. package/dist/slider.css +1 -0
  75. package/dist/slider.js +0 -0
  76. package/dist/switch.css +1 -0
  77. package/dist/switch.js +0 -0
  78. package/dist/textfield.css +1 -0
  79. package/dist/textfield.js +0 -0
  80. package/docs/accordion.html +285 -0
  81. package/docs/bottomsheet.html +162 -0
  82. package/docs/button.html +206 -0
  83. package/docs/card-awards.webp +0 -0
  84. package/docs/card-cabinet.webp +0 -0
  85. package/docs/card-city.webp +0 -0
  86. package/docs/card-fingerprint.webp +0 -0
  87. package/docs/card-holiday.webp +0 -0
  88. package/docs/card-names.webp +0 -0
  89. package/docs/card.html +91 -0
  90. package/docs/checkbox.html +99 -0
  91. package/docs/dialog.html +153 -0
  92. package/docs/divider.html +103 -0
  93. package/docs/docs.css +34 -0
  94. package/docs/docs.js +69 -0
  95. package/docs/iconbutton.html +197 -0
  96. package/docs/index.html +319 -0
  97. package/docs/list.html +224 -0
  98. package/docs/menu.html +143 -0
  99. package/docs/micl.css +1 -0
  100. package/docs/micl.js +1 -0
  101. package/docs/radio.html +101 -0
  102. package/docs/select.html +205 -0
  103. package/docs/sidesheet.html +115 -0
  104. package/docs/slider.html +72 -0
  105. package/docs/switch.html +151 -0
  106. package/docs/textfield.html +151 -0
  107. package/docs/themes/airblue/dark-hc.css +51 -0
  108. package/docs/themes/airblue/dark-mc.css +51 -0
  109. package/docs/themes/airblue/dark.css +51 -0
  110. package/docs/themes/airblue/light-hc.css +51 -0
  111. package/docs/themes/airblue/light-mc.css +51 -0
  112. package/docs/themes/airblue/light.css +51 -0
  113. package/docs/themes/airblue/theme.css +306 -0
  114. package/docs/themes/barnred/dark-hc.css +51 -0
  115. package/docs/themes/barnred/dark-mc.css +51 -0
  116. package/docs/themes/barnred/dark.css +51 -0
  117. package/docs/themes/barnred/light-hc.css +51 -0
  118. package/docs/themes/barnred/light-mc.css +51 -0
  119. package/docs/themes/barnred/light.css +51 -0
  120. package/docs/themes/barnred/theme.css +306 -0
  121. package/docs/themes/citrine/dark-hc.css +51 -0
  122. package/docs/themes/citrine/dark-mc.css +51 -0
  123. package/docs/themes/citrine/dark.css +51 -0
  124. package/docs/themes/citrine/light-hc.css +51 -0
  125. package/docs/themes/citrine/light-mc.css +51 -0
  126. package/docs/themes/citrine/light.css +51 -0
  127. package/docs/themes/citrine/theme.css +306 -0
  128. package/docs/themes/olivegreen/dark-hc.css +51 -0
  129. package/docs/themes/olivegreen/dark-mc.css +51 -0
  130. package/docs/themes/olivegreen/dark.css +51 -0
  131. package/docs/themes/olivegreen/light-hc.css +51 -0
  132. package/docs/themes/olivegreen/light-mc.css +51 -0
  133. package/docs/themes/olivegreen/light.css +51 -0
  134. package/docs/themes/olivegreen/theme.css +306 -0
  135. package/package.json +62 -0
  136. package/styles/README.md +99 -0
  137. package/styles/elevation.scss +36 -0
  138. package/styles/motion.scss +124 -0
  139. package/styles/ripple.scss +50 -0
  140. package/styles/shapes.scss +46 -0
  141. package/styles/statelayer.scss +42 -0
  142. package/styles/typography.scss +568 -0
  143. package/styles.scss +43 -0
  144. package/themes/README.md +57 -0
  145. package/themes/airblue/dark-hc.css +51 -0
  146. package/themes/airblue/dark-mc.css +51 -0
  147. package/themes/airblue/dark.css +51 -0
  148. package/themes/airblue/light-hc.css +51 -0
  149. package/themes/airblue/light-mc.css +51 -0
  150. package/themes/airblue/light.css +51 -0
  151. package/themes/airblue/theme.css +306 -0
  152. package/themes/barnred/dark-hc.css +51 -0
  153. package/themes/barnred/dark-mc.css +51 -0
  154. package/themes/barnred/dark.css +51 -0
  155. package/themes/barnred/light-hc.css +51 -0
  156. package/themes/barnred/light-mc.css +51 -0
  157. package/themes/barnred/light.css +51 -0
  158. package/themes/barnred/theme.css +306 -0
  159. package/themes/citrine/dark-hc.css +51 -0
  160. package/themes/citrine/dark-mc.css +51 -0
  161. package/themes/citrine/dark.css +51 -0
  162. package/themes/citrine/light-hc.css +51 -0
  163. package/themes/citrine/light-mc.css +51 -0
  164. package/themes/citrine/light.css +51 -0
  165. package/themes/citrine/theme.css +306 -0
  166. package/themes/olivegreen/dark-hc.css +51 -0
  167. package/themes/olivegreen/dark-mc.css +51 -0
  168. package/themes/olivegreen/dark.css +51 -0
  169. package/themes/olivegreen/light-hc.css +51 -0
  170. package/themes/olivegreen/light-mc.css +51 -0
  171. package/themes/olivegreen/light.css +51 -0
  172. package/themes/olivegreen/theme.css +306 -0
  173. package/tsconfig.json +110 -0
  174. package/webpack.config.js +49 -0
@@ -0,0 +1,92 @@
1
+ # Button
2
+ This component implements the the [Material Design 3 Expressive Button](https://m3.material.io/components/buttons/overview) design. Buttons are interactive elements that enable users to trigger actions or navigate.
3
+
4
+ ## Basic Usage
5
+
6
+ ### HTML
7
+ To create a basic button, use the `<button>` element with a class that specifies its style and size. This example uses a small text-style button:
8
+
9
+ ```HTML
10
+ <button type="button" class="micl-button-text-s">Save</button>
11
+ ```
12
+
13
+ ### CSS
14
+ Import the button styles into your project:
15
+
16
+ ```CSS
17
+ @use "micl/components/button";
18
+ ```
19
+
20
+ ### TypeScript
21
+ This component requires a TypeScript module for interactive features like the **ripple effect** and **toggle logic**. You can import the specific button module or use the main MICL TypeScript library, which handles initialization automatically.
22
+
23
+ To manually initialize the component:
24
+
25
+ ```TypeScript
26
+ import miclButton from 'micl/components/button';
27
+
28
+ miclButton.initialize(document.querySelector('.micl-button-text-s'));
29
+ ```
30
+
31
+ ### Demo
32
+ A live example of the [Button component](https://henkpb.github.io/micl/button.html) is available for you to interact with.
33
+
34
+ ## Variants
35
+ Buttons come in **five sizes**: extra small (`xs`), small (`s`), medium (`m`), large (`l`), and extra large (`xl`). To specify a size, append the appropriate postfix to the button's style class:
36
+
37
+ **Example: An extra-large text button**
38
+
39
+ ```HTML
40
+ <button type="button" class="micl-button-text-xl>Save</button>
41
+ ```
42
+
43
+ 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:
44
+
45
+ **Example: A medium-sized elevated button**
46
+
47
+ ```HTML
48
+ <button type="button" class="micl-button-elevated-m">Save</button>
49
+ ```
50
+
51
+ By default, buttons have a **rounded shape**. For a more square-like appearance, add the `micl-button--square` class.
52
+
53
+ Adding the `disabled` boolean attribute to the button causes the button to be displayed in a disabled state.
54
+
55
+ ### Toggle Button
56
+ A toggle button has two states: **on** (selected) and **off** (unselected). To create one, add the `micl-button--toggle` class.
57
+ - **Off state**: The button has the `micl-button--toggle` class.
58
+ - **On state**: The button has both the `micl-button--toggle` and `micl-button--selected` classes.
59
+
60
+ **Example: A selected toggle button**
61
+
62
+ ```HTML
63
+ <button type="button" class="micl-button-tonal-s micl-button--toggle micl-button--selected">Selected</button>
64
+ ```
65
+
66
+ ## Icons
67
+ To add a leading icon to a button, include an element with the `micl-button__icon` class inside the `<button>`:
68
+
69
+ ```HTML
70
+ <button type="button" class="micl-button-filled-m">
71
+ <span class="micl-button__icon material-symbols-outlined">save</span>
72
+ Save
73
+ </button>
74
+ ```
75
+
76
+ This example uses a [Google Material Symbol](https://fonts.google.com/icons). For buttons using these icons, a fill-style of `1` is applied when the button is selected or hovered over. To enable this effect, ensure your `link` tag includes `FILL@0..1`.
77
+
78
+ ```HTML
79
+ <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:FILL@0..1" rel="stylesheet">
80
+ ```
81
+
82
+ You can also use other icon libraries. For example, with the [Bootstrap Icons library](https://icons.getbootstrap.com):
83
+
84
+ ```HTML
85
+ <button type="button" class="micl-button-outlined-l">
86
+ <i class="bi bi-gear"></i>
87
+ Settings
88
+ </button>
89
+ ```
90
+
91
+ ## Compatibility
92
+ This component uses the `color-mix` CSS functional notation, which might not be supported in your browser. Please check [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix#browser_compatibility) for details.
@@ -0,0 +1,515 @@
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
+ @use '../../styles/motion';
23
+ @use '../../styles/ripple';
24
+ @use '../../styles/typography';
25
+
26
+ button.micl-button-text-xs,
27
+ button.micl-button-text-s,
28
+ button.micl-button-text-m,
29
+ button.micl-button-text-l,
30
+ button.micl-button-text-xl,
31
+ button.micl-button-elevated-xs,
32
+ button.micl-button-elevated-s,
33
+ button.micl-button-elevated-m,
34
+ button.micl-button-elevated-l,
35
+ button.micl-button-elevated-xl,
36
+ button.micl-button-filled-xs,
37
+ button.micl-button-filled-s,
38
+ button.micl-button-filled-m,
39
+ button.micl-button-filled-l,
40
+ button.micl-button-filled-xl,
41
+ button.micl-button-tonal-xs,
42
+ button.micl-button-tonal-s,
43
+ button.micl-button-tonal-m,
44
+ button.micl-button-tonal-l,
45
+ button.micl-button-tonal-xl,
46
+ button.micl-button-outlined-xs,
47
+ button.micl-button-outlined-s,
48
+ button.micl-button-outlined-m,
49
+ button.micl-button-outlined-l,
50
+ button.micl-button-outlined-xl {
51
+ padding: 0;
52
+ border: none;
53
+ cursor: pointer;
54
+ transition: border-radius var(--md-sys-motion-duration-extra-long4) linear(motion.$md-sys-motion-spring-fast-spatial);
55
+
56
+ &:disabled {
57
+ background-color: rgb(from var(--md-sys-color-on-surface) r g b / 10%);
58
+ color: rgb(from var(--md-sys-color-on-surface) r g b / 38%);
59
+ box-shadow: var(--md-sys-elevation-level0);
60
+ cursor: default;
61
+ }
62
+ &:not(:disabled):focus-visible {
63
+ outline: var(--md-sys-state-focus-indicator-thickness) solid var(--md-sys-color-secondary);
64
+ outline-offset: 3px;
65
+ }
66
+ .micl-button__icon {
67
+ font-variation-settings: 'FILL' 0;
68
+ transition: font-variation-settings 600ms;
69
+ }
70
+ }
71
+
72
+ button.micl-button-text-xs,
73
+ button.micl-button-elevated-xs,
74
+ button.micl-button-filled-xs,
75
+ button.micl-button-tonal-xs,
76
+ button.micl-button-outlined-xs {
77
+ @include typography.label-large;
78
+
79
+ min-width: var(--md-sys-target-size);
80
+ height: var(--md-sys-target-size);
81
+ padding-inline: 12px;
82
+ border: 8px solid transparent;
83
+ border-radius: calc(var(--md-sys-target-size) / 2);
84
+ background-clip: padding-box;
85
+
86
+ &.micl-button--toggle.micl-button--selected {
87
+ border-radius: var(--md-sys-shape-corner-medium);
88
+ }
89
+ &.micl-button--square {
90
+ &.micl-button-elevated-xs {
91
+ border-radius: var(--md-sys-shape-corner-medium);
92
+ }
93
+ &:not(.micl-button-elevated-xs) {
94
+ border-radius: calc(var(--md-sys-shape-corner-medium) + 8px);
95
+ }
96
+ &.micl-button--toggle.micl-button--selected {
97
+ border-radius: calc(var(--md-sys-target-size) / 2);
98
+ }
99
+ }
100
+ &:not(:disabled) {
101
+ --miclripple: 1;
102
+ @include ripple.effect;
103
+
104
+ &:active {
105
+ &.micl-button-elevated-xs {
106
+ border-radius: var(--md-sys-shape-corner-small);
107
+ }
108
+ &:not(.micl-button-elevated-xs) {
109
+ border-radius: calc(var(--md-sys-shape-corner-small) + 8px);
110
+ }
111
+ }
112
+ &:not(.micl-button-elevated-xs):focus-visible {
113
+ outline-offset: -6px;
114
+ }
115
+ }
116
+ .micl-button__icon {
117
+ font-size: 20px;
118
+ width: 20px;
119
+ margin-right: 8px;
120
+ vertical-align: text-bottom;
121
+ }
122
+ }
123
+
124
+ button.micl-button-text-s,
125
+ button.micl-button-elevated-s,
126
+ button.micl-button-filled-s,
127
+ button.micl-button-tonal-s,
128
+ button.micl-button-outlined-s {
129
+ @include typography.label-large;
130
+
131
+ min-width: var(--md-sys-target-size);
132
+ height: var(--md-sys-target-size);
133
+ padding-inline: 16px;
134
+ border: 4px solid transparent;
135
+ border-radius: calc(var(--md-sys-target-size) / 2);
136
+ background-clip: padding-box;
137
+
138
+ &.micl-button--toggle.micl-button--selected {
139
+ border-radius: var(--md-sys-shape-corner-medium);
140
+ }
141
+ &.micl-button--square {
142
+ &.micl-button-elevated-s {
143
+ border-radius: var(--md-sys-shape-corner-medium);
144
+ }
145
+ &:not(.micl-button-elevated-s) {
146
+ border-radius: calc(var(--md-sys-shape-corner-medium) + 4px);
147
+ }
148
+ &.micl-button--toggle.micl-button--selected {
149
+ border-radius: calc(var(--md-sys-target-size) / 2);
150
+ }
151
+ }
152
+ &:not(:disabled) {
153
+ --miclripple: 1;
154
+ @include ripple.effect;
155
+
156
+ &:active:not(:disabled) {
157
+ &.micl-button-elevated-s {
158
+ border-radius: var(--md-sys-shape-corner-small);
159
+ }
160
+ &:not(.micl-button-elevated-s) {
161
+ border-radius: calc(var(--md-sys-shape-corner-small) + 4px);
162
+ }
163
+ }
164
+ &:not(.micl-button-elevated-s):focus-visible {
165
+ outline-offset: -2px;
166
+ }
167
+ }
168
+ .micl-button__icon {
169
+ font-size: 20px;
170
+ width: 20px;
171
+ margin-right: 8px;
172
+ vertical-align: text-bottom;
173
+ }
174
+ }
175
+
176
+ button.micl-button-text-m,
177
+ button.micl-button-elevated-m,
178
+ button.micl-button-filled-m,
179
+ button.micl-button-tonal-m,
180
+ button.micl-button-outlined-m {
181
+ @include typography.title-medium;
182
+
183
+ min-width: 56px;
184
+ height: 56px;
185
+ padding-inline: 24px;
186
+ border-radius: 28px;
187
+
188
+ &.micl-button--toggle.micl-button--selected {
189
+ border-radius: var(--md-sys-shape-corner-large);
190
+ }
191
+ &.micl-button--square {
192
+ border-radius: var(--md-sys-shape-corner-large);
193
+
194
+ &.micl-button--toggle.micl-button--selected {
195
+ border-radius: 28px;
196
+ }
197
+ }
198
+ &:not(:disabled) {
199
+ --miclripple: 1;
200
+ @include ripple.effect;
201
+
202
+ &:active:not(:disabled) {
203
+ border-radius: var(--md-sys-shape-corner-medium);
204
+ }
205
+ }
206
+ .micl-button__icon {
207
+ font-size: 24px;
208
+ width: 24px;
209
+ margin-right: 8px;
210
+ vertical-align: text-bottom;
211
+ }
212
+ }
213
+
214
+ button.micl-button-text-l,
215
+ button.micl-button-elevated-l,
216
+ button.micl-button-filled-l,
217
+ button.micl-button-tonal-l,
218
+ button.micl-button-outlined-l {
219
+ @include typography.headline-small;
220
+
221
+ min-width: 96px;
222
+ height: 96px;
223
+ padding-inline: 48px;
224
+ border-radius: 48px;
225
+
226
+ &.micl-button--toggle.micl-button--selected {
227
+ border-radius: var(--md-sys-shape-corner-extra-large);
228
+ }
229
+ &.micl-button--square {
230
+ border-radius: var(--md-sys-shape-corner-extra-large);
231
+
232
+ &.micl-button--toggle.micl-button--selected {
233
+ border-radius: 48px;
234
+ }
235
+ }
236
+ &:not(:disabled) {
237
+ --miclripple: 1;
238
+ @include ripple.effect;
239
+
240
+ &:active:not(:disabled) {
241
+ border-radius: var(--md-sys-shape-corner-large);
242
+ }
243
+ }
244
+ .micl-button__icon {
245
+ font-size: 32px;
246
+ width: 32px;
247
+ margin-right: 12px;
248
+ vertical-align: text-bottom;
249
+ }
250
+ }
251
+
252
+ button.micl-button-text-xl,
253
+ button.micl-button-elevated-xl,
254
+ button.micl-button-filled-xl,
255
+ button.micl-button-tonal-xl,
256
+ button.micl-button-outlined-xl {
257
+ @include typography.headline-large;
258
+
259
+ min-width: 136px;
260
+ height: 136px;
261
+ padding-inline: 64px;
262
+ border-radius: 68px;
263
+
264
+ &.micl-button--toggle.micl-button--selected {
265
+ border-radius: var(--md-sys-shape-corner-extra-large);
266
+ }
267
+ &.micl-button--square {
268
+ border-radius: var(--md-sys-shape-corner-extra-large);
269
+
270
+ &.micl-button--toggle.micl-button--selected {
271
+ border-radius: 68px;;
272
+ }
273
+ }
274
+ &:not(:disabled) {
275
+ --miclripple: 1;
276
+ @include ripple.effect;
277
+
278
+ &:active:not(:disabled) {
279
+ border-radius: var(--md-sys-shape-corner-large);
280
+ }
281
+ }
282
+ .micl-button__icon {
283
+ font-size: 40px;
284
+ width: 40px;
285
+ margin-right: 16px;
286
+ vertical-align: text-bottom;
287
+ }
288
+ }
289
+
290
+ button.micl-button-text-xs,
291
+ button.micl-button-text-s,
292
+ button.micl-button-text-m,
293
+ button.micl-button-text-l,
294
+ button.micl-button-text-xl {
295
+ background-color: transparent;
296
+ color: var(--md-sys-color-primary);
297
+
298
+ &:not(:disabled) {
299
+ &:hover {
300
+ background-color: rgb(from var(--md-sys-color-primary) r g b / var(--md-sys-state-hover-state-layer-opacity));
301
+
302
+ .micl-button__icon {
303
+ font-variation-settings: 'FILL' 1;
304
+ }
305
+ }
306
+ &:focus-visible {
307
+ background-color: rgb(from var(--md-sys-color-primary) r g b / var(--md-sys-state-focus-state-layer-opacity));
308
+ }
309
+ &:active {
310
+ background-color: rgb(from var(--md-sys-color-primary) r g b / var(--md-sys-state-pressed-state-layer-opacity));
311
+ }
312
+ }
313
+ }
314
+
315
+ button.micl-button-elevated-xs,
316
+ button.micl-button-elevated-s,
317
+ button.micl-button-elevated-m,
318
+ button.micl-button-elevated-l,
319
+ button.micl-button-elevated-xl {
320
+ background-color: var(--md-sys-color-surface-container-low);
321
+ color: var(--md-sys-color-primary);
322
+ box-shadow: var(--md-sys-elevation-level1);
323
+
324
+ &:not(:disabled) {
325
+ &.micl-button--toggle.micl-button--selected {
326
+ background-color: var(--md-sys-color-primary);
327
+ color: var(--md-sys-color-on-primary);
328
+
329
+ .micl-button__icon {
330
+ font-variation-settings: 'FILL' 1;
331
+ }
332
+ }
333
+ &:hover {
334
+ background-color: color-mix(in srgb, var(--md-sys-color-surface-container-low), var(--md-sys-color-primary), var(--md-sys-state-hover-state-layer-opacity));
335
+
336
+ &.micl-button--toggle.micl-button--selected {
337
+ background-color: color-mix(in srgb, var(--md-sys-color-primary), var(--md-sys-color-on-primary) var(--md-sys-state-hover-state-layer-opacity));
338
+ }
339
+ .micl-button__icon {
340
+ font-variation-settings: 'FILL' 1;
341
+ }
342
+ }
343
+ &:focus-visible {
344
+ background-color: color-mix(in srgb, var(--md-sys-color-surface-container-low), var(--md-sys-color-primary), var(--md-sys-state-focus-state-layer-opacity));
345
+
346
+ &.micl-button--toggle.micl-button--selected {
347
+ background-color: color-mix(in srgb, var(--md-sys-color-primary), var(--md-sys-color-on-primary) var(--md-sys-state-focus-state-layer-opacity));
348
+ }
349
+ }
350
+ &:active {
351
+ background-color: color-mix(in srgb, var(--md-sys-color-surface-container-low), var(--md-sys-color-primary), var(--md-sys-state-pressed-state-layer-opacity));
352
+
353
+ &.micl-button--toggle.micl-button--selected {
354
+ background-color: color-mix(in srgb, var(--md-sys-color-primary), var(--md-sys-color-on-primary) var(--md-sys-state-pressed-state-layer-opacity));
355
+ }
356
+ }
357
+ }
358
+ }
359
+ button.micl-button-elevated-xs {
360
+ height: 32px;
361
+ border: none;
362
+ }
363
+ button.micl-button-elevated-s {
364
+ height: 40px;
365
+ border: none;
366
+ }
367
+
368
+ button.micl-button-filled-xs,
369
+ button.micl-button-filled-s,
370
+ button.micl-button-filled-m,
371
+ button.micl-button-filled-l,
372
+ button.micl-button-filled-xl {
373
+ background-color: var(--md-sys-color-primary);
374
+ color: var(--md-sys-color-on-primary);
375
+
376
+ &:not(:disabled) {
377
+ &.micl-button--toggle.micl-button--selected {
378
+ .micl-button__icon {
379
+ font-variation-settings: 'FILL' 1;
380
+ }
381
+ }
382
+ &.micl-button--toggle:not(.micl-button--selected) {
383
+ background-color: var(--md-sys-color-surface-container);
384
+ color: var(--md-sys-color-on-surface-variant);
385
+ }
386
+ &:hover {
387
+ background-color: color-mix(in srgb, var(--md-sys-color-primary), var(--md-sys-color-on-primary) var(--md-sys-state-hover-state-layer-opacity));
388
+
389
+ &.micl-button--toggle:not(.micl-button--selected) {
390
+ background-color: color-mix(in srgb, var(--md-sys-color-surface-container), var(--md-sys-color-on-surface-variant) var(--md-sys-state-hover-state-layer-opacity));
391
+ }
392
+ .micl-button__icon {
393
+ font-variation-settings: 'FILL' 1;
394
+ }
395
+ }
396
+ &:focus-visible {
397
+ background-color: color-mix(in srgb, var(--md-sys-color-primary), var(--md-sys-color-on-primary) var(--md-sys-state-focus-state-layer-opacity));
398
+
399
+ &.micl-button--toggle:not(.micl-button--selected) {
400
+ background-color: color-mix(in srgb, var(--md-sys-color-surface-container), var(--md-sys-color-on-surface-variant) var(--md-sys-state-focus-state-layer-opacity));
401
+ }
402
+ }
403
+ &:active {
404
+ background-color: color-mix(in srgb, var(--md-sys-color-primary), var(--md-sys-color-on-primary) var(--md-sys-state-pressed-state-layer-opacity));
405
+
406
+ &.micl-button--toggle:not(.micl-button--selected) {
407
+ background-color: color-mix(in srgb, var(--md-sys-color-surface-container), var(--md-sys-color-on-surface-variant) var(--md-sys-state-pressed-state-layer-opacity));
408
+ }
409
+ }
410
+ }
411
+ }
412
+
413
+ button.micl-button-tonal-xs,
414
+ button.micl-button-tonal-s,
415
+ button.micl-button-tonal-m,
416
+ button.micl-button-tonal-l,
417
+ button.micl-button-tonal-xl {
418
+ background-color: var(--md-sys-color-secondary-container);
419
+ color: var(--md-sys-color-on-secondary-container);
420
+
421
+ &:not(:disabled) {
422
+ &.micl-button--toggle.micl-button--selected {
423
+ background-color: var(--md-sys-color-secondary);
424
+ color: var(--md-sys-color-on-secondary);
425
+
426
+ .micl-button__icon {
427
+ font-variation-settings: 'FILL' 1;
428
+ }
429
+ }
430
+ &:hover {
431
+ background-color: color-mix(in srgb, var(--md-sys-color-secondary-container), var(--md-sys-color-on-secondary-container) var(--md-sys-state-hover-state-layer-opacity));
432
+
433
+ &.micl-button--toggle.micl-button--selected {
434
+ background-color: color-mix(in srgb, var(--md-sys-color-secondary), var(--md-sys-color-on-secondary) var(--md-sys-state-hover-state-layer-opacity));
435
+ }
436
+ .micl-button__icon {
437
+ font-variation-settings: 'FILL' 1;
438
+ }
439
+ }
440
+ &:focus-visible {
441
+ background-color: color-mix(in srgb, var(--md-sys-color-secondary-container), var(--md-sys-color-on-secondary-container) var(--md-sys-state-focus-state-layer-opacity));
442
+
443
+ &.micl-button--toggle.micl-button--selected {
444
+ background-color: color-mix(in srgb, var(--md-sys-color-secondary), var(--md-sys-color-on-secondary) var(--md-sys-state-focus-state-layer-opacity));
445
+ }
446
+ }
447
+ &:active {
448
+ background-color: color-mix(in srgb, var(--md-sys-color-secondary-container), var(--md-sys-color-on-secondary-container) var(--md-sys-state-pressed-state-layer-opacity));
449
+
450
+ &.micl-button--toggle.micl-button--selected {
451
+ background-color: color-mix(in srgb, var(--md-sys-color-secondary), var(--md-sys-color-on-secondary) var(--md-sys-state-pressed-state-layer-opacity));
452
+ }
453
+ }
454
+ }
455
+ }
456
+
457
+ button.micl-button-outlined-xs,
458
+ button.micl-button-outlined-s,
459
+ button.micl-button-outlined-m,
460
+ button.micl-button-outlined-l,
461
+ button.micl-button-outlined-xl {
462
+ background-color: transparent;
463
+ color: var(--md-sys-color-on-surface-variant);
464
+
465
+ &:not(:disabled) {
466
+ &.micl-button--toggle.micl-button--selected {
467
+ background-color: var(--md-sys-color-inverse-surface);
468
+ color: var(--md-sys-color-inverse-on-surface);
469
+
470
+ .micl-button__icon {
471
+ font-variation-settings: 'FILL' 1;
472
+ }
473
+ }
474
+ &:hover {
475
+ background-color: rgb(from var(--md-sys-color-on-surface-variant) r g b / var(--md-sys-state-hover-state-layer-opacity));
476
+
477
+ &.micl-button--toggle.micl-button--selected {
478
+ background-color: color-mix(in srgb, var(--md-sys-color-inverse-surface), var(--md-sys-color-inverse-on-surface) var(--md-sys-state-hover-state-layer-opacity));
479
+ }
480
+ .micl-button__icon {
481
+ font-variation-settings: 'FILL' 1;
482
+ }
483
+ }
484
+ &:focus-visible {
485
+ background-color: rgb(from var(--md-sys-color-on-surface-variant) r g b / var(--md-sys-state-focus-state-layer-opacity));
486
+
487
+ &.micl-button--toggle.micl-button--selected {
488
+ background-color: color-mix(in srgb, var(--md-sys-color-inverse-surface), var(--md-sys-color-inverse-on-surface) var(--md-sys-state-focus-state-layer-opacity));
489
+ }
490
+ }
491
+ &:active {
492
+ background-color: rgb(from var(--md-sys-color-on-surface-variant) r g b / var(--md-sys-state-pressed-state-layer-opacity));
493
+
494
+ &.micl-button--toggle.micl-button--selected {
495
+ background-color: color-mix(in srgb, var(--md-sys-color-inverse-surface), var(--md-sys-color-inverse-on-surface) var(--md-sys-state-pressed-state-layer-opacity));
496
+ }
497
+ }
498
+ }
499
+ }
500
+ button.micl-button-outlined-xs,
501
+ button.micl-button-outlined-s {
502
+ box-shadow: inset 1px 0px var(--md-sys-color-outline-variant),
503
+ inset -1px 0px var(--md-sys-color-outline-variant),
504
+ inset 0px -1px var(--md-sys-color-outline-variant),
505
+ inset 0px 1px var(--md-sys-color-outline-variant);
506
+ }
507
+ button.micl-button-outlined-m {
508
+ border: 1px solid var(--md-sys-color-outline-variant);
509
+ }
510
+ button.micl-button-outlined-l {
511
+ border: 2px solid var(--md-sys-color-outline-variant);
512
+ }
513
+ button.micl-button-outlined-xl {
514
+ border: 3px solid var(--md-sys-color-outline-variant);
515
+ }
@@ -0,0 +1,73 @@
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
+ export const buttonSelector = 'button[popovertarget],button.micl-button--toggle';
23
+
24
+ export default (() =>
25
+ {
26
+ const onClick = (event: Event) =>
27
+ {
28
+ if (!event.target || !(event.target instanceof HTMLButtonElement)) {
29
+ return;
30
+ }
31
+ if (event.target.popoverTargetElement instanceof HTMLDialogElement) {
32
+ if (event.target.popoverTargetElement.open) {
33
+ event.target.popoverTargetElement.close();
34
+ }
35
+ else {
36
+ event.target.popoverTargetElement.showModal();
37
+ }
38
+ }
39
+ if (event.target.classList.contains('micl-button--toggle')) {
40
+ event.target.classList.toggle('micl-button--selected');
41
+ }
42
+ };
43
+
44
+ return {
45
+ initialize: (element: HTMLButtonElement) =>
46
+ {
47
+ if (
48
+ !element.matches('button[popovertarget],button.micl-button--toggle')
49
+ || element.dataset.miclinitialized
50
+ ) {
51
+ return;
52
+ }
53
+ element.dataset.miclinitialized = '1';
54
+
55
+ if (
56
+ (element.popoverTargetElement instanceof HTMLDialogElement)
57
+ && !element.popoverTargetElement.hasAttribute('popover')
58
+ ) {
59
+ element.addEventListener('click', onClick);
60
+ }
61
+ else if (element.classList.contains('micl-button--toggle')) {
62
+ element.addEventListener('click', onClick);
63
+ }
64
+ },
65
+ cleanup: (element: HTMLButtonElement) =>
66
+ {
67
+ if (element.matches('button[popovertarget],button.micl-button--toggle')) {
68
+ document.removeEventListener('click', onClick);
69
+ delete element.dataset.miclinitialized;
70
+ }
71
+ }
72
+ };
73
+ })();