material-inspired-component-library 2.0.0 → 3.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 (71) hide show
  1. package/CODE_OF_CONDUCT.md +128 -0
  2. package/README.md +14 -0
  3. package/components/README.md +2 -0
  4. package/components/appbar/README.md +94 -0
  5. package/components/appbar/index.scss +216 -0
  6. package/components/badge/README.md +5 -5
  7. package/components/badge/index.scss +20 -27
  8. package/components/bottomsheet/README.md +29 -17
  9. package/components/bottomsheet/index.scss +23 -23
  10. package/components/bottomsheet/index.ts +25 -24
  11. package/components/button/README.md +1 -1
  12. package/components/button/index.scss +70 -65
  13. package/components/button/index.ts +1 -1
  14. package/components/card/index.scss +1 -1
  15. package/components/checkbox/index.scss +4 -0
  16. package/components/dialog/README.md +9 -9
  17. package/components/iconbutton/index.scss +111 -111
  18. package/components/iconbutton/index.ts +1 -1
  19. package/components/navigationrail/README.md +16 -16
  20. package/components/navigationrail/index.scss +20 -12
  21. package/components/radio/index.scss +1 -1
  22. package/components/sidesheet/README.md +32 -17
  23. package/components/sidesheet/index.scss +43 -47
  24. package/components/slider/README.md +5 -5
  25. package/dist/appbar.css +1 -0
  26. package/dist/appbar.js +1 -0
  27. package/dist/badge.css +1 -1
  28. package/dist/bottomsheet.css +1 -1
  29. package/dist/button.css +1 -1
  30. package/dist/card.css +1 -1
  31. package/dist/checkbox.css +1 -1
  32. package/dist/dialog.css +1 -1
  33. package/dist/iconbutton.css +1 -1
  34. package/dist/list.css +1 -1
  35. package/dist/micl.css +1 -1
  36. package/dist/micl.js +1 -1
  37. package/dist/navigationrail.css +1 -1
  38. package/dist/radio.css +1 -1
  39. package/dist/select.css +1 -1
  40. package/dist/sidesheet.css +1 -1
  41. package/dist/slider.css +1 -1
  42. package/dist/switch.css +1 -1
  43. package/dist/textfield.css +1 -1
  44. package/docs/accordion.html +298 -254
  45. package/docs/bottomsheet.html +194 -114
  46. package/docs/button.html +210 -182
  47. package/docs/card.html +107 -72
  48. package/docs/checkbox.html +92 -65
  49. package/docs/dialog.html +154 -123
  50. package/docs/divider.html +96 -67
  51. package/docs/docs.css +14 -24
  52. package/docs/docs.js +4 -2
  53. package/docs/iconbutton.html +196 -171
  54. package/docs/index.html +298 -288
  55. package/docs/list.html +260 -216
  56. package/docs/menu.html +260 -220
  57. package/docs/micl.css +1 -1
  58. package/docs/micl.js +1 -1
  59. package/docs/navigationrail.html +38 -36
  60. package/docs/radio.html +93 -68
  61. package/docs/select.html +213 -173
  62. package/docs/sidesheet.html +105 -73
  63. package/docs/slider.html +105 -72
  64. package/docs/switch.html +126 -101
  65. package/docs/textfield.html +181 -138
  66. package/layout/README.md +122 -0
  67. package/layout/index.scss +258 -0
  68. package/package.json +1 -1
  69. package/styles/statelayer.scss +2 -0
  70. package/styles.scss +13 -0
  71. package/styles/layout.scss +0 -74
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ micl.hermana@proton.me.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
package/README.md CHANGED
@@ -76,9 +76,15 @@ Copy the main `micl.js` file to your distribution folder and include it in your
76
76
  ```
77
77
  This will initialize all MICL components, including those that will be added to the DOM later on.
78
78
 
79
+ ## Foundations
80
+ A separate CSS file, based on the [Material Design Layout Foundation](https://m3.material.io/foundations/layout/understanding-layout/overview), provides styles for an adaptive layout. It includes styles for the **window frame**, **body region** and **panes** that adjust to the available screen space, ensuring your layout follows Material Design's responsive guidelines.
81
+
82
+ - [x] [Layout](layout/README.md)
83
+
79
84
  ## Available components ✅
80
85
  The library currently consists of the following components:
81
86
  - [x] [Accordion](components/accordion/README.md)
87
+ - [x] [App Bar](components/appbar/README.md)
82
88
  - [x] [Badge](components/badge/README.md)
83
89
  - [x] [Bottom sheet](components/bottomsheet/README.md)
84
90
  - [x] [Button](components/button/README.md)
@@ -99,6 +105,14 @@ The library currently consists of the following components:
99
105
 
100
106
  ## Change Log
101
107
 
108
+ ### 3.0.0 (24.09.2025)
109
+ **Features**
110
+
111
+ - **App Bar**: New component.
112
+ - **Layout**: Support for adaptive layout.
113
+ - Improved handling of target area for small buttons.
114
+ - **BREAKING:** Use `<nav>` instead of `<div>` for Navigation rail.
115
+
102
116
  ### 2.0.0 (04.09.2025)
103
117
  **Features**
104
118
 
@@ -10,3 +10,5 @@ Each component is self-contained in a separate folder, making it easy to find wh
10
10
  - A README.md file for detailed documentation.
11
11
 
12
12
  Most components are standalone, but some are built on top of others. For example, the [Menu component](./menu/README.md) extends the [List component](./list/README.md), so it requires the styles and functionality of both. Always check the documentation for each component to see which dependencies you need to import. This ensures everything works as expected.
13
+
14
+ A [separate CSS file](../layout/README.md), based on the [Material Design Layout Foundation](https://m3.material.io/foundations/layout/understanding-layout/overview), provides styles for an adaptive layout. It includes styles for the **window frame**, **body region** and **panes** that adjust to the available screen space, ensuring your layout follows Material Design's responsive guidelines.
@@ -0,0 +1,94 @@
1
+ # App Bar
2
+ This component implements the the [Material Design 3 Expressive App Bar](https://m3.material.io/components/app-bars/overview) design. The app bar serves as the top container for a page, displaying the page title, primary actions, and navigation options.
3
+
4
+ ## Basic Usage
5
+
6
+ ### HTML
7
+ To add a basic (small) app bar, use the `<header>` element with the `micl-appbar` class. The `<h1>` and `<p>` elements within the `.micl-appbar__headline` `<div>` define the main headline and an optional subtitle.
8
+
9
+ ```HTML
10
+ <header class="micl-appbar">
11
+ <div class="micl-appbar__headline">
12
+ <h1>Headline</h1>
13
+ <p class="micl-appbar__subtitle">Subtitle</p>
14
+ </div>
15
+ </header>
16
+ ```
17
+
18
+ ### CSS
19
+ Import the app bar styles into your project:
20
+
21
+ ```CSS
22
+ @use "material-inspired-component-library/dist/appbar";
23
+ ```
24
+
25
+ ### JavaScript
26
+ No custom JavaScript is required for the core functionality of this component.
27
+
28
+ ### Demo
29
+ A live example of the [App Bar component](https://henkpb.github.io/micl/index.html) is available for you to interact with.
30
+
31
+ ## Variants
32
+ The app bar component supports three sizes: **small**, **medium** (flexible), and **large** (flexible). Use a modifier class to specify a size other than the default small size.
33
+
34
+ - **Small** (default): `<header class="micl-appbar">`
35
+ - **Medium**: `<header class="micl-appbar micl-appbar--medium">`
36
+ - **Large**: `<header class="micl-appbar micl-appbar--large">`
37
+
38
+ To center the headline and subtitle, add the `micl-appbar__headline--center` class to the headline container.
39
+
40
+ **Example: A medium-sized app bar with centered text**
41
+
42
+ ```HTML
43
+ <header class="micl-appbar micl-appbar--medium">
44
+ <div class="micl-appbar__headline micl-appbar__headline--center">
45
+ <h1>Headline</h1>
46
+ <p class="micl-appbar__subtitle">Subtitle</p>
47
+ </div>
48
+ </header>
49
+ ```
50
+
51
+ ### Leading content
52
+ Use the `micl-appbar__leading` (or: `micl-appbar__leading-icon`) class for an element (or: icon) placed before the headline.
53
+
54
+ **Example: An app bar with a home link**
55
+
56
+ ```HTML
57
+ <header class="micl-appbar">
58
+ <a href="index.html" class="micl-appbar__leading-icon micl-link micl-iconbutton-standard-m" aria-label="Home">
59
+ <span class="material-symbols-outlined" aria-hidden="true">home</span>
60
+ </a>
61
+ <div class="micl-appbar__headline">
62
+ <h1>Headline</h1>
63
+ </div>
64
+ </header>
65
+ ```
66
+
67
+ ### Trailing content
68
+ Use the `micl-appbar__trailing` (or: `micl-appbar__trailing-icon`) class for elements (or: icons) placed after the headline.
69
+
70
+ **Example: An app bar with a settings-button**
71
+
72
+ ```HTML
73
+ <header class="micl-appbar">
74
+ <div class="micl-appbar__headline">
75
+ <h1>Headline</h1>
76
+ </div>
77
+ <button type="button" class="micl-appbar__trailing micl-iconbutton-tonal-s micl-iconbutton--wide material-symbols-outlined">settings</button>
78
+ </header>
79
+ ```
80
+
81
+ ### Sticky app bar
82
+ The app bar is 'glued' to the top of the page when one of the following conditions is met:
83
+
84
+ - The [body region](../../layout/README.md) contains only one pane.
85
+ - The body region contains two or more panes and the page has a compact size.
86
+ - The body region contains two or more panes, has the `micl-body--stacked-to-expanded` class and the page has a compact or medium size.
87
+ - The body region contains two or more panes, has the `micl-body--stacked-to-large` class and the page has a compact, medium or expanded size.
88
+ - The body region contains two or more panes, has the `micl-body--stacked-to-extralarge` class and the page has a compact, medium, expanded or large size.
89
+ - The app bar has the `micl-appbar--sticky` class.
90
+
91
+ Adding the `micl-appbar--not-sticky` class to the app bar will prohibit gluing the app bar to the top of the page.
92
+
93
+ ## Compatibility
94
+ This component uses the `animation-timeline` CSS property for the scroll-effect, which may not be supported in your browser. Please check [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timeline#browser_compatibility) for details.
@@ -0,0 +1,216 @@
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 '../../layout';
23
+ @use '../../styles/elevation';
24
+ @use '../../styles/shapes';
25
+ @use '../../styles/statelayer';
26
+ @use '../../styles/typography';
27
+
28
+ @mixin appbar-sticky() {
29
+ position: sticky;
30
+ inset: unset;
31
+ inset-block-start: 0;
32
+ inset-inline-start: 0;
33
+ animation: 1ms linear alternate appbar-background;
34
+ animation-timeline: scroll(root);
35
+ }
36
+
37
+ .micl-appbar {
38
+ --md-sys-appbar-height: 64px;
39
+ --md-sys-appbar-padding-block-start: 0px;
40
+ --md-sys-appbar-padding-block-end: 0px;
41
+ --md-sys-appbar-padding-inline: 4px;
42
+
43
+ box-sizing: border-box;
44
+ display: grid;
45
+ grid-template-areas:
46
+ "appbar-leading appbar-middle appbar-trailing"
47
+ "appbar-bottom appbar-bottom appbar-bottom";
48
+ grid-template-columns: 0fr 1fr max-content;
49
+ column-gap: 4px;
50
+ align-items: center;
51
+ min-block-size: var(--md-sys-appbar-height);
52
+ padding-block: var(--md-sys-appbar-padding-block-start) var(--md-sys-appbar-padding-block-end);
53
+ padding-inline: var(--md-sys-appbar-padding-inline);
54
+ border-start-start-radius: inherit;
55
+ border-start-end-radius: inherit;
56
+ background-color: var(--md-sys-color-surface);
57
+ box-shadow: var(--md-sys-elevation-level0);
58
+ z-index: 8;
59
+
60
+ &.micl-appbar--sticky {
61
+ @include appbar-sticky;
62
+ }
63
+ .micl-appbar__leading {
64
+ grid-area: appbar-leading;
65
+ margin-inline-start: calc(var(--md-sys-layout-window-margin) - var(--md-sys-appbar-padding-inline));
66
+ }
67
+ .micl-appbar__leading-icon {
68
+ grid-area: appbar-leading;
69
+ margin-inline-start: calc(var(--md-sys-layout-window-margin) - (var(--micl-width, statelayer.$md-sys-target-size) / 2) + (24px / 2) - var(--md-sys-appbar-padding-inline));
70
+ color: var(--md-sys-color-on-surface);
71
+ }
72
+ .micl-appbar__headline {
73
+ display: flex;
74
+ grid-area: appbar-middle;
75
+ flex-direction: column;
76
+ align-items: flex-start;
77
+ margin: 8px 0;
78
+ border-radius: var(--md-sys-shape-corner-none);
79
+ color: var(--md-sys-color-on-surface);
80
+
81
+ &.micl-appbar__headline--center {
82
+ align-items: center;
83
+ text-align: center;
84
+ }
85
+ h1, h2, h3, h4, h5, h6, .micl-heading {
86
+ @include typography.title-large;
87
+
88
+ margin: 0;
89
+ }
90
+ .micl-appbar__subtitle {
91
+ margin: 0;
92
+ color: var(--md-sys-color-on-surface-variant);
93
+ }
94
+ }
95
+ &:has(.micl-appbar__subtitle) {
96
+ .micl-appbar__subtitle {
97
+ @include typography.label-medium;
98
+ }
99
+ }
100
+ .micl-appbar__trailing {
101
+ grid-area: appbar-trailing;
102
+ margin-inline-end: calc(var(--md-sys-layout-window-margin) - var(--md-sys-appbar-padding-inline));
103
+ }
104
+ .micl-appbar__trailing-icon {
105
+ grid-area: appbar-trailing;
106
+ margin-inline-end: calc(var(--md-sys-layout-window-margin) - (var(--micl-width, statelayer.$md-sys-target-size) / 2) + (24px / 2) - var(--md-sys-appbar-padding-inline));
107
+ color: var(--md-sys-color-on-surface-variant);
108
+ }
109
+ &.micl-appbar--medium {
110
+ --md-sys-appbar-height: 112px;
111
+ --md-sys-appbar-padding-block-start: 4px;
112
+ --md-sys-appbar-padding-block-end: 12px;
113
+
114
+ padding-inline-start: 0;
115
+
116
+ .micl-appbar__headline {
117
+ grid-area: appbar-bottom;
118
+ margin: 0;
119
+ padding-inline-start: var(--md-sys-layout-window-margin);
120
+
121
+ h1, h2, h3, h4, h5, h6, .micl-heading {
122
+ @include typography.headline-medium;
123
+ }
124
+ }
125
+ &:has(.micl-appbar__subtitle) {
126
+ --md-sys-appbar-height: 136px;
127
+
128
+ .micl-appbar__subtitle {
129
+ @include typography.title-small;
130
+ }
131
+ }
132
+ }
133
+ &.micl-appbar--large {
134
+ --md-sys-appbar-height: 120px;
135
+ --md-sys-appbar-padding-block-start: 4px;
136
+ --md-sys-appbar-padding-block-end: 12px;
137
+
138
+ padding-inline-start: 0;
139
+
140
+ .micl-appbar__headline {
141
+ grid-area: appbar-bottom;
142
+ margin: 0;
143
+ padding-inline-start: var(--md-sys-layout-window-margin);
144
+
145
+ h1, h2, h3, h4, h5, h6, .micl-heading {
146
+ @include typography.display-small;
147
+ }
148
+ }
149
+ &:has(.micl-appbar__subtitle) {
150
+ --md-sys-appbar-height: 152px;
151
+
152
+ .micl-appbar__subtitle {
153
+ @include typography.title-medium;
154
+ }
155
+ }
156
+ }
157
+ }
158
+
159
+ .micl-body:not(:has(> .micl-pane:nth-child(2))) {
160
+ .micl-appbar:not(.micl-appbar--not-sticky) {
161
+ @include appbar-sticky;
162
+ }
163
+ }
164
+ .micl-body:has(> .micl-pane:nth-child(2)) {
165
+ @media (max-width: layout.$md-sys-window-medium-min) {
166
+ .micl-appbar:not(.micl-appbar--not-sticky) {
167
+ @include appbar-sticky;
168
+ }
169
+ }
170
+ @media (min-width: layout.$md-sys-window-medium-min) and (max-width: layout.$md-sys-window-medium-max) {
171
+ &.micl-body--stacked-to-expanded,
172
+ &.micl-body--stacked-to-large,
173
+ &.micl-body--stacked-to-extralarge {
174
+ .micl-appbar:not(.micl-appbar--not-sticky) {
175
+ @include appbar-sticky;
176
+ }
177
+ }
178
+ }
179
+ @media (min-width: layout.$md-sys-window-expanded-min) and (max-width: layout.$md-sys-window-expanded-max) {
180
+ &.micl-body--stacked-to-large,
181
+ &.micl-body--stacked-to-extralarge {
182
+ .micl-appbar:not(.micl-appbar--not-sticky) {
183
+ @include appbar-sticky;
184
+ }
185
+ }
186
+ }
187
+ @media (min-width: layout.$md-sys-window-large-min) and (max-width: layout.$md-sys-window-large-max) {
188
+ &.micl-body--stacked-to-extralarge {
189
+ .micl-appbar:not(.micl-appbar--not-sticky) {
190
+ @include appbar-sticky;
191
+ }
192
+ }
193
+ }
194
+ }
195
+
196
+ @keyframes appbar-background {
197
+ 0% {
198
+ background-color: inherit;
199
+ border-start-start-radius: inherit;
200
+ border-start-end-radius: inherit;
201
+ }
202
+ 10% {
203
+ background-color: var(--md-sys-color-surface-container);
204
+ box-shadow: var(--md-sys-elevation-level2);
205
+ }
206
+ 50% {
207
+ border-start-start-radius: 0;
208
+ border-start-end-radius: 0;
209
+ }
210
+ 100% {
211
+ background-color: var(--md-sys-color-surface-container);
212
+ box-shadow: var(--md-sys-elevation-level2);
213
+ border-start-start-radius: 0;
214
+ border-start-end-radius: 0;
215
+ }
216
+ }
@@ -4,12 +4,12 @@ This component implements the the [Material Design 3 Expressive Badge](https://m
4
4
  ## Basic Usage
5
5
 
6
6
  ### HTML
7
- To add a large badge, use a `<span>` element with the `micl-badge-large` class and add a short text inside. For a small badge, which is a simple dot, use a `<span>` with the `micl-badge-small` class and leave the element empty.
7
+ To add a large badge, use a `<span>` element with the `micl-badge` class and add a short text inside. For a small badge, which is a simple dot, add the `micl-badge--small` class and leave the element empty.
8
8
 
9
9
  ```HTML
10
- <span class="micl-badge-large">57</span>
10
+ <span class="micl-badge">57</span>
11
11
 
12
- <span class="micl-badge-small"></span>
12
+ <span class="micl-badge micl-badge--small"></span>
13
13
  ```
14
14
 
15
15
  ### CSS
@@ -33,7 +33,7 @@ Badges are typically placed on top of other elements, like icons. To anchor a ba
33
33
 
34
34
  ```HTML
35
35
  <span class="material-symbols-outlined" style="anchor-name:--inbox">inbox</span>
36
- <span class="micl-badge-large" style="position-anchor:--inbox">57</span>
36
+ <span class="micl-badge" style="position-anchor:--inbox">57</span>
37
37
  ```
38
38
 
39
39
  You can fine-tune the badge's position relative to its anchor using the following CSS variables:
@@ -57,7 +57,7 @@ You can customize the appearance of the Badge component by overriding its global
57
57
 
58
58
  ```HTML
59
59
  <div style="--md-sys-badge-small-size:8px">
60
- <span class="micl-badge-small"></span>
60
+ <span class="micl-badge micl-badge--small"></span>
61
61
  </div>
62
62
  ```
63
63
 
@@ -27,42 +27,35 @@
27
27
  --md-sys-badge-large-padding: 4px;
28
28
  }
29
29
 
30
- .micl-badge-small {
30
+ .micl-badge {
31
31
  --md-sys-badge-inline-offset: 0px;
32
32
  --md-sys-badge-block-offset: 0px;
33
33
 
34
34
  box-sizing: border-box;
35
35
  position: fixed;
36
- inline-size: var(--md-sys-badge-small-size);
37
- block-size: var(--md-sys-badge-small-size);
38
36
  inset: unset;
39
- inset-block-start: calc(anchor(start) + var(--md-sys-badge-block-offset));
40
- inset-inline-start: calc(anchor(end) - var(--md-sys-badge-small-size) - var(--md-sys-badge-inline-offset));
41
- border-radius: calc(var(--md-sys-badge-small-size) / 2);
42
37
  margin: 0;
43
- padding: 0;
44
38
  background-color: var(--md-sys-color-error);
45
39
  color: var(--md-sys-color-on-error);
46
- }
47
40
 
48
- .micl-badge-large {
49
- --md-sys-badge-inline-offset: 0px;
50
- --md-sys-badge-block-offset: 0px;
41
+ &.micl-badge--small {
42
+ inline-size: var(--md-sys-badge-small-size);
43
+ block-size: var(--md-sys-badge-small-size);
44
+ inset-block-start: calc(anchor(start) + var(--md-sys-badge-block-offset));
45
+ inset-inline-start: calc(anchor(end) - var(--md-sys-badge-small-size) - var(--md-sys-badge-inline-offset));
46
+ padding: 0;
47
+ border-radius: calc(var(--md-sys-badge-small-size) / 2);
48
+ }
49
+ &:not(.micl-badge--small) {
50
+ @include typography.label-small;
51
51
 
52
- @include typography.label-small;
53
-
54
- box-sizing: border-box;
55
- position: fixed;
56
- inline-size: fit-content;
57
- max-inline-size: 34px;
58
- min-inline-size: var(--md-sys-badge-large-size);
59
- block-size: var(--md-sys-badge-large-size);
60
- inset: unset;
61
- inset-block-start: calc(anchor(start) - 2px + var(--md-sys-badge-block-offset));
62
- inset-inline-start: calc(anchor(end) - 12px - var(--md-sys-badge-inline-offset));
63
- margin: 0;
64
- padding-inline: var(--md-sys-badge-large-padding);
65
- border-radius: calc(var(--md-sys-badge-large-size) / 2);
66
- background-color: var(--md-sys-color-error);
67
- color: var(--md-sys-color-on-error);
52
+ inline-size: fit-content;
53
+ max-inline-size: 34px;
54
+ min-inline-size: var(--md-sys-badge-large-size);
55
+ block-size: var(--md-sys-badge-large-size);
56
+ inset-block-start: calc(anchor(start) - 2px + var(--md-sys-badge-block-offset));
57
+ inset-inline-start: calc(anchor(end) - 12px - var(--md-sys-badge-inline-offset));
58
+ padding-inline: var(--md-sys-badge-large-padding);
59
+ border-radius: calc(var(--md-sys-badge-large-size) / 2);
60
+ }
68
61
  }
@@ -1,13 +1,13 @@
1
1
  # Bottom sheet
2
- This component implements the the [Material Design 3 Expressive Bottom sheet](https://m3.material.io/components/bottom-sheets/overview) design.
2
+ This component implements the the [Material Design 3 Expressive Bottom sheet](https://m3.material.io/components/bottom-sheets/overview) design. Bottom sheets show secondary content anchored to the bottom of the screen.
3
3
 
4
4
  ## Basic Usage
5
5
 
6
6
  ### HTML
7
- To create a standard bottom sheet, use the `<dialog>` element with the `popover` attribute. The `closedby="any"` attribute allows the user to dismiss the bottom sheet by clicking anywhere outside of it.
7
+ To create a standard bottom sheet, use the `<dialog>` element with the `popover` attribute.
8
8
 
9
9
  ```HTML
10
- <dialog id="mybottomsheet" class="micl-bottomsheet" closedby="any" popover>
10
+ <dialog id="mybottomsheet" class="micl-bottomsheet" popover>
11
11
  <div class="micl-bottomsheet__content">
12
12
  ...your content...
13
13
  </div>
@@ -22,34 +22,50 @@ Import the bottom sheet styles into your project:
22
22
  ```
23
23
 
24
24
  ### JavaScript
25
- This component requires JavaScript to support **modal** and **resizable** bottom sheets:
25
+ This component requires JavaScript to support **resizable** bottom sheets. The library will automatically initialize new components as they're added to the DOM.
26
26
 
27
27
  ```JavaScript
28
28
  import micl from "material-inspired-component-library/dist/micl";
29
29
  ```
30
30
 
31
- This will initialize any Bottom sheet component, including those that will be added to the DOM later on.
32
-
33
31
  ### Demo
34
32
  A live example of the [Bottom sheet component](https://henkpb.github.io/micl/bottomsheet.html) is available for you to interact with.
35
33
 
36
34
  ## Variants
35
+ Setting the `popover` attribute to `manual` lets a bottom sheet co-exist and be interactive with the rest of the page.
36
+
37
+ ```HTML
38
+ <dialog id="mybottomsheet" class="micl-bottomsheet" popover="manual">
39
+ <div class="micl-bottomsheet__content">
40
+ ...your content...
41
+ </div>
42
+ </dialog>
43
+ ```
44
+
45
+ ### Modal Bottom Sheet
37
46
  A **modal** bottom sheet blocks access to the rest of the page and must be dismissed explicitly by the user. This is suitable for critical tasks or information that requires a user's full attention.
38
47
 
39
- To create a modal bottom sheet, use the `<dialog>` element without the `popover` attribute. Use `closedby="closerequest"` to prevent the bottom sheet from being dismissed by clicking outside of it. You'll also need a button or other control with popovertarget to close it.
48
+ To create a modal bottom sheet, use the `<dialog>` element without the `popover` attribute. Add the `closedby="any"` to allow the bottom sheet to be dismissed by a user clicking outside of it.
40
49
 
41
50
  ```HTML
42
- <dialog id="mybottomsheet" class="micl-bottomsheet" closedby="closerequest">
51
+ <dialog id="mybottomsheet" class="micl-bottomsheet" closedby="any">
43
52
  <div class="micl-bottomsheet__content">
44
53
  ...your content...
45
54
  </div>
46
55
  </dialog>
47
56
  ```
48
57
 
49
- Include the bottom sheet heading (and optionally a drag-handle) to create a **resizable** bottom sheet.
58
+ To open or close a bottom sheet, add the markup of a button that is linked to the bottom sheet using the `popovertarget` attribute:
59
+
60
+ ```HTML
61
+ <button type="button" popovertarget="mybottomsheet">Open Bottom Sheet</button>
62
+ ```
63
+
64
+ ### Resizable Bottom Sheet
65
+ To create a **resizable** bottom sheet, include a heading and an optional drag-handle.
50
66
 
51
67
  ```HTML
52
- <dialog id="mybottomsheet" class="micl-bottomsheet" closedby="any" popover>
68
+ <dialog id="mybottomsheet" class="micl-bottomsheet" popover>
53
69
  <div class="micl-bottomsheet__headline">
54
70
  <button type="button" class="micl-bottomsheet__draghandle" aria-label="Drag handle"></button>
55
71
  </div>
@@ -59,17 +75,13 @@ Include the bottom sheet heading (and optionally a drag-handle) to create a **re
59
75
  </dialog>
60
76
  ```
61
77
 
62
- The height of a bottom sheet is determined by its contents, initially capped at 50% of the screen height. You can set multiple preset heights for the bottom sheet by adding the `data-snapheights` attribute:
78
+ The initial height is determined by its content and capped at 50% of the screen's height. You can define specific preset heights by using the `data-miclsnapheights` attribute.
63
79
 
64
80
  ```HTML
65
- <dialog data-snapheights="200,420" ...>
81
+ <dialog data-miclsnapheights="0,200,420" ...>
66
82
  ```
67
83
 
68
- To open or close a bottom sheet, add the markup of a button that is linked to the bottom sheet using the `popovertarget` attribute:
69
-
70
- ```HTML
71
- <button type="button" popovertarget="mybottomsheet">Open Bottom Sheet</button>
72
- ```
84
+ The value `0` is equivalent to closing the bottom sheet. When a user clicks the drag-handle, the bottom sheet toggles between these preset heights and its initial height. The bottom sheet will also snap to these preset heights as a user drags the heading.
73
85
 
74
86
  ## Compatibility
75
87
  This component uses the Popover API, which might not be supported in your browser. Please check [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API#api.htmlelement.popover) for details.