m3-svelte 5.2.6 → 5.3.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.
@@ -30,124 +30,40 @@
30
30
  --m3-util-rounding-medium: 12px;
31
31
  --m3-util-rounding-large: 16px;
32
32
  --m3-util-rounding-extra-large: 28px;
33
- --m3-util-rounding-full: 9999px;
33
+ --m3-util-rounding-full: calc(infinity * 1px);
34
34
  --m3-util-optical-centering-coefficient: 0.11;
35
35
 
36
36
  --m3-font: Roboto, system-ui, sans-serif;
37
+ --m3-font-mono: "Google Sans Code", "Roboto Mono", monospace;
37
38
 
38
39
  /* Expressive easing */
39
- --m3-util-easing-fast-spatial: cubic-bezier(0.42, 1.67, 0.21, 0.9) 350ms;
40
- --m3-util-easing-spatial: cubic-bezier(0.38, 1.21, 0.22, 1) 500ms;
41
- --m3-util-easing-slow-spatial: cubic-bezier(0.39, 1.29, 0.35, 0.98) 650ms;
42
- --m3-util-easing-fast: cubic-bezier(0.31, 0.94, 0.34, 1) 150ms;
43
- --m3-util-easing: cubic-bezier(0.34, 0.8, 0.34, 1) 200ms;
44
- --m3-util-easing-slow: cubic-bezier(0.34, 0.88, 0.34, 1) 300ms;
45
- /* Emphasized easing, curve derived from this code:
46
- const createBezierLUT = (points: number[][], pointCount: number = 100): number[][] => {
47
- const lut: number[][] = [];
48
- for (let t = 0; t < 1; t += 1 / pointCount) {
49
- const a = (1 - t) * (1 - t) * (1 - t);
50
- const b = (1 - t) * (1 - t) * t;
51
- const c = (1 - t) * t * t;
52
- const d = t * t * t;
53
- const x = a * points[0][0] + 3 * b * points[1][0] + 3 * c * points[2][0] + d * points[3][0];
54
- const y = a * points[0][1] + 3 * b * points[1][1] + 3 * c * points[2][1] + d * points[3][1];
55
- lut.push([x, y]);
56
- }
57
- return lut;
58
- };
59
-
60
- const createCSSEaseOptimized = (
61
- lutOptions: number[][][],
62
- maxErrorThreshold: number = 0.01
63
- ): string => {
64
- // Create the full lookup table
65
- const lut = lutOptions.map((args) => createBezierLUT(args)).flat();
66
-
67
- // Find key points using Douglas-Peucker algorithm
68
- const keyPoints: number[][] = [lut[0], lut[lut.length - 1]];
69
- const segments: number[][] = [[0, lut.length - 1]];
70
-
71
- while (segments.length > 0) {
72
- const [startIdx, endIdx] = segments.pop() || [0, 0];
73
- let maxError = 0;
74
- let maxErrorIdx = -1;
75
-
76
- // Skip if segment is too small
77
- if (endIdx - startIdx <= 1) continue;
40
+ --m3-util-timing-function-fast-spatial: cubic-bezier(0.42, 1.67, 0.21, 0.9);
41
+ --m3-util-duration-fast-spatial: 350ms;
42
+ --m3-util-easing-fast-spatial: var(--m3-util-timing-function-fast-spatial)
43
+ var(--m3-util-duration-fast-spatial);
78
44
 
79
- const [startX, startY] = lut[startIdx];
80
- const [endX, endY] = lut[endIdx];
45
+ --m3-util-timing-function-spatial: cubic-bezier(0.38, 1.21, 0.22, 1);
46
+ --m3-util-duration-spatial: 500ms;
47
+ --m3-util-easing-spatial: var(--m3-util-timing-function-spatial) var(--m3-util-duration-spatial);
81
48
 
82
- // Find point with maximum error
83
- for (let i = startIdx + 1; i < endIdx; i++) {
84
- const [x, y] = lut[i];
49
+ --m3-util-timing-function-slow-spatial: cubic-bezier(0.39, 1.29, 0.35, 0.98);
50
+ --m3-util-duration-slow-spatial: 650ms;
51
+ --m3-util-easing-slow-spatial: var(--m3-util-timing-function-slow-spatial)
52
+ var(--m3-util-duration-slow-spatial);
85
53
 
86
- // Linear interpolation
87
- const t = (x - startX) / (endX - startX);
88
- const interpolatedY = startY + t * (endY - startY);
54
+ --m3-util-timing-function-fast: cubic-bezier(0.31, 0.94, 0.34, 1);
55
+ --m3-util-duration-fast: 150ms;
56
+ --m3-util-easing-fast: var(--m3-util-timing-function-fast) var(--m3-util-duration-fast);
89
57
 
90
- const error = Math.abs(y - interpolatedY);
58
+ --m3-util-timing-function: cubic-bezier(0.34, 0.8, 0.34, 1);
59
+ --m3-util-duration: 200ms;
60
+ --m3-util-easing: var(--m3-util-timing-function) var(--m3-util-duration);
91
61
 
92
- if (error > maxError) {
93
- maxError = error;
94
- maxErrorIdx = i;
95
- }
96
- }
97
-
98
- // If error exceeds threshold, add point and split segment
99
- if (maxError > maxErrorThreshold) {
100
- keyPoints.push(lut[maxErrorIdx]);
101
- segments.push([startIdx, maxErrorIdx]);
102
- segments.push([maxErrorIdx, endIdx]);
103
- }
104
- }
105
-
106
- // Sort by x value
107
- keyPoints.sort((a, b) => a[0] - b[0]);
108
-
109
- // Format result using CSS linear() with explicit percentages
110
- let result = "linear(";
111
-
112
- // First point (no percentage for first point)
113
- result += keyPoints[0][1].toFixed(3);
114
-
115
- // Middle points with explicit percentages
116
- for (let i = 1; i < keyPoints.length - 1; i++) {
117
- const [x, y] = keyPoints[i];
118
- const percentage = (x * 100).toFixed(0) + "%";
119
- result += `, ${y.toFixed(3)} ${percentage}`;
120
- }
62
+ --m3-util-timing-function-slow: cubic-bezier(0.34, 0.88, 0.34, 1);
63
+ --m3-util-duration-slow: 300ms;
64
+ --m3-util-easing-slow: var(--m3-util-timing-function-slow) var(--m3-util-duration-slow);
121
65
 
122
- // Last point (no percentage for last point)
123
- result += `, ${keyPoints[keyPoints.length - 1][1].toFixed(3)}`;
124
- result += ")";
125
-
126
- return result;
127
- };
128
-
129
- // Example usage
130
- const testInput = [
131
- [
132
- [0, 0],
133
- [0.05, 0],
134
- [0.133, 0.06],
135
- [0.166, 0.4],
136
- ],
137
- [
138
- [0.166, 0.4],
139
- [0.208, 0.82],
140
- [0.25, 1],
141
- [1, 1],
142
- ],
143
- ];
144
-
145
- // Run optimized function with a more relaxed threshold for smaller size
146
- const optimizedSmallResult = createCSSEaseOptimized(testInput, 0.01);
147
- console.log("Optimized result (relaxed threshold 0.01):");
148
- console.log(optimizedSmallResult);
149
- */
150
- --m3-util-curve: linear(
66
+ --m3-util-timing-function-emphasized: linear(
151
67
  0,
152
68
  0.034 6%,
153
69
  0.073 9%,
@@ -164,8 +80,13 @@ console.log(optimizedSmallResult);
164
80
  0.989 72%,
165
81
  1
166
82
  );
167
- --m3-util-curve-decel: cubic-bezier(0.05, 0.7, 0.1, 1);
168
- --m3-util-curve-accel: cubic-bezier(0.3, 0, 0.8, 0.15);
83
+ --m3-util-timing-function-emphasized-accel: cubic-bezier(0.3, 0, 0.8, 0.15);
84
+ --m3-util-timing-function-emphasized-decel: cubic-bezier(0.05, 0.7, 0.1, 1);
85
+
86
+ /* deprecated / todo next release remove */
87
+ --m3-util-curve: var(--m3-util-timing-function-emphasized);
88
+ --m3-util-curve-accel: var(--m3-util-timing-function-emphasized-accel);
89
+ --m3-util-curve-decel: var(--m3-util-timing-function-emphasized-decel);
169
90
 
170
91
  accent-color: rgb(var(--m3-scheme-primary));
171
92
  }
@@ -290,20 +211,128 @@ or for very small text in the content body, such as captions. */
290
211
  letter-spacing: var(--m3-font-body-small-tracking, 0.025rem);
291
212
  font-weight: var(--m3-font-body-small-weight, 400);
292
213
  }
293
- /* Fix some browser stuff */
294
- .m3-container {
295
- box-sizing: border-box;
214
+ /* Reset a few things */
215
+ @layer base {
216
+ *,
217
+ *::before,
218
+ *::after {
219
+ box-sizing: inherit;
220
+ }
221
+ .m3-container {
222
+ box-sizing: border-box;
223
+ }
224
+ .m3-container a,
225
+ a.m3-container {
226
+ text-decoration: none;
227
+ }
228
+ .m3-container dialog,
229
+ dialog.m3-container {
230
+ margin: auto;
231
+ }
296
232
  }
297
- *,
298
- *::before,
299
- *::after {
300
- box-sizing: inherit;
233
+
234
+ /* Emphasized easing timing function derived from this code:
235
+ const createBezierLUT = (points: number[][], pointCount: number = 100): number[][] => {
236
+ const lut: number[][] = [];
237
+ for (let t = 0; t < 1; t += 1 / pointCount) {
238
+ const a = (1 - t) * (1 - t) * (1 - t);
239
+ const b = (1 - t) * (1 - t) * t;
240
+ const c = (1 - t) * t * t;
241
+ const d = t * t * t;
242
+ const x = a * points[0][0] + 3 * b * points[1][0] + 3 * c * points[2][0] + d * points[3][0];
243
+ const y = a * points[0][1] + 3 * b * points[1][1] + 3 * c * points[2][1] + d * points[3][1];
244
+ lut.push([x, y]);
301
245
  }
302
- .m3-container a,
303
- a.m3-container {
304
- text-decoration: none;
246
+ return lut;
247
+ };
248
+
249
+ const createCSSEaseOptimized = (
250
+ lutOptions: number[][][],
251
+ maxErrorThreshold: number = 0.01
252
+ ): string => {
253
+ // Create the full lookup table
254
+ const lut = lutOptions.map((args) => createBezierLUT(args)).flat();
255
+
256
+ // Find key points using Douglas-Peucker algorithm
257
+ const keyPoints: number[][] = [lut[0], lut[lut.length - 1]];
258
+ const segments: number[][] = [[0, lut.length - 1]];
259
+
260
+ while (segments.length > 0) {
261
+ const [startIdx, endIdx] = segments.pop() || [0, 0];
262
+ let maxError = 0;
263
+ let maxErrorIdx = -1;
264
+
265
+ // Skip if segment is too small
266
+ if (endIdx - startIdx <= 1) continue;
267
+
268
+ const [startX, startY] = lut[startIdx];
269
+ const [endX, endY] = lut[endIdx];
270
+
271
+ // Find point with maximum error
272
+ for (let i = startIdx + 1; i < endIdx; i++) {
273
+ const [x, y] = lut[i];
274
+
275
+ // Linear interpolation
276
+ const t = (x - startX) / (endX - startX);
277
+ const interpolatedY = startY + t * (endY - startY);
278
+
279
+ const error = Math.abs(y - interpolatedY);
280
+
281
+ if (error > maxError) {
282
+ maxError = error;
283
+ maxErrorIdx = i;
284
+ }
285
+ }
286
+
287
+ // If error exceeds threshold, add point and split segment
288
+ if (maxError > maxErrorThreshold) {
289
+ keyPoints.push(lut[maxErrorIdx]);
290
+ segments.push([startIdx, maxErrorIdx]);
291
+ segments.push([maxErrorIdx, endIdx]);
292
+ }
305
293
  }
306
- .m3-container dialog,
307
- dialog.m3-container {
308
- margin: auto;
294
+
295
+ // Sort by x value
296
+ keyPoints.sort((a, b) => a[0] - b[0]);
297
+
298
+ // Format result using CSS linear() with explicit percentages
299
+ let result = "linear(";
300
+
301
+ // First point (no percentage for first point)
302
+ result += keyPoints[0][1].toFixed(3);
303
+
304
+ // Middle points with explicit percentages
305
+ for (let i = 1; i < keyPoints.length - 1; i++) {
306
+ const [x, y] = keyPoints[i];
307
+ const percentage = (x * 100).toFixed(0) + "%";
308
+ result += `, ${y.toFixed(3)} ${percentage}`;
309
309
  }
310
+
311
+ // Last point (no percentage for last point)
312
+ result += `, ${keyPoints[keyPoints.length - 1][1].toFixed(3)}`;
313
+ result += ")";
314
+
315
+ return result;
316
+ };
317
+
318
+ // Example usage
319
+ const testInput = [
320
+ [
321
+ [0, 0],
322
+ [0.05, 0],
323
+ [0.133, 0.06],
324
+ [0.166, 0.4],
325
+ ],
326
+ [
327
+ [0.166, 0.4],
328
+ [0.208, 0.82],
329
+ [0.25, 1],
330
+ [1, 1],
331
+ ],
332
+ ];
333
+
334
+ // Run optimized function with a more relaxed threshold for smaller size
335
+ const optimizedSmallResult = createCSSEaseOptimized(testInput, 0.01);
336
+ console.log("Optimized result (relaxed threshold 0.01):");
337
+ console.log(optimizedSmallResult);
338
+ */
@@ -0,0 +1,162 @@
1
+ @theme {
2
+ --*: initial;
3
+
4
+ --spacing: 0.25rem;
5
+ --font-mono: var(--m3-font-mono);
6
+
7
+ --shadow-1: var(--m3-util-elevation-1);
8
+ --shadow-2: var(--m3-util-elevation-2);
9
+ --shadow-3: var(--m3-util-elevation-3);
10
+ --shadow-4: var(--m3-util-elevation-4);
11
+ --shadow-5: var(--m3-util-elevation-5);
12
+
13
+ --radius-xs: var(--m3-util-rounding-extra-small); /* = 4px = rounded-sm */
14
+ --radius-s: var(--m3-util-rounding-small); /* = 8px = rounded-lg */
15
+ --radius-m: var(--m3-util-rounding-medium); /* = 12px = rounded-xl */
16
+ --radius-l: var(--m3-util-rounding-large); /* = 16px = rounded-2xl */
17
+ --radius-xl: var(--m3-util-rounding-extra-large); /* = 28px ≅ rounded-3xl */
18
+
19
+ --breakpoint-m: 37.5rem; /* ≅ sm */
20
+ --breakpoint-x: 52.5rem; /* ≅ md */
21
+ --breakpoint-l: 75rem; /* ≅ lg, xl */
22
+ --breakpoint-xl: 100rem; /* ≅ 2xl */
23
+
24
+ --ease-fast-spatial: var(--m3-util-timing-function-fast-spatial);
25
+ --ease-spatial: var(--m3-util-timing-function-spatial);
26
+ --ease-slow-spatial: var(--m3-util-timing-function-slow-spatial);
27
+ --ease-fast: var(--m3-util-timing-function-fast);
28
+ --ease: var(--m3-util-timing-function);
29
+ --ease-slow: var(--m3-util-timing-function-slow);
30
+ --ease-emphasized: var(--m3-util-timing-function-emphasized);
31
+ --ease-emphasized-accel: var(--m3-util-timing-function-emphasized-accel);
32
+ --ease-emphasized-decel: var(--m3-util-timing-function-emphasized-decel);
33
+
34
+ --default-transition-timing-function: var(--ease);
35
+ --default-transition-duration: var(--m3-util-duration);
36
+
37
+ --color-background: rgb(var(--m3-scheme-background));
38
+ --color-on-background: rgb(var(--m3-scheme-on-background));
39
+ --color-surface: rgb(var(--m3-scheme-surface));
40
+ --color-surface-dim: rgb(var(--m3-scheme-surface-dim));
41
+ --color-surface-bright: rgb(var(--m3-scheme-surface-bright));
42
+ --color-surface-container-lowest: rgb(var(--m3-scheme-surface-container-lowest));
43
+ --color-surface-container-low: rgb(var(--m3-scheme-surface-container-low));
44
+ --color-surface-container: rgb(var(--m3-scheme-surface-container));
45
+ --color-surface-container-high: rgb(var(--m3-scheme-surface-container-high));
46
+ --color-surface-container-highest: rgb(var(--m3-scheme-surface-container-highest));
47
+ --color-on-surface: rgb(var(--m3-scheme-on-surface));
48
+ --color-on-surface-variant: rgb(var(--m3-scheme-on-surface-variant));
49
+ --color-outline: rgb(var(--m3-scheme-outline));
50
+ --color-outline-variant: rgb(var(--m3-scheme-outline-variant));
51
+ --color-inverse-surface: rgb(var(--m3-scheme-inverse-surface));
52
+ --color-inverse-on-surface: rgb(var(--m3-scheme-inverse-on-surface));
53
+ --color-primary: rgb(var(--m3-scheme-primary));
54
+ --color-primary-dim: rgb(var(--m3-scheme-primary-dim));
55
+ --color-on-primary: rgb(var(--m3-scheme-on-primary));
56
+ --color-primary-container: rgb(var(--m3-scheme-primary-container));
57
+ --color-on-primary-container: rgb(var(--m3-scheme-on-primary-container));
58
+ --color-primary-fixed: rgb(var(--m3-scheme-primary-fixed));
59
+ --color-primary-fixed-dim: rgb(var(--m3-scheme-primary-fixed-dim));
60
+ --color-on-primary-fixed: rgb(var(--m3-scheme-on-primary-fixed));
61
+ --color-on-primary-fixed-variant: rgb(var(--m3-scheme-on-primary-fixed-variant));
62
+ --color-inverse-primary: rgb(var(--m3-scheme-inverse-primary));
63
+ --color-secondary: rgb(var(--m3-scheme-secondary));
64
+ --color-secondary-dim: rgb(var(--m3-scheme-secondary-dim));
65
+ --color-on-secondary: rgb(var(--m3-scheme-on-secondary));
66
+ --color-secondary-container: rgb(var(--m3-scheme-secondary-container));
67
+ --color-on-secondary-container: rgb(var(--m3-scheme-on-secondary-container));
68
+ --color-secondary-fixed: rgb(var(--m3-scheme-secondary-fixed));
69
+ --color-secondary-fixed-dim: rgb(var(--m3-scheme-secondary-fixed-dim));
70
+ --color-on-secondary-fixed: rgb(var(--m3-scheme-on-secondary-fixed));
71
+ --color-on-secondary-fixed-variant: rgb(var(--m3-scheme-on-secondary-fixed-variant));
72
+ --color-tertiary: rgb(var(--m3-scheme-tertiary));
73
+ --color-tertiary-dim: rgb(var(--m3-scheme-tertiary-dim));
74
+ --color-on-tertiary: rgb(var(--m3-scheme-on-tertiary));
75
+ --color-tertiary-container: rgb(var(--m3-scheme-tertiary-container));
76
+ --color-on-tertiary-container: rgb(var(--m3-scheme-on-tertiary-container));
77
+ --color-tertiary-fixed: rgb(var(--m3-scheme-tertiary-fixed));
78
+ --color-tertiary-fixed-dim: rgb(var(--m3-scheme-tertiary-fixed-dim));
79
+ --color-on-tertiary-fixed: rgb(var(--m3-scheme-on-tertiary-fixed));
80
+ --color-on-tertiary-fixed-variant: rgb(var(--m3-scheme-on-tertiary-fixed-variant));
81
+ --color-error: rgb(var(--m3-scheme-error));
82
+ --color-error-dim: rgb(var(--m3-scheme-error-dim));
83
+ --color-on-error: rgb(var(--m3-scheme-on-error));
84
+ --color-error-container: rgb(var(--m3-scheme-error-container));
85
+ --color-on-error-container: rgb(var(--m3-scheme-on-error-container));
86
+ --color-shadow: rgb(var(--m3-scheme-shadow));
87
+ --color-scrim: rgb(var(--m3-scheme-scrim));
88
+ --color-on-on-primary: rgb(var(--m3-scheme-on-on-primary));
89
+ --color-primary-container-subtle: rgb(var(--m3-scheme-primary-container-subtle));
90
+ --color-on-primary-container-subtle: rgb(var(--m3-scheme-on-primary-container-subtle));
91
+ --color-tertiary-container-subtle: rgb(var(--m3-scheme-tertiary-container-subtle));
92
+ --color-on-tertiary-container-subtle: rgb(var(--m3-scheme-on-tertiary-container-subtle));
93
+ --color-error-container-subtle: rgb(var(--m3-scheme-error-container-subtle));
94
+ --color-on-error-container-subtle: rgb(var(--m3-scheme-on-error-container-subtle));
95
+ }
96
+
97
+ @utility transition-fast-spatial {
98
+ transition-timing-function: var(--m3-util-timing-function-fast-spatial);
99
+ transition-duration: var(--m3-util-duration-fast-spatial);
100
+ }
101
+ @utility transition-spatial {
102
+ transition-timing-function: var(--m3-util-timing-function-spatial);
103
+ transition-duration: var(--m3-util-duration-spatial);
104
+ }
105
+ @utility transition-slow-spatial {
106
+ transition-timing-function: var(--m3-util-timing-function-slow-spatial);
107
+ transition-duration: var(--m3-util-duration-slow-spatial);
108
+ }
109
+ @utility transition-fast {
110
+ transition-timing-function: var(--m3-util-timing-function-fast);
111
+ transition-duration: var(--m3-util-duration-fast);
112
+ }
113
+ @utility transition-slow {
114
+ transition-timing-function: var(--m3-util-timing-function-slow);
115
+ transition-duration: var(--m3-util-duration-slow);
116
+ }
117
+
118
+ @utility m3-font-display-large {
119
+ --: "";
120
+ }
121
+ @utility m3-font-display-medium {
122
+ --: "";
123
+ }
124
+ @utility m3-font-display-small {
125
+ --: "";
126
+ }
127
+ @utility m3-font-headline-large {
128
+ --: "";
129
+ }
130
+ @utility m3-font-headline-medium {
131
+ --: "";
132
+ }
133
+ @utility m3-font-headline-small {
134
+ --: "";
135
+ }
136
+ @utility m3-font-title-large {
137
+ --: "";
138
+ }
139
+ @utility m3-font-title-medium {
140
+ --: "";
141
+ }
142
+ @utility m3-font-title-small {
143
+ --: "";
144
+ }
145
+ @utility m3-font-label-large {
146
+ --: "";
147
+ }
148
+ @utility m3-font-label-medium {
149
+ --: "";
150
+ }
151
+ @utility m3-font-label-small {
152
+ --: "";
153
+ }
154
+ @utility m3-font-body-large {
155
+ --: "";
156
+ }
157
+ @utility m3-font-body-medium {
158
+ --: "";
159
+ }
160
+ @utility m3-font-body-small {
161
+ --: "";
162
+ }
@@ -59,7 +59,7 @@
59
59
  width: 6rem;
60
60
  }
61
61
  @media (100rem <= width) {
62
- /* Expanded */
62
+ /* Extra large: expanded */
63
63
  flex-direction: column;
64
64
  padding-block: 1.25rem;
65
65
  min-width: 13.75rem;
@@ -273,7 +273,7 @@
273
273
  }
274
274
  }
275
275
  @media (100rem <= width) {
276
- /* Expanded */
276
+ /* Extra large: expanded */
277
277
  height: 3.5rem;
278
278
  padding-inline: 1.25rem;
279
279
  font-size: var(--m3-font-label-large-size, 0.875rem);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "m3-svelte",
3
- "version": "5.2.6",
3
+ "version": "5.3.0",
4
4
  "license": "Apache-2.0 OR GPL-3.0-only",
5
5
  "repository": "KTibow/m3-svelte",
6
6
  "author": {
@@ -26,6 +26,9 @@
26
26
  },
27
27
  "./misc/recommended-styles.css": {
28
28
  "import": "./package/misc/recommended-styles.css"
29
+ },
30
+ "./misc/tailwind-styles.css": {
31
+ "import": "./package/misc/tailwind-styles.css"
29
32
  }
30
33
  },
31
34
  "dependencies": {
@@ -74,6 +77,6 @@
74
77
  "preview": "vite preview",
75
78
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json && eslint",
76
79
  "format": "prettier --write .",
77
- "lint": "prettier --check . && eslint ."
80
+ "lint": "eslint ."
78
81
  }
79
82
  }