material-inspired-component-library 1.3.0 → 2.0.1
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.
- package/CODE_OF_CONDUCT.md +128 -0
- package/README.md +9 -1
- package/components/badge/README.md +65 -0
- package/components/badge/index.scss +61 -0
- package/components/bottomsheet/README.md +29 -17
- package/components/bottomsheet/index.scss +23 -23
- package/components/bottomsheet/index.ts +25 -24
- package/components/button/README.md +1 -1
- package/components/button/index.scss +10 -12
- package/components/button/index.ts +5 -0
- package/components/card/index.scss +2 -2
- package/components/checkbox/index.scss +1 -1
- package/components/dialog/README.md +9 -9
- package/components/iconbutton/index.scss +2 -2
- package/components/iconbutton/index.ts +5 -0
- package/components/list/index.scss +2 -2
- package/components/navigationrail/README.md +110 -59
- package/components/navigationrail/index.scss +399 -88
- package/components/{checkbox → navigationrail}/index.ts +12 -7
- package/components/radio/index.scss +2 -2
- package/components/sidesheet/README.md +32 -17
- package/components/sidesheet/index.scss +43 -47
- package/components/slider/README.md +5 -5
- package/dist/badge.css +1 -0
- package/dist/badge.js +1 -0
- package/dist/bottomsheet.css +1 -1
- package/dist/button.css +1 -1
- package/dist/card.css +1 -1
- package/dist/checkbox.css +1 -1
- package/dist/components/navigationrail/index.d.ts +5 -0
- package/dist/iconbutton.css +1 -1
- package/dist/list.css +1 -1
- package/dist/micl.css +1 -1
- package/dist/micl.js +1 -1
- package/dist/navigationrail.css +1 -1
- package/dist/radio.css +1 -1
- package/dist/sidesheet.css +1 -1
- package/docs/bottomsheet.html +58 -7
- package/docs/button.html +30 -30
- package/docs/docs.css +2 -1
- package/docs/index.html +35 -4
- package/docs/micl.css +1 -1
- package/docs/micl.js +1 -1
- package/docs/navigationrail.html +48 -42
- package/docs/sidesheet.html +22 -7
- package/micl.ts +20 -27
- package/package.json +4 -1
- package/styles.scss +17 -0
- package/dist/components/checkbox/index.d.ts +0 -5
|
@@ -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
|
@@ -79,6 +79,7 @@ This will initialize all MICL components, including those that will be added to
|
|
|
79
79
|
## Available components ✅
|
|
80
80
|
The library currently consists of the following components:
|
|
81
81
|
- [x] [Accordion](components/accordion/README.md)
|
|
82
|
+
- [x] [Badge](components/badge/README.md)
|
|
82
83
|
- [x] [Bottom sheet](components/bottomsheet/README.md)
|
|
83
84
|
- [x] [Button](components/button/README.md)
|
|
84
85
|
- [x] [Card](components/card/README.md)
|
|
@@ -88,7 +89,7 @@ The library currently consists of the following components:
|
|
|
88
89
|
- [x] [Icon button](components/iconbutton/README.md)
|
|
89
90
|
- [x] [List](components/list/README.md)
|
|
90
91
|
- [x] [Menu](components/menu/README.md)
|
|
91
|
-
- [
|
|
92
|
+
- [x] [Navigation rail](components/navigationrail/README.md)
|
|
92
93
|
- [x] [Radio button](components/radio/README.md)
|
|
93
94
|
- [x] [Select](components/select/README.md)
|
|
94
95
|
- [x] [Side sheet](components/sidesheet/README.md)
|
|
@@ -98,6 +99,13 @@ The library currently consists of the following components:
|
|
|
98
99
|
|
|
99
100
|
## Change Log
|
|
100
101
|
|
|
102
|
+
### 2.0.0 (04.09.2025)
|
|
103
|
+
**Features**
|
|
104
|
+
|
|
105
|
+
- **Navigation rail**: New component.
|
|
106
|
+
- **Badge**: New component.
|
|
107
|
+
- **Ripple**: Now uses custom CSS properties.
|
|
108
|
+
|
|
101
109
|
### 1.3.0 (23.08.2025)
|
|
102
110
|
**Features**
|
|
103
111
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Badge
|
|
2
|
+
This component implements the the [Material Design 3 Expressive Badge](https://m3.material.io/components/badges/overview) design. Badges are small status indicators that can show a count or simply signal new information.
|
|
3
|
+
|
|
4
|
+
## Basic Usage
|
|
5
|
+
|
|
6
|
+
### HTML
|
|
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
|
+
|
|
9
|
+
```HTML
|
|
10
|
+
<span class="micl-badge">57</span>
|
|
11
|
+
|
|
12
|
+
<span class="micl-badge micl-badge--small"></span>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### CSS
|
|
16
|
+
Import the badge styles into your project:
|
|
17
|
+
|
|
18
|
+
```CSS
|
|
19
|
+
@use "material-inspired-component-library/dist/badge";
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### JavaScript
|
|
23
|
+
No custom JavaScript is required for the core functionality of this component.
|
|
24
|
+
|
|
25
|
+
### Demo
|
|
26
|
+
A live example of the [Badge component](https://henkpb.github.io/micl/index.html) is available for you to interact with.
|
|
27
|
+
|
|
28
|
+
## Anchoring
|
|
29
|
+
Badges are typically placed on top of other elements, like icons. To anchor a badge to a specific element, use CSS `anchor positioning`.
|
|
30
|
+
|
|
31
|
+
1. Assign a unique `anchor-name` to the element you want to anchor the badge to. The value should start with `--`.
|
|
32
|
+
2. Use the `position-anchor` CSS property on the badge and set its value to the `anchor-name` of the target element.
|
|
33
|
+
|
|
34
|
+
```HTML
|
|
35
|
+
<span class="material-symbols-outlined" style="anchor-name:--inbox">inbox</span>
|
|
36
|
+
<span class="micl-badge" style="position-anchor:--inbox">57</span>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
You can fine-tune the badge's position relative to its anchor using the following CSS variables:
|
|
40
|
+
|
|
41
|
+
| Variable name | Default Value | Description |
|
|
42
|
+
| ------------- | ------------- | ----------- |
|
|
43
|
+
| --md-sys-badge-inline-offset | 0px | Adjusts the horizontal position of the badge |
|
|
44
|
+
| --md-sys-badge-block-offset | 0px | Adjusts the vertical position of the badge |
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Customizations
|
|
48
|
+
You can customize the appearance of the Badge component by overriding its global CSS variables. These variables are declared on the `:root` pseudo-class and can be changed on any appropriate parent element to affect its child badges.
|
|
49
|
+
|
|
50
|
+
| Variable name | Default Value | Description |
|
|
51
|
+
| ------------- | ------------- | ----------- |
|
|
52
|
+
| --md-sys-badge-small-size | 6px | The height and width of the small badge |
|
|
53
|
+
| --md-sys-badge-large-size | 16px | The height and minimum width of the large badge |
|
|
54
|
+
| --md-sys-badge-large-padding | 4px | The horizontal padding used for the large badge |
|
|
55
|
+
|
|
56
|
+
**Example: Changing the size of the small badge**
|
|
57
|
+
|
|
58
|
+
```HTML
|
|
59
|
+
<div style="--md-sys-badge-small-size:8px">
|
|
60
|
+
<span class="micl-badge micl-badge--small"></span>
|
|
61
|
+
</div>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Compatibility
|
|
65
|
+
This component uses **anchor positioning**, a modern CSS feature that may not be fully supported in all browsers. Please check [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/anchor#browser_compatibility) for details.
|
|
@@ -0,0 +1,61 @@
|
|
|
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/typography';
|
|
23
|
+
|
|
24
|
+
:root {
|
|
25
|
+
--md-sys-badge-small-size: 6px;
|
|
26
|
+
--md-sys-badge-large-size: 16px;
|
|
27
|
+
--md-sys-badge-large-padding: 4px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.micl-badge {
|
|
31
|
+
--md-sys-badge-inline-offset: 0px;
|
|
32
|
+
--md-sys-badge-block-offset: 0px;
|
|
33
|
+
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
position: fixed;
|
|
36
|
+
inset: unset;
|
|
37
|
+
margin: 0;
|
|
38
|
+
background-color: var(--md-sys-color-error);
|
|
39
|
+
color: var(--md-sys-color-on-error);
|
|
40
|
+
|
|
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
|
+
|
|
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
|
+
}
|
|
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.
|
|
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"
|
|
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 **
|
|
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.
|
|
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="
|
|
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
|
-
|
|
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"
|
|
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
|
|
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-
|
|
81
|
+
<dialog data-miclsnapheights="0,200,420" ...>
|
|
66
82
|
```
|
|
67
83
|
|
|
68
|
-
|
|
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.
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
dialog.micl-bottomsheet {
|
|
28
28
|
--md-sys-bottomsheet-height: max-content;
|
|
29
29
|
--md-sys-bottomsheet-margin: 56px;
|
|
30
|
+
--md-sys-bottomsheet-margin-top: 72px;
|
|
30
31
|
--md-sys-bottomsheet-padding: 24px;
|
|
31
32
|
--md-sys-bottomsheet-handle-width: 32px;
|
|
32
33
|
--md-sys-bottomsheet-handle-height: 4px;
|
|
@@ -36,13 +37,12 @@ dialog.micl-bottomsheet {
|
|
|
36
37
|
|
|
37
38
|
box-sizing: border-box;
|
|
38
39
|
position: fixed;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
margin: 72px 0 0 0 ;
|
|
40
|
+
inset-block: auto 0;
|
|
41
|
+
block-size: 0;
|
|
42
|
+
max-block-size: 50vh;
|
|
43
|
+
inline-size: 100%;
|
|
44
|
+
min-inline-size: 100%;
|
|
45
|
+
margin: var(--md-sys-bottomsheet-margin-top) 0 0 0 ;
|
|
46
46
|
padding: 0;
|
|
47
47
|
border: none;
|
|
48
48
|
border-radius: var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large) 0 0;
|
|
@@ -55,26 +55,23 @@ dialog.micl-bottomsheet {
|
|
|
55
55
|
&:not(.micl-bottomsheet--resizing) {
|
|
56
56
|
transition:
|
|
57
57
|
opacity var(--md-sys-bottomsheet-motion-duration-reverse) motion.$md-sys-motion-easing-emphasized-accelerate,
|
|
58
|
-
|
|
58
|
+
block-size var(--md-sys-bottomsheet-motion-duration-reverse) var(--md-sys-bottomsheet-motion-spatial),
|
|
59
59
|
overlay var(--md-sys-bottomsheet-motion-duration-reverse) linear allow-discrete,
|
|
60
60
|
display var(--md-sys-bottomsheet-motion-duration-reverse) linear allow-discrete;
|
|
61
61
|
}
|
|
62
|
-
&.micl-bottomsheet--resizing .micl-bottomsheet__headline {
|
|
63
|
-
cursor: grabbing;
|
|
64
|
-
}
|
|
65
62
|
.micl-bottomsheet__headline {
|
|
66
63
|
box-sizing: border-box;
|
|
67
64
|
display: flex;
|
|
68
65
|
align-items: center;
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
inline-size: 100%;
|
|
67
|
+
block-size: var(--md-sys-target-size);
|
|
71
68
|
justify-content: center;
|
|
72
69
|
cursor: grab;
|
|
73
70
|
|
|
74
71
|
.micl-bottomsheet__draghandle {
|
|
75
72
|
box-sizing: content-box;
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
inline-size: var(--md-sys-bottomsheet-handle-width);
|
|
74
|
+
block-size: var(--md-sys-bottomsheet-handle-height);
|
|
78
75
|
padding: 16px calc((var(--md-sys-target-size) - var(--md-sys-bottomsheet-handle-width)) / 2);
|
|
79
76
|
border: none;
|
|
80
77
|
border-radius: var(--md-sys-shape-corner-small);
|
|
@@ -88,6 +85,9 @@ dialog.micl-bottomsheet {
|
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
}
|
|
88
|
+
&.micl-bottomsheet--resizing .micl-bottomsheet__headline {
|
|
89
|
+
cursor: grabbing;
|
|
90
|
+
}
|
|
91
91
|
|
|
92
92
|
.micl-bottomsheet__content {
|
|
93
93
|
padding: 0 var(--md-sys-bottomsheet-padding) var(--md-sys-bottomsheet-padding) var(--md-sys-bottomsheet-padding);
|
|
@@ -102,19 +102,19 @@ dialog.micl-bottomsheet {
|
|
|
102
102
|
}
|
|
103
103
|
&:popover-open,
|
|
104
104
|
&[open] {
|
|
105
|
-
|
|
106
|
-
opacity:
|
|
105
|
+
block-size: var(--md-sys-bottomsheet-height);
|
|
106
|
+
opacity: 100%;
|
|
107
107
|
// overflow-y: auto;
|
|
108
108
|
|
|
109
109
|
&:not(.micl-bottomsheet--resizing) {
|
|
110
110
|
transition:
|
|
111
111
|
opacity var(--md-sys-bottomsheet-motion-duration) motion.$md-sys-motion-easing-emphasized-decelerate,
|
|
112
|
-
|
|
112
|
+
block-size var(--md-sys-bottomsheet-motion-duration) var(--md-sys-bottomsheet-motion-spatial),
|
|
113
113
|
overlay var(--md-sys-bottomsheet-motion-duration) linear allow-discrete,
|
|
114
114
|
display var(--md-sys-bottomsheet-motion-duration) linear allow-discrete;
|
|
115
115
|
}
|
|
116
116
|
@starting-style {
|
|
117
|
-
|
|
117
|
+
block-size: 0;
|
|
118
118
|
opacity: 0;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -129,11 +129,11 @@ dialog.micl-bottomsheet {
|
|
|
129
129
|
|
|
130
130
|
@media (min-width: 641px) {
|
|
131
131
|
dialog.micl-bottomsheet {
|
|
132
|
-
|
|
133
|
-
max-
|
|
134
|
-
min-
|
|
132
|
+
inline-size: min(100vw - (2 * var(--md-sys-bottomsheet-margin)), 640px);
|
|
133
|
+
max-inline-size: 640px;
|
|
134
|
+
min-inline-size: min(100vw - (2 * var(--md-sys-bottomsheet-margin)), 640px);
|
|
135
135
|
inset-inline-start: calc(((100vw - min(100vw - (2 * var(--md-sys-bottomsheet-margin)), 640px)) / 2) - var(--md-sys-bottomsheet-margin));
|
|
136
136
|
margin: var(--md-sys-bottomsheet-margin);
|
|
137
|
-
margin-
|
|
137
|
+
margin-block-end: 0;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -23,19 +23,19 @@ export const bottomsheetSelector = 'dialog.micl-bottomsheet';
|
|
|
23
23
|
|
|
24
24
|
export default (() =>
|
|
25
25
|
{
|
|
26
|
-
var fitHeight = 0;
|
|
27
|
-
|
|
28
26
|
const getSnapHeights = (dialog: HTMLDialogElement): number[] =>
|
|
29
27
|
{
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
let fitHeight = parseInt(dialog.dataset.miclfitheight || '0', 10),
|
|
29
|
+
maxHeight = parseInt(window.getComputedStyle(dialog).getPropertyValue('max-block-size'), 10),
|
|
30
|
+
snapHeights = (dialog.dataset.miclsnapheights || '').split(',').map(Number).filter(
|
|
31
|
+
n => !isNaN(n) && (n >= 0) && (n <= maxHeight)
|
|
33
32
|
);
|
|
34
33
|
|
|
35
|
-
if (
|
|
36
|
-
fitHeight = dialog.getBoundingClientRect().height;
|
|
34
|
+
if (fitHeight < 1) {
|
|
35
|
+
fitHeight = Math.min(dialog.getBoundingClientRect().height, maxHeight);
|
|
36
|
+
dialog.dataset.miclfitheight = `${fitHeight}`;
|
|
37
37
|
}
|
|
38
|
-
return [...new Set(snapHeights.concat([fitHeight
|
|
38
|
+
return [...new Set(snapHeights.concat([fitHeight]).sort())];
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
const getNextSnapHeight = (dialog: HTMLDialogElement, isResizing: boolean): number =>
|
|
@@ -58,14 +58,21 @@ export default (() =>
|
|
|
58
58
|
|
|
59
59
|
const setHeight = (dialog: HTMLDialogElement, value: number): void =>
|
|
60
60
|
{
|
|
61
|
-
|
|
61
|
+
if (value < 1) {
|
|
62
|
+
delete dialog.dataset.miclfitheight;
|
|
63
|
+
dialog.style.removeProperty('--md-sys-bottomsheet-height');
|
|
64
|
+
dialog[!dialog.popover ? 'close' : 'hidePopover']();
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
dialog.style.setProperty('--md-sys-bottomsheet-height', `${value}px`);
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
return {
|
|
65
72
|
initialize: (element: HTMLDialogElement) =>
|
|
66
73
|
{
|
|
67
74
|
if (
|
|
68
|
-
!element.matches(
|
|
75
|
+
!element.matches(bottomsheetSelector)
|
|
69
76
|
|| element.dataset.miclinitialized
|
|
70
77
|
) {
|
|
71
78
|
return;
|
|
@@ -80,10 +87,7 @@ export default (() =>
|
|
|
80
87
|
|
|
81
88
|
draghandle?.addEventListener('click', () =>
|
|
82
89
|
{
|
|
83
|
-
|
|
84
|
-
if (nextSnapHeight > 4) {
|
|
85
|
-
setHeight(element, nextSnapHeight);
|
|
86
|
-
}
|
|
90
|
+
setHeight(element, getNextSnapHeight(element, false));
|
|
87
91
|
});
|
|
88
92
|
|
|
89
93
|
let isPreparing = false,
|
|
@@ -126,16 +130,11 @@ export default (() =>
|
|
|
126
130
|
if (currentMouseY < initialMouseY) {
|
|
127
131
|
setHeight(element, getNextSnapHeight(element, true));
|
|
128
132
|
}
|
|
133
|
+
else if (element.getBoundingClientRect().height < 48) {
|
|
134
|
+
setHeight(element, 0);
|
|
135
|
+
}
|
|
129
136
|
else {
|
|
130
|
-
|
|
131
|
-
if (!!element.popover) {
|
|
132
|
-
element.hidePopover();
|
|
133
|
-
}
|
|
134
|
-
setHeight(element, initialHeight);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
setHeight(element, getPreviousSnapHeight(element));
|
|
138
|
-
}
|
|
137
|
+
setHeight(element, getPreviousSnapHeight(element));
|
|
139
138
|
}
|
|
140
139
|
document.removeEventListener('mousemove', onMouseMove);
|
|
141
140
|
document.removeEventListener('mouseup', onMouseUp);
|
|
@@ -144,8 +143,10 @@ export default (() =>
|
|
|
144
143
|
},
|
|
145
144
|
cleanup: (element: HTMLDialogElement) =>
|
|
146
145
|
{
|
|
147
|
-
if (element.matches(
|
|
146
|
+
if (element.matches(bottomsheetSelector)) {
|
|
147
|
+
element.classList.remove('micl-bottomsheet--resizing');
|
|
148
148
|
delete element.dataset.miclinitialized;
|
|
149
|
+
delete element.dataset.miclfitheight;
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
};
|
|
@@ -66,7 +66,7 @@ To add a leading icon to a button, include an element with the `micl-button__ico
|
|
|
66
66
|
|
|
67
67
|
```HTML
|
|
68
68
|
<button type="button" class="micl-button-filled-m">
|
|
69
|
-
<span class="micl-button__icon material-symbols-outlined">save</span>
|
|
69
|
+
<span class="micl-button__icon material-symbols-outlined" aria-hidden="true">save</span>
|
|
70
70
|
Save
|
|
71
71
|
</button>
|
|
72
72
|
```
|