@m3e/fab 1.0.0-rc.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/LICENSE +22 -0
- package/README.md +181 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +80 -0
- package/dist/css-custom-data.json +1247 -0
- package/dist/custom-elements.json +1363 -0
- package/dist/html-custom-data.json +78 -0
- package/dist/index.js +1393 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +310 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/FabElement.d.ts +355 -0
- package/dist/src/FabElement.d.ts.map +1 -0
- package/dist/src/FabSize.d.ts +3 -0
- package/dist/src/FabSize.d.ts.map +1 -0
- package/dist/src/FabVariant.d.ts +3 -0
- package/dist/src/FabVariant.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/styles/FabSizeStyle.d.ts +7 -0
- package/dist/src/styles/FabSizeStyle.d.ts.map +1 -0
- package/dist/src/styles/FabSizeToken.d.ts +25 -0
- package/dist/src/styles/FabSizeToken.d.ts.map +1 -0
- package/dist/src/styles/FabStyle.d.ts +7 -0
- package/dist/src/styles/FabStyle.d.ts.map +1 -0
- package/dist/src/styles/FabVariantStyle.d.ts +7 -0
- package/dist/src/styles/FabVariantStyle.d.ts.map +1 -0
- package/dist/src/styles/FabVariantToken.d.ts +52 -0
- package/dist/src/styles/FabVariantToken.d.ts.map +1 -0
- package/dist/src/styles/index.d.ts +4 -0
- package/dist/src/styles/index.d.ts.map +1 -0
- package/eslint.config.mjs +13 -0
- package/package.json +49 -0
- package/rollup.config.js +32 -0
- package/src/FabElement.ts +448 -0
- package/src/FabSize.ts +2 -0
- package/src/FabVariant.ts +9 -0
- package/src/index.ts +3 -0
- package/src/styles/FabSizeStyle.ts +45 -0
- package/src/styles/FabSizeToken.ts +102 -0
- package/src/styles/FabStyle.ts +155 -0
- package/src/styles/FabVariantStyle.ts +95 -0
- package/src/styles/FabVariantToken.ts +1068 -0
- package/src/styles/index.ts +3 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { css, CSSResultGroup, unsafeCSS } from "lit";
|
|
2
|
+
|
|
3
|
+
import { DesignToken } from "@m3e/core";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Baseline styles for `M3eFabElement`.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const FabStyle: CSSResultGroup = css`
|
|
10
|
+
:host {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
outline: none;
|
|
13
|
+
user-select: none;
|
|
14
|
+
}
|
|
15
|
+
.base {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
vertical-align: middle;
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
position: relative;
|
|
22
|
+
width: 100%;
|
|
23
|
+
transition: ${unsafeCSS(
|
|
24
|
+
`background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`
|
|
25
|
+
)};
|
|
26
|
+
}
|
|
27
|
+
.touch {
|
|
28
|
+
position: absolute;
|
|
29
|
+
height: 3rem;
|
|
30
|
+
left: 0;
|
|
31
|
+
right: 0;
|
|
32
|
+
}
|
|
33
|
+
.wrapper {
|
|
34
|
+
width: 100%;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
}
|
|
39
|
+
.label {
|
|
40
|
+
justify-self: center;
|
|
41
|
+
flex: 1 1 auto;
|
|
42
|
+
text-align: center;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};
|
|
47
|
+
}
|
|
48
|
+
.icon {
|
|
49
|
+
transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};
|
|
50
|
+
}
|
|
51
|
+
:host(:not(:disabled):not([disabled-interactive])) {
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
}
|
|
54
|
+
:host([disabled-interactive]) {
|
|
55
|
+
cursor: not-allowed;
|
|
56
|
+
}
|
|
57
|
+
.close-icon,
|
|
58
|
+
::slotted(:not([slot])),
|
|
59
|
+
::slotted([slot="close-icon"]) {
|
|
60
|
+
font-size: inherit !important;
|
|
61
|
+
flex: none;
|
|
62
|
+
}
|
|
63
|
+
.close-icon,
|
|
64
|
+
::slotted(svg:not([slot])),
|
|
65
|
+
::slotted(svg[slot="close-icon"]) {
|
|
66
|
+
width: 1em;
|
|
67
|
+
height: 1em;
|
|
68
|
+
}
|
|
69
|
+
:host(:not([extended])) ::slotted([slot="label"]),
|
|
70
|
+
.base.-with-menu ::slotted([slot="label"]),
|
|
71
|
+
.base:not(.-with-menu) ::slotted([slot="close-icon"]),
|
|
72
|
+
.base:not(.-with-menu) .close-icon,
|
|
73
|
+
:host([aria-expanded="true"]) .base.-with-menu ::slotted(:not([slot])),
|
|
74
|
+
:host([aria-expanded="false"]) .base.-with-menu ::slotted([slot="close-icon"]),
|
|
75
|
+
:host([aria-expanded="false"]) .base.-with-menu .close-icon {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
:host([aria-expanded="true"]) .base.-with-menu {
|
|
79
|
+
border-radius: var(--m3e-fab-menu-close-button-container-shape, ${DesignToken.shape.corner.full});
|
|
80
|
+
height: calc(var(--m3e-fab-menu-close-button-container-height, 3.5rem) + ${DesignToken.density.calc(-3)});
|
|
81
|
+
}
|
|
82
|
+
:host([aria-expanded="true"]) .base.-with-menu .wrapper {
|
|
83
|
+
padding-inline-start: calc(var(--m3e-fab-menu-close-button-leading-space, 1rem) + ${DesignToken.density.calc(-3)});
|
|
84
|
+
padding-inline-end: calc(var(--m3e-fab-menu-close-button-trailing-space, 1rem) + ${DesignToken.density.calc(-3)});
|
|
85
|
+
}
|
|
86
|
+
:host([aria-expanded="true"]) .base.-with-menu .icon {
|
|
87
|
+
font-size: calc(var(--m3e-fab-menu-close-button-icon-size, 1.5rem) + ${DesignToken.density.calc(-3)});
|
|
88
|
+
--m3e-icon-size: calc(var(--m3e-fab-menu-close-button-icon-size, 1.5rem) + ${DesignToken.density.calc(-3)});
|
|
89
|
+
}
|
|
90
|
+
.base.-with-menu {
|
|
91
|
+
transition: height ${DesignToken.motion.spring.fastSpatial};
|
|
92
|
+
}
|
|
93
|
+
.base.-with-menu .wrapper {
|
|
94
|
+
transition: padding ${DesignToken.motion.spring.fastSpatial};
|
|
95
|
+
}
|
|
96
|
+
a {
|
|
97
|
+
all: unset;
|
|
98
|
+
display: block;
|
|
99
|
+
position: absolute;
|
|
100
|
+
top: 0px;
|
|
101
|
+
left: 0px;
|
|
102
|
+
right: 0px;
|
|
103
|
+
bottom: 0px;
|
|
104
|
+
z-index: 1;
|
|
105
|
+
}
|
|
106
|
+
@media (forced-colors: active) {
|
|
107
|
+
.base,
|
|
108
|
+
.icon {
|
|
109
|
+
transition: none;
|
|
110
|
+
}
|
|
111
|
+
.base {
|
|
112
|
+
outline-style: solid;
|
|
113
|
+
}
|
|
114
|
+
:host([variant]:not(:disabled):not([disabled-interactive])) .base {
|
|
115
|
+
background-color: ButtonFace;
|
|
116
|
+
outline-color: ButtonText;
|
|
117
|
+
}
|
|
118
|
+
:host([variant]:not(:disabled):not([disabled-interactive])) .label,
|
|
119
|
+
:host([variant]:not(:disabled):not([disabled-interactive])) .icon {
|
|
120
|
+
color: ButtonText;
|
|
121
|
+
}
|
|
122
|
+
:host([variant]:disabled) .base,
|
|
123
|
+
:host([variant][disabled-interactive]) .base {
|
|
124
|
+
outline-color: GrayText;
|
|
125
|
+
background-color: unset;
|
|
126
|
+
}
|
|
127
|
+
:host([variant]:disabled) .label,
|
|
128
|
+
:host([variant][disabled-interactive]) .label,
|
|
129
|
+
:host([variant]:disabled) .icon,
|
|
130
|
+
:host([variant][disabled-interactive]) .icon {
|
|
131
|
+
color: GrayText;
|
|
132
|
+
}
|
|
133
|
+
:host([size="small"]) .base {
|
|
134
|
+
outline-offset: calc(0px - var(--m3e-button-small-outline-thickness, 1px));
|
|
135
|
+
outline-width: var(--m3e-button-small-outline-thickness, 1px);
|
|
136
|
+
}
|
|
137
|
+
:host([size="medium"]) .base {
|
|
138
|
+
outline-offset: calc(0px - var(--m3e-button-medium-outline-thickness, 1px));
|
|
139
|
+
outline-width: var(--m3e-button-medium-outline-thickness, 1px);
|
|
140
|
+
}
|
|
141
|
+
:host([size="large"]) .base {
|
|
142
|
+
outline-offset: calc(0px - var(--m3e-button-large-outline-thickness, 0.125rem));
|
|
143
|
+
outline-width: var(--m3e-button-large-outline-thickness, 0.125rem);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
@media (prefers-reduced-motion) {
|
|
147
|
+
.base,
|
|
148
|
+
.base.resting,
|
|
149
|
+
.base.pressed,
|
|
150
|
+
.label,
|
|
151
|
+
.icon {
|
|
152
|
+
transition: none;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { css, CSSResult, CSSResultGroup, unsafeCSS } from "lit";
|
|
2
|
+
|
|
3
|
+
import { FabVariant } from "../FabVariant";
|
|
4
|
+
import { FabVariantToken } from "./FabVariantToken";
|
|
5
|
+
|
|
6
|
+
/** @private */
|
|
7
|
+
function fabVariantStyle(variant: FabVariant): CSSResult {
|
|
8
|
+
return css`
|
|
9
|
+
:host([variant="${unsafeCSS(variant)}"]:not([lowered])) .base {
|
|
10
|
+
background-color: ${FabVariantToken[variant].containerColor};
|
|
11
|
+
--m3e-elevation-level: ${FabVariantToken[variant].containerElevation};
|
|
12
|
+
--m3e-elevation-hover-level: ${FabVariantToken[variant].hover.containerElevation};
|
|
13
|
+
--m3e-elevation-focus-level: ${FabVariantToken[variant].focus.containerElevation};
|
|
14
|
+
--m3e-elevation-pressed-level: ${FabVariantToken[variant].pressed.containerElevation};
|
|
15
|
+
}
|
|
16
|
+
:host([variant="${unsafeCSS(variant)}"][lowered]) .base {
|
|
17
|
+
background-color: ${FabVariantToken[variant].loweredContainerColor ?? FabVariantToken[variant].containerColor};
|
|
18
|
+
--m3e-elevation-level: ${FabVariantToken[variant].loweredContainerElevation};
|
|
19
|
+
--m3e-elevation-hover-level: ${FabVariantToken[variant].hover.loweredContainerElevation};
|
|
20
|
+
--m3e-elevation-focus-level: ${FabVariantToken[variant].focus.loweredContainerElevation};
|
|
21
|
+
--m3e-elevation-pressed-level: ${FabVariantToken[variant].pressed.loweredContainerElevation};
|
|
22
|
+
}
|
|
23
|
+
:host([variant="${unsafeCSS(variant)}"]) .base {
|
|
24
|
+
--m3e-state-layer-hover-color: ${FabVariantToken[variant].hover.stateLayerColor};
|
|
25
|
+
--m3e-state-layer-hover-opacity: ${FabVariantToken[variant].hover.stateLayerOpacity};
|
|
26
|
+
--m3e-state-layer-focus-color: ${FabVariantToken[variant].focus.stateLayerColor};
|
|
27
|
+
--m3e-state-layer-focus-opacity: ${FabVariantToken[variant].focus.stateLayerOpacity};
|
|
28
|
+
--m3e-ripple-color: ${FabVariantToken[variant].pressed.stateLayerColor};
|
|
29
|
+
--m3e-ripple-opacity: ${FabVariantToken[variant].pressed.stateLayerOpacity};
|
|
30
|
+
}
|
|
31
|
+
:host([variant="${unsafeCSS(variant)}"]) .label {
|
|
32
|
+
color: ${FabVariantToken[variant].labelTextColor};
|
|
33
|
+
}
|
|
34
|
+
:host([variant="${unsafeCSS(variant)}"]:focus) .label {
|
|
35
|
+
color: ${FabVariantToken[variant].focus.labelTextColor};
|
|
36
|
+
}
|
|
37
|
+
:host([variant="${unsafeCSS(variant)}"]:hover) .label {
|
|
38
|
+
color: ${FabVariantToken[variant].hover.labelTextColor};
|
|
39
|
+
}
|
|
40
|
+
:host([variant="${unsafeCSS(variant)}"]) .base.pressed .label {
|
|
41
|
+
color: ${FabVariantToken[variant].pressed.labelTextColor};
|
|
42
|
+
}
|
|
43
|
+
:host([variant="${unsafeCSS(variant)}"]) .icon {
|
|
44
|
+
color: ${FabVariantToken[variant].iconColor};
|
|
45
|
+
}
|
|
46
|
+
:host([variant="${unsafeCSS(variant)}"]:focus) .icon {
|
|
47
|
+
color: ${FabVariantToken[variant].focus.iconColor};
|
|
48
|
+
}
|
|
49
|
+
:host([variant="${unsafeCSS(variant)}"]:hover) .icon {
|
|
50
|
+
color: ${FabVariantToken[variant].hover.iconColor};
|
|
51
|
+
}
|
|
52
|
+
:host([variant="${unsafeCSS(variant)}"]) .base.pressed .icon {
|
|
53
|
+
color: ${FabVariantToken[variant].pressed.iconColor};
|
|
54
|
+
}
|
|
55
|
+
:host([variant="${unsafeCSS(variant)}"]:disabled) .base,
|
|
56
|
+
:host([variant="${unsafeCSS(variant)}"][disabled-interactive]) .base {
|
|
57
|
+
--m3e-elevation-level: ${FabVariantToken[variant].disabled.containerElevation};
|
|
58
|
+
background-color: color-mix(
|
|
59
|
+
in srgb,
|
|
60
|
+
${FabVariantToken[variant].disabled.containerColor} ${FabVariantToken[variant].disabled.containerOpacity},
|
|
61
|
+
transparent
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
:host([variant="${unsafeCSS(variant)}"]:disabled) .label,
|
|
65
|
+
:host([variant="${unsafeCSS(variant)}"][disabled-interactive]) .label {
|
|
66
|
+
color: color-mix(
|
|
67
|
+
in srgb,
|
|
68
|
+
${FabVariantToken[variant].disabled.labelTextColor} ${FabVariantToken[variant].disabled.labelTextOpacity},
|
|
69
|
+
transparent
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
:host([variant="${unsafeCSS(variant)}"]:disabled) .icon,
|
|
73
|
+
:host([variant="${unsafeCSS(variant)}"][disabled-interactive]) .icon {
|
|
74
|
+
color: color-mix(
|
|
75
|
+
in srgb,
|
|
76
|
+
${FabVariantToken[variant].disabled.iconColor} ${FabVariantToken[variant].disabled.iconOpacity},
|
|
77
|
+
transparent
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Appearance variant styles for `M3eFabElement`.
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export const FabVariantStyle: CSSResultGroup = [
|
|
88
|
+
fabVariantStyle("primary"),
|
|
89
|
+
fabVariantStyle("secondary"),
|
|
90
|
+
fabVariantStyle("tertiary"),
|
|
91
|
+
fabVariantStyle("primary-container"),
|
|
92
|
+
fabVariantStyle("secondary-container"),
|
|
93
|
+
fabVariantStyle("tertiary-container"),
|
|
94
|
+
fabVariantStyle("surface"),
|
|
95
|
+
];
|