m3-svelte 4.0.0-beta.3 → 4.1.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.
- package/package/buttons/Button.svelte +13 -13
- package/package/buttons/Button.svelte.d.ts +1 -1
- package/package/buttons/FAB.svelte +21 -10
- package/package/buttons/FAB.svelte.d.ts +1 -1
- package/package/index.d.ts +0 -2
- package/package/index.js +0 -2
- package/package/misc/_ripple.svelte +3 -9
- package/package/misc/_ripplesimple.svelte +2 -4
- package/package/misc/utils.d.ts +2 -1
- package/package/misc/utils.js +6 -6
- package/package.json +19 -20
- package/package/misc/StyleFromScheme.svelte +0 -18
- package/package/misc/StyleFromScheme.svelte.d.ts +0 -10
- package/package/misc/_styling.svelte +0 -26
- package/package/misc/_styling.svelte.d.ts +0 -9
- package/package/misc/serializeScheme.d.ts +0 -7
- package/package/misc/serializeScheme.js +0 -13
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
// If you want a toggle button, use `for` with an `<input>`.
|
|
11
11
|
type ActionProps =
|
|
12
|
-
| ({ click
|
|
12
|
+
| ({ click?: () => void; disabled?: boolean } & HTMLButtonAttributes)
|
|
13
13
|
| ({ href: string } & HTMLAnchorAttributes)
|
|
14
14
|
| ({ for: string } & HTMLLabelAttributes);
|
|
15
15
|
type Props = {
|
|
@@ -22,26 +22,24 @@
|
|
|
22
22
|
let props: Props = $props();
|
|
23
23
|
</script>
|
|
24
24
|
|
|
25
|
-
{#if "
|
|
25
|
+
{#if "for" in props}
|
|
26
26
|
{@const {
|
|
27
27
|
variant = "filled",
|
|
28
|
-
|
|
29
|
-
disabled,
|
|
28
|
+
for: forItem,
|
|
30
29
|
square = false,
|
|
31
30
|
iconType = "none",
|
|
32
31
|
children,
|
|
33
32
|
...extra
|
|
34
33
|
} = props}
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
{disabled}
|
|
34
|
+
<label
|
|
35
|
+
for={forItem}
|
|
38
36
|
class="m3-container m3-font-label-large {variant} icon-{iconType}"
|
|
39
37
|
class:square
|
|
40
38
|
{...extra}
|
|
41
39
|
>
|
|
42
40
|
<Layer />
|
|
43
41
|
{@render children()}
|
|
44
|
-
</
|
|
42
|
+
</label>
|
|
45
43
|
{:else if "href" in props}
|
|
46
44
|
{@const {
|
|
47
45
|
variant = "filled",
|
|
@@ -63,21 +61,23 @@
|
|
|
63
61
|
{:else}
|
|
64
62
|
{@const {
|
|
65
63
|
variant = "filled",
|
|
66
|
-
|
|
64
|
+
click,
|
|
65
|
+
disabled,
|
|
67
66
|
square = false,
|
|
68
67
|
iconType = "none",
|
|
69
68
|
children,
|
|
70
69
|
...extra
|
|
71
70
|
} = props}
|
|
72
|
-
<
|
|
73
|
-
|
|
71
|
+
<button
|
|
72
|
+
onclick={click}
|
|
73
|
+
{disabled}
|
|
74
74
|
class="m3-container m3-font-label-large {variant} icon-{iconType}"
|
|
75
75
|
class:square
|
|
76
76
|
{...extra}
|
|
77
77
|
>
|
|
78
78
|
<Layer />
|
|
79
79
|
{@render children()}
|
|
80
|
-
</
|
|
80
|
+
</button>
|
|
81
81
|
{/if}
|
|
82
82
|
|
|
83
83
|
<style>
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
&:is(:global(input:checked) + label):not(.square) {
|
|
171
171
|
border-radius: var(--m3-util-rounding-medium);
|
|
172
172
|
}
|
|
173
|
-
&:
|
|
173
|
+
&:active {
|
|
174
174
|
border-radius: var(--m3-util-rounding-small) !important;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HTMLButtonAttributes, HTMLAnchorAttributes, HTMLLabelAttributes } from "svelte/elements";
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
3
|
type ActionProps = ({
|
|
4
|
-
click
|
|
4
|
+
click?: () => void;
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
} & HTMLButtonAttributes) | ({
|
|
7
7
|
href: string;
|
|
@@ -25,7 +25,13 @@
|
|
|
25
25
|
text,
|
|
26
26
|
...extra
|
|
27
27
|
}: {
|
|
28
|
-
color?:
|
|
28
|
+
color?:
|
|
29
|
+
| "primary-container"
|
|
30
|
+
| "secondary-container"
|
|
31
|
+
| "tertiary-container"
|
|
32
|
+
| "primary"
|
|
33
|
+
| "secondary"
|
|
34
|
+
| "tertiary";
|
|
29
35
|
elevation?: "normal" | "lowered" | "none";
|
|
30
36
|
click: () => void;
|
|
31
37
|
} & ContentProps &
|
|
@@ -100,21 +106,26 @@
|
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
.color-primary {
|
|
103
|
-
background-color: rgb(var(--m3-scheme-primary
|
|
104
|
-
color: rgb(var(--m3-scheme-on-primary
|
|
109
|
+
background-color: rgb(var(--m3-scheme-primary));
|
|
110
|
+
color: rgb(var(--m3-scheme-on-primary));
|
|
105
111
|
}
|
|
106
|
-
.color-
|
|
107
|
-
background-color: rgb(var(--m3-scheme-
|
|
108
|
-
color: rgb(var(--m3-scheme-
|
|
112
|
+
.color-secondary {
|
|
113
|
+
background-color: rgb(var(--m3-scheme-secondary));
|
|
114
|
+
color: rgb(var(--m3-scheme-on-secondary));
|
|
109
115
|
}
|
|
110
|
-
.color-
|
|
111
|
-
background-color: rgb(var(--m3-scheme-
|
|
116
|
+
.color-tertiary {
|
|
117
|
+
background-color: rgb(var(--m3-scheme-tertiary));
|
|
118
|
+
color: rgb(var(--m3-scheme-on-tertiary));
|
|
112
119
|
}
|
|
113
|
-
.color-
|
|
120
|
+
.color-primary-container {
|
|
121
|
+
background-color: rgb(var(--m3-scheme-primary-container));
|
|
122
|
+
color: rgb(var(--m3-scheme-on-primary-container));
|
|
123
|
+
}
|
|
124
|
+
.color-secondary-container {
|
|
114
125
|
background-color: rgb(var(--m3-scheme-secondary-container));
|
|
115
126
|
color: rgb(var(--m3-scheme-on-secondary-container));
|
|
116
127
|
}
|
|
117
|
-
.color-tertiary {
|
|
128
|
+
.color-tertiary-container {
|
|
118
129
|
background-color: rgb(var(--m3-scheme-tertiary-container));
|
|
119
130
|
color: rgb(var(--m3-scheme-on-tertiary-container));
|
|
120
131
|
}
|
|
@@ -10,7 +10,7 @@ type ContentProps = {
|
|
|
10
10
|
text?: undefined;
|
|
11
11
|
};
|
|
12
12
|
type $$ComponentProps = {
|
|
13
|
-
color?: "primary" | "
|
|
13
|
+
color?: "primary-container" | "secondary-container" | "tertiary-container" | "primary" | "secondary" | "tertiary";
|
|
14
14
|
elevation?: "normal" | "lowered" | "none";
|
|
15
15
|
click: () => void;
|
|
16
16
|
} & ContentProps & HTMLButtonAttributes;
|
package/package/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
export { default as StyleFromScheme } from "./misc/StyleFromScheme.svelte";
|
|
2
1
|
export { default as Icon } from "./misc/_icon.svelte";
|
|
3
2
|
export { default as Layer } from "./misc/Layer.svelte";
|
|
4
3
|
export * from "./misc/animation.js";
|
|
5
4
|
export * from "./misc/utils.js";
|
|
6
5
|
export * from "./misc/easing.js";
|
|
7
|
-
export * from "./misc/serializeScheme.js";
|
|
8
6
|
export { default as Button } from "./buttons/Button.svelte";
|
|
9
7
|
export { default as ConnectedButtons } from "./buttons/ConnectedButtons.svelte";
|
|
10
8
|
export { default as FAB } from "./buttons/FAB.svelte";
|
package/package/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
export { default as StyleFromScheme } from "./misc/StyleFromScheme.svelte";
|
|
2
1
|
export { default as Icon } from "./misc/_icon.svelte";
|
|
3
2
|
export { default as Layer } from "./misc/Layer.svelte";
|
|
4
3
|
export * from "./misc/animation.js";
|
|
5
4
|
export * from "./misc/utils.js";
|
|
6
5
|
export * from "./misc/easing.js";
|
|
7
|
-
export * from "./misc/serializeScheme.js";
|
|
8
6
|
export { default as Button } from "./buttons/Button.svelte";
|
|
9
7
|
export { default as ConnectedButtons } from "./buttons/ConnectedButtons.svelte";
|
|
10
8
|
export { default as FAB } from "./buttons/FAB.svelte";
|
|
@@ -101,8 +101,6 @@
|
|
|
101
101
|
|
|
102
102
|
node.appendChild(svg);
|
|
103
103
|
|
|
104
|
-
parent.classList.toggle("activated", true);
|
|
105
|
-
|
|
106
104
|
cancelRipples.push(() => {
|
|
107
105
|
const fade = document.createElementNS("http://www.w3.org/2000/svg", "animate");
|
|
108
106
|
fade.setAttribute("attributeName", "opacity");
|
|
@@ -115,8 +113,6 @@
|
|
|
115
113
|
circle.appendChild(fade);
|
|
116
114
|
fade.beginElement();
|
|
117
115
|
setTimeout(() => svg.remove(), 800);
|
|
118
|
-
|
|
119
|
-
parent.classList.toggle("activated", false);
|
|
120
116
|
});
|
|
121
117
|
};
|
|
122
118
|
|
|
@@ -171,11 +167,9 @@
|
|
|
171
167
|
}
|
|
172
168
|
}
|
|
173
169
|
|
|
174
|
-
&:focus-visible > .tint
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
&:active > .ripple-container.broken + .tint {
|
|
170
|
+
&:is(:global(input:focus-visible + label)) > .tint,
|
|
171
|
+
&:focus-visible > .tint,
|
|
172
|
+
&:active > .tint {
|
|
179
173
|
opacity: 0.12;
|
|
180
174
|
}
|
|
181
175
|
}
|
package/package/misc/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DynamicScheme } from "@ktibow/material-color-utilities-nightly";
|
|
1
2
|
export type Color = "primary" | "onPrimary" | "primaryContainer" | "onPrimaryContainer" | "inversePrimary" | "secondary" | "onSecondary" | "secondaryContainer" | "onSecondaryContainer" | "tertiary" | "onTertiary" | "tertiaryContainer" | "onTertiaryContainer" | "error" | "onError" | "errorContainer" | "onErrorContainer" | "background" | "onBackground" | "surface" | "onSurface" | "surfaceVariant" | "onSurfaceVariant" | "inverseSurface" | "inverseOnSurface" | "outline" | "outlineVariant" | "shadow" | "scrim" | "surfaceDim" | "surfaceBright" | "surfaceContainerLowest" | "surfaceContainerLow" | "surfaceContainer" | "surfaceContainerHigh" | "surfaceContainerHighest" | "surfaceTint";
|
|
2
3
|
export type SerializedScheme = Record<Color, number>;
|
|
3
4
|
export declare const pairs: string[][];
|
|
@@ -5,5 +6,5 @@ export declare const colors: Color[];
|
|
|
5
6
|
/**
|
|
6
7
|
* @returns A string of CSS code with custom properties representing the color scheme values.
|
|
7
8
|
* */
|
|
8
|
-
export declare const genCSS: (light:
|
|
9
|
+
export declare const genCSS: (light: DynamicScheme, dark: DynamicScheme) => string;
|
|
9
10
|
export declare const parseSize: (size: string) => number;
|
package/package/misc/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MaterialDynamicColors, } from "@ktibow/material-color-utilities-nightly";
|
|
1
2
|
export const pairs = [
|
|
2
3
|
["primary", "onPrimary"],
|
|
3
4
|
["primaryContainer", "onPrimaryContainer"],
|
|
@@ -62,13 +63,13 @@ export const genCSS = (light, dark) => {
|
|
|
62
63
|
const blue = argb & 255;
|
|
63
64
|
return `--m3-scheme-${kebabCase}: ${red} ${green} ${blue};`;
|
|
64
65
|
};
|
|
65
|
-
const lightColors =
|
|
66
|
-
.map((
|
|
66
|
+
const lightColors = colors
|
|
67
|
+
.map((name) => genColorVariable(name, MaterialDynamicColors[name].getArgb(light)))
|
|
67
68
|
.join("\n");
|
|
68
|
-
const darkColors =
|
|
69
|
-
.map((
|
|
69
|
+
const darkColors = colors
|
|
70
|
+
.map((name) => genColorVariable(name, MaterialDynamicColors[name].getArgb(dark)))
|
|
70
71
|
.join("\n");
|
|
71
|
-
|
|
72
|
+
return `@media (prefers-color-scheme: light) {
|
|
72
73
|
:root {
|
|
73
74
|
color-scheme: light;
|
|
74
75
|
}
|
|
@@ -84,7 +85,6 @@ ${lightColors}
|
|
|
84
85
|
${darkColors}
|
|
85
86
|
}
|
|
86
87
|
}`;
|
|
87
|
-
return colors;
|
|
88
88
|
};
|
|
89
89
|
export const parseSize = (size) => (size.endsWith("px")
|
|
90
90
|
? +size.slice(0, -2)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "m3-svelte",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"license": "Apache-2.0 OR GPL-3.0-only",
|
|
5
5
|
"repository": "KTibow/m3-svelte",
|
|
6
6
|
"author": {
|
|
@@ -30,30 +30,29 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@iconify/types": "^2.0.0",
|
|
32
32
|
"@ktibow/iconset-material-symbols": "^0.0.1747426012",
|
|
33
|
-
"@
|
|
34
|
-
"svelte": "^5.
|
|
33
|
+
"@ktibow/material-color-utilities-nightly": "^0.3.11748493074137",
|
|
34
|
+
"svelte": "^5.33.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@eslint/compat": "^1.2.
|
|
38
|
-
"@eslint/js": "^9.
|
|
37
|
+
"@eslint/compat": "^1.2.9",
|
|
38
|
+
"@eslint/js": "^9.27.0",
|
|
39
39
|
"@sveltejs/adapter-static": "^3.0.8",
|
|
40
|
-
"@sveltejs/kit": "^2.
|
|
41
|
-
"@sveltejs/package": "^2.
|
|
42
|
-
"@sveltejs/vite-plugin-svelte": "^5.0.
|
|
43
|
-
"eslint": "^9.
|
|
44
|
-
"eslint-config-prettier": "^10.
|
|
45
|
-
"eslint-plugin-svelte": "^3.
|
|
40
|
+
"@sveltejs/kit": "^2.21.1",
|
|
41
|
+
"@sveltejs/package": "^2.3.11",
|
|
42
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
43
|
+
"eslint": "^9.27.0",
|
|
44
|
+
"eslint-config-prettier": "^10.1.5",
|
|
45
|
+
"eslint-plugin-svelte": "^3.9.0",
|
|
46
46
|
"fast-glob": "^3.3.3",
|
|
47
|
-
"globals": "^16.
|
|
48
|
-
"prettier": "^3.
|
|
49
|
-
"prettier-plugin-svelte": "^3.
|
|
50
|
-
"publint": "^0.3.
|
|
51
|
-
"svelte": "^
|
|
52
|
-
"svelte-check": "^4.0.0",
|
|
47
|
+
"globals": "^16.2.0",
|
|
48
|
+
"prettier": "^3.5.3",
|
|
49
|
+
"prettier-plugin-svelte": "^3.4.0",
|
|
50
|
+
"publint": "^0.3.12",
|
|
51
|
+
"svelte-check": "^4.2.1",
|
|
53
52
|
"svelte-highlight": "^7.8.3",
|
|
54
|
-
"typescript": "^5.
|
|
55
|
-
"typescript-eslint": "^8.
|
|
56
|
-
"vite": "^6.
|
|
53
|
+
"typescript": "^5.8.3",
|
|
54
|
+
"typescript-eslint": "^8.32.1",
|
|
55
|
+
"vite": "^6.3.5"
|
|
57
56
|
},
|
|
58
57
|
"keywords": [
|
|
59
58
|
"svelte",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
@component
|
|
3
|
-
@deprecated Directly set styles instead
|
|
4
|
-
-->
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import type { SerializedScheme } from "./utils";
|
|
7
|
-
import Styling from "./_styling.svelte";
|
|
8
|
-
import "./styles.css";
|
|
9
|
-
|
|
10
|
-
interface Props {
|
|
11
|
-
lightScheme: SerializedScheme;
|
|
12
|
-
darkScheme: SerializedScheme;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let { lightScheme, darkScheme }: Props = $props();
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<Styling {lightScheme} {darkScheme} />
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { SerializedScheme } from "./utils";
|
|
2
|
-
import "./styles.css";
|
|
3
|
-
interface Props {
|
|
4
|
-
lightScheme: SerializedScheme;
|
|
5
|
-
darkScheme: SerializedScheme;
|
|
6
|
-
}
|
|
7
|
-
/** @deprecated Directly set styles instead */
|
|
8
|
-
declare const StyleFromScheme: import("svelte").Component<Props, {}, "">;
|
|
9
|
-
type StyleFromScheme = ReturnType<typeof StyleFromScheme>;
|
|
10
|
-
export default StyleFromScheme;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
@component
|
|
3
|
-
@deprecated Directly set styles instead
|
|
4
|
-
-->
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import { genCSS, type SerializedScheme } from "./utils";
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
lightScheme: SerializedScheme;
|
|
10
|
-
darkScheme: SerializedScheme;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
let { lightScheme, darkScheme }: Props = $props();
|
|
14
|
-
const hexCode = (argb: number) => "#" + ((argb & 0xffffff) + 0x1000000).toString(16).slice(1);
|
|
15
|
-
let styling = $derived(genCSS(lightScheme, darkScheme));
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<svelte:head>
|
|
19
|
-
<meta name="theme-color" content={hexCode(lightScheme["primary"])} />
|
|
20
|
-
<meta
|
|
21
|
-
name="theme-color"
|
|
22
|
-
media="(prefers-color-scheme: dark)"
|
|
23
|
-
content={hexCode(darkScheme["primary"])}
|
|
24
|
-
/>
|
|
25
|
-
</svelte:head>
|
|
26
|
-
{@html `<${""}style>${styling}</${""}style>`}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type SerializedScheme } from "./utils";
|
|
2
|
-
interface Props {
|
|
3
|
-
lightScheme: SerializedScheme;
|
|
4
|
-
darkScheme: SerializedScheme;
|
|
5
|
-
}
|
|
6
|
-
/** @deprecated Directly set styles instead */
|
|
7
|
-
declare const Styling: import("svelte").Component<Props, {}, "">;
|
|
8
|
-
type Styling = ReturnType<typeof Styling>;
|
|
9
|
-
export default Styling;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type DynamicScheme } from "@material/material-color-utilities";
|
|
2
|
-
import { type SerializedScheme } from "./utils";
|
|
3
|
-
/**
|
|
4
|
-
* @description Serializes the {@link DynamicScheme} so that it can be used by {@link StyleFromScheme} and {@link genCSS}.
|
|
5
|
-
* @param scheme The theme generated by material-color-utils.
|
|
6
|
-
* */
|
|
7
|
-
export declare const serializeScheme: (scheme: DynamicScheme) => SerializedScheme;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { MaterialDynamicColors } from "@material/material-color-utilities";
|
|
2
|
-
import { colors } from "./utils";
|
|
3
|
-
/**
|
|
4
|
-
* @description Serializes the {@link DynamicScheme} so that it can be used by {@link StyleFromScheme} and {@link genCSS}.
|
|
5
|
-
* @param scheme The theme generated by material-color-utils.
|
|
6
|
-
* */
|
|
7
|
-
export const serializeScheme = (scheme) => {
|
|
8
|
-
const out = {};
|
|
9
|
-
for (const color of colors) {
|
|
10
|
-
out[color] = MaterialDynamicColors[color].getArgb(scheme);
|
|
11
|
-
}
|
|
12
|
-
return out;
|
|
13
|
-
};
|