m3-svelte 5.2.1 → 5.2.3

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.
@@ -38,7 +38,8 @@
38
38
  {/if}
39
39
  <div class="body">
40
40
  {#if overline}
41
- <p class="overline m3-font-label-small">{overline}</p>
41
+ <!-- Renamed to not conflict with Tailwind -->
42
+ <p class="overline- m3-font-label-small">{overline}</p>
42
43
  {/if}
43
44
  <p class="headline m3-font-body-large">{headline}</p>
44
45
  {#if supporting}
@@ -134,7 +135,7 @@
134
135
  margin: 0;
135
136
  }
136
137
  .supporting,
137
- .overline {
138
+ .overline- {
138
139
  color: rgb(var(--m3-scheme-on-surface-variant));
139
140
  }
140
141
  .headline {
@@ -35,6 +35,7 @@
35
35
  align-items: center;
36
36
  height: calc(3rem + var(--m3-util-density-term));
37
37
  padding: 0 0.75rem;
38
+ gap: 0.75rem;
38
39
  white-space: nowrap;
39
40
 
40
41
  border: none;
@@ -48,7 +49,6 @@
48
49
  .icon {
49
50
  width: 1.5rem;
50
51
  height: 1.5rem;
51
- margin-right: 0.75rem;
52
52
  }
53
53
  .icon > :global(svg) {
54
54
  width: 1.5rem;
@@ -112,17 +112,17 @@ opacity: ${Math.min(t * 3, 1)};`,
112
112
  }
113
113
  label {
114
114
  position: absolute;
115
- left: 1rem;
115
+ inset-inline-start: 1rem;
116
116
  top: 0.5rem;
117
117
  color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
118
118
  pointer-events: none;
119
119
  }
120
120
  input {
121
- padding-left: 0.875rem;
121
+ padding-inline-start: 0.875rem;
122
122
  }
123
123
  @supports (-moz-appearance: none) {
124
124
  input {
125
- padding-left: 0.75rem;
125
+ padding-inline-start: 0.75rem;
126
126
  }
127
127
  }
128
128
 
@@ -132,7 +132,7 @@ opacity: ${Math.min(t * 3, 1)};`,
132
132
  padding-left: 0.75rem;
133
133
  padding-right: 0.75rem;
134
134
  height: 100%;
135
- right: 0;
135
+ inset-inline-end: 0;
136
136
 
137
137
  align-items: center;
138
138
  justify-content: center;
@@ -175,6 +175,9 @@ opacity: ${Math.min(t * 3, 1)};`,
175
175
  }
176
176
  .has-js input {
177
177
  clip-path: inset(0 3.5rem 0 0);
178
+ &:is(:global([dir="rtl"]) input) {
179
+ clip-path: inset(0 0 0 3.5rem);
180
+ }
178
181
  }
179
182
  }
180
183
  </style>
@@ -160,15 +160,15 @@
160
160
  width: var(--icon-size);
161
161
  height: var(--icon-size);
162
162
  top: 50%;
163
- left: 0.25rem;
163
+ inset-inline-start: 0.25rem;
164
164
  translate: 0 -50%;
165
165
  pointer-events: none;
166
166
  color: rgb(var(--m3-scheme-secondary-container));
167
167
  }
168
168
 
169
169
  .m3-container :global(.leading.pop) {
170
- left: var(--percent);
171
- margin-left: 0.625rem;
170
+ inset-inline-start: var(--percent);
171
+ margin-inline-start: 0.625rem;
172
172
  color: rgb(var(--m3-scheme-primary));
173
173
  }
174
174
 
@@ -177,15 +177,15 @@
177
177
  width: var(--icon-size);
178
178
  height: var(--icon-size);
179
179
  top: 50%;
180
- right: 0.25rem;
180
+ inset-inline-end: 0.25rem;
181
181
  translate: 0 -50%;
182
182
  pointer-events: none;
183
183
  color: rgb(var(--m3-scheme-primary));
184
184
  }
185
185
 
186
186
  .m3-container :global(.trailing.pop) {
187
- right: abs(100% - var(--percent));
188
- margin-right: 0.625rem;
187
+ inset-inline-end: abs(100% - var(--percent));
188
+ margin-inline-end: 0.625rem;
189
189
  color: rgb(var(--m3-scheme-secondary-container));
190
190
  }
191
191
 
@@ -195,8 +195,8 @@
195
195
  height: 4px;
196
196
  border-radius: var(--m3-util-rounding-full);
197
197
  top: 50%;
198
- right: 2px;
199
- translate: -50% -50%;
198
+ inset-inline-end: 4px;
199
+ translate: 0 -50%;
200
200
  background-color: rgb(var(--m3-scheme-primary));
201
201
  pointer-events: none;
202
202
  &.hidden {
@@ -206,8 +206,7 @@
206
206
 
207
207
  input {
208
208
  position: absolute;
209
- left: -0.5rem;
210
- right: -0.5rem;
209
+ inset-inline: -0.5rem;
211
210
  width: calc(100% + 1rem);
212
211
  height: 100%;
213
212
 
@@ -221,7 +220,7 @@
221
220
  .track::before {
222
221
  position: absolute;
223
222
  content: " ";
224
- left: 0;
223
+ inset-inline-start: 0;
225
224
  top: 50%;
226
225
  translate: 0 -50%;
227
226
  width: calc(var(--percent) - 0.375rem);
@@ -238,7 +237,7 @@
238
237
  .track::after {
239
238
  position: absolute;
240
239
  content: " ";
241
- right: 0;
240
+ inset-inline-end: 0;
242
241
  top: 50%;
243
242
  translate: 0 -50%;
244
243
  width: calc(100% - var(--percent) - 0.375rem);
@@ -258,8 +257,11 @@
258
257
  height: 4px;
259
258
  border-radius: var(--m3-util-rounding-full);
260
259
  top: 50%;
261
- left: calc(50% + (100% - 0.75rem) * var(--x));
260
+ inset-inline-start: calc(50% + (100% - 0.75rem) * var(--x));
262
261
  translate: -50% -50%;
262
+ &:is(:global([dir="rtl"] .tick)) {
263
+ translate: 50% -50%;
264
+ }
263
265
  background-color: rgb(var(--m3-scheme-secondary-container));
264
266
  pointer-events: none;
265
267
  }
@@ -282,8 +284,11 @@
282
284
 
283
285
  .handle {
284
286
  position: absolute;
285
- left: var(--percent);
287
+ inset-inline-start: var(--percent);
286
288
  translate: -50% 0;
289
+ &:is(:global([dir="rtl"]) .handle) {
290
+ translate: 50% 0;
291
+ }
287
292
  width: 0.25rem;
288
293
  height: var(--handle-height);
289
294
  border-radius: 1.25rem;
@@ -305,9 +310,12 @@
305
310
  padding: 0.75rem 1rem;
306
311
  border-radius: var(--m3-slider-handle-shape);
307
312
 
308
- left: var(--percent);
313
+ inset-inline-start: var(--percent);
309
314
  bottom: calc(var(--handle-height) + 4px);
310
315
  translate: -50% 0;
316
+ &:is(:global([dir="rtl"]) .value) {
317
+ translate: 50% 0;
318
+ }
311
319
 
312
320
  opacity: 0;
313
321
  pointer-events: none;
@@ -86,7 +86,7 @@
86
86
  }
87
87
  label {
88
88
  position: absolute;
89
- left: 1rem;
89
+ inset-inline-start: 1rem;
90
90
  top: 50%;
91
91
  translate: 0 -50%;
92
92
  color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
@@ -144,14 +144,13 @@
144
144
  }
145
145
  .m3-container > :global(.leading) {
146
146
  position: relative;
147
- margin-left: 0.75rem;
147
+ margin-inline-start: 0.75rem;
148
148
  }
149
149
  .trailing {
150
150
  position: absolute;
151
- padding-left: 0.75rem;
152
- padding-right: 0.75rem;
151
+ padding-inline: 0.75rem;
153
152
  height: 100%;
154
- right: 0;
153
+ inset-inline-end: 0;
155
154
 
156
155
  display: flex;
157
156
  align-items: center;
@@ -171,13 +170,13 @@
171
170
  }
172
171
 
173
172
  .leading-icon > input {
174
- padding-left: 3.25rem;
173
+ padding-inline-start: 3.25rem;
175
174
  }
176
175
  .leading-icon > label {
177
- left: 3.25rem;
176
+ inset-inline-start: 3.25rem;
178
177
  }
179
178
  .trailing-icon > input {
180
- padding-right: 3.25rem;
179
+ padding-inline-end: 3.25rem;
181
180
  }
182
181
  .error {
183
182
  --error: var(--m3-scheme-error);
@@ -1,17 +1,181 @@
1
1
  <script lang="ts">
2
- import Ripple from "./_ripple.svelte";
3
- import RippleSimple from "./_ripplesimple.svelte";
4
-
5
- let ripple = $state(RippleSimple);
6
- if (
7
- // @ts-expect-error about M3_SVELTE_NO_RIPPLE
8
- typeof M3_SVELTE_NO_RIPPLE == "undefined" &&
9
- (typeof window == "undefined" || !window.matchMedia("(prefers-reduced-motion: reduce)").matches)
10
- ) {
11
- ripple = Ripple;
12
- }
2
+ let cancelRipples: (() => void)[] = $state([]);
3
+
4
+ const createRipple = (node: HTMLDivElement) => {
5
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
6
+
7
+ node.classList.remove("broken");
8
+
9
+ const parent = node.parentElement!;
10
+
11
+ const ripple = (e: MouseEvent) => {
12
+ if (e.button != 0) return;
13
+ if (parent instanceof HTMLButtonElement) {
14
+ if (parent.disabled) return;
15
+ }
16
+ if (parent instanceof HTMLLabelElement) {
17
+ const control = parent.control;
18
+ if (control instanceof HTMLInputElement && control.disabled) return;
19
+ }
20
+ if (parent.classList.contains("layer-container")) {
21
+ const input = parent.previousElementSibling;
22
+ if (input instanceof HTMLInputElement && input.disabled) return;
23
+ }
24
+
25
+ const rect = parent.getBoundingClientRect();
26
+ const x = e.clientX - rect.left;
27
+ const y = e.clientY - rect.top;
28
+ const size = Math.hypot(Math.max(x, rect.width - x), Math.max(y, rect.height - y)) * 2.5;
29
+ const speed = Math.max(Math.min(Math.log(size) * 50, 600), 200);
30
+
31
+ const gradient = document.createElementNS("http://www.w3.org/2000/svg", "radialGradient");
32
+ gradient.id = `ripple-${Date.now()}`;
33
+
34
+ const stops = [
35
+ { offset: "0%", opacity: "0.12" },
36
+ { offset: "70%", opacity: "0.12" },
37
+ { offset: "100%", opacity: "0" },
38
+ ];
39
+
40
+ stops.forEach(({ offset, opacity }) => {
41
+ const stop = document.createElementNS("http://www.w3.org/2000/svg", "stop");
42
+ stop.setAttribute("offset", offset);
43
+ stop.setAttribute("stop-color", "currentColor");
44
+ stop.setAttribute("stop-opacity", opacity);
45
+ gradient.appendChild(stop);
46
+ });
47
+
48
+ const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
49
+ circle.setAttribute("cx", `${size / 2}`);
50
+ circle.setAttribute("cy", `${size / 2}`);
51
+ circle.setAttribute("r", "0");
52
+ circle.setAttribute("fill", `url(#${gradient.id})`);
53
+
54
+ const expand = document.createElementNS("http://www.w3.org/2000/svg", "animate");
55
+ expand.setAttribute("attributeName", "r");
56
+ expand.setAttribute("from", "0");
57
+ expand.setAttribute("to", `${size / 2}`);
58
+ expand.setAttribute("dur", `${speed}ms`);
59
+ expand.setAttribute("fill", "freeze");
60
+ expand.setAttribute("calcMode", "spline");
61
+ expand.setAttribute("keySplines", "0.4 0, 0.2 1");
62
+
63
+ circle.appendChild(expand);
64
+
65
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
66
+ svg.style.cssText = `
67
+ position: absolute;
68
+ left: ${x - size / 2}px;
69
+ top: ${y - size / 2}px;
70
+ width: ${size}px;
71
+ height: ${size}px;
72
+ pointer-events: none;
73
+ overflow: visible;
74
+ `;
75
+ svg.appendChild(gradient);
76
+ svg.appendChild(circle);
77
+
78
+ const ua = navigator.userAgent;
79
+ const isFirefox = ua.includes("Firefox");
80
+ const isTrulySafari = !ua.includes("Chrome") && ua.includes("Safari");
81
+ if (!isFirefox && !isTrulySafari && size > 100) {
82
+ const filter = document.createElementNS("http://www.w3.org/2000/svg", "filter");
83
+ filter.id = `noise-${Date.now()}`;
13
84
 
14
- const Component = $derived(ripple);
85
+ const turb = document.createElementNS("http://www.w3.org/2000/svg", "feTurbulence");
86
+ turb.setAttribute("type", "fractalNoise");
87
+ turb.setAttribute("baseFrequency", "0.6");
88
+ turb.setAttribute("seed", Math.random().toString());
89
+
90
+ const blur = document.createElementNS("http://www.w3.org/2000/svg", "feDisplacementMap");
91
+ blur.setAttribute("in", "SourceGraphic");
92
+ blur.setAttribute("in2", "turbulence");
93
+ blur.setAttribute("scale", `${size ** 2 * 0.0002}`);
94
+ blur.setAttribute("xChannelSelector", "R");
95
+ blur.setAttribute("yChannelSelector", "B");
96
+
97
+ filter.appendChild(turb);
98
+ filter.appendChild(blur);
99
+
100
+ circle.setAttribute("filter", `url(#${filter.id})`);
101
+ svg.appendChild(filter);
102
+ }
103
+
104
+ node.appendChild(svg);
105
+
106
+ cancelRipples.push(() => {
107
+ const fade = document.createElementNS("http://www.w3.org/2000/svg", "animate");
108
+ fade.setAttribute("attributeName", "opacity");
109
+ fade.setAttribute("from", "1");
110
+ fade.setAttribute("to", "0");
111
+ fade.setAttribute("dur", "800ms");
112
+ fade.setAttribute("fill", "freeze");
113
+ fade.setAttribute("calcMode", "spline");
114
+ fade.setAttribute("keySplines", "0.4 0, 0.2 1");
115
+ circle.appendChild(fade);
116
+ fade.beginElement();
117
+ setTimeout(() => svg.remove(), 800);
118
+ });
119
+ };
120
+
121
+ parent.addEventListener("pointerdown", ripple);
122
+
123
+ return {
124
+ destroy() {
125
+ parent.removeEventListener("pointerdown", ripple);
126
+ },
127
+ };
128
+ };
15
129
  </script>
16
130
 
17
- <Component />
131
+ <svelte:window
132
+ onpointerup={() => {
133
+ cancelRipples.forEach((cancel) => cancel());
134
+ cancelRipples = [];
135
+ }}
136
+ ondragend={() => {
137
+ cancelRipples.forEach((cancel) => cancel());
138
+ cancelRipples = [];
139
+ }}
140
+ />
141
+
142
+ <div class="ripple-container broken" use:createRipple></div>
143
+ <div class="tint"></div>
144
+
145
+ <style>
146
+ .ripple-container {
147
+ position: absolute;
148
+ inset: 0;
149
+ border-radius: inherit;
150
+ pointer-events: none;
151
+
152
+ overflow: hidden;
153
+ }
154
+ .tint {
155
+ position: absolute;
156
+ inset: 0;
157
+ border-radius: inherit;
158
+ pointer-events: none;
159
+
160
+ background-color: currentColor;
161
+ opacity: 0;
162
+ transition: opacity var(--m3-util-easing-fast);
163
+
164
+ &:not(
165
+ :global(input:disabled + label) > .tint,
166
+ :global(input:disabled + .layer-container) > .tint,
167
+ :global(:disabled) > .tint
168
+ ) {
169
+ @media (hover: hover) {
170
+ &:is(:global(:hover) > .tint) {
171
+ opacity: 0.08;
172
+ }
173
+ }
174
+ &:is(:global(input:focus-visible + label) > .tint),
175
+ &:is(:global(:focus-visible) > .tint),
176
+ &:is(.ripple-container.broken + .tint):is(:global(:active) > .tint) {
177
+ opacity: 0.12;
178
+ }
179
+ }
180
+ }
181
+ </style>
@@ -99,19 +99,19 @@
99
99
  transition: var(--m3-util-easing-fast-spatial);
100
100
  }
101
101
  input:checked:nth-of-type(1) ~ .bar {
102
- left: 0;
102
+ inset-inline-start: 0;
103
103
  }
104
104
  input:checked:nth-of-type(2) ~ .bar {
105
- left: calc(100% / var(--items));
105
+ inset-inline-start: calc(100% / var(--items));
106
106
  }
107
107
  input:checked:nth-of-type(3) ~ .bar {
108
- left: calc(100% / var(--items) * 2);
108
+ inset-inline-start: calc(100% / var(--items) * 2);
109
109
  }
110
110
  input:checked:nth-of-type(4) ~ .bar {
111
- left: calc(100% / var(--items) * 3);
111
+ inset-inline-start: calc(100% / var(--items) * 3);
112
112
  }
113
113
  input:checked:nth-of-type(5) ~ .bar {
114
- left: calc(100% / var(--items) * 4);
114
+ inset-inline-start: calc(100% / var(--items) * 4);
115
115
  }
116
116
  input:checked:nth-of-type(-n + 5) ~ .bar {
117
117
  height: 0.125rem;
@@ -135,8 +135,11 @@
135
135
  width: 3rem;
136
136
  height: 0.1875rem;
137
137
  border-radius: 0.1875rem 0.1875rem 0 0;
138
- margin-left: calc(50% / var(--items));
139
- transform: translateX(-50%);
138
+ margin-inline-start: calc(50% / var(--items));
139
+ translate: -50% 0;
140
+ &:is(:global([dir="rtl"]) .bar) {
141
+ translate: 50% 0;
142
+ }
140
143
  }
141
144
 
142
145
  .bar {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "m3-svelte",
3
- "version": "5.2.1",
3
+ "version": "5.2.3",
4
4
  "license": "Apache-2.0 OR GPL-3.0-only",
5
5
  "repository": "KTibow/m3-svelte",
6
6
  "author": {
@@ -30,17 +30,17 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@iconify/types": "^2.0.0",
33
- "@ktibow/iconset-material-symbols": "^0.0.1752989765",
34
- "@ktibow/material-color-utilities-nightly": "^0.3.11753062248503",
35
- "svelte": "^5.37.3"
33
+ "@ktibow/iconset-material-symbols": "^0.0.1754804347",
34
+ "@ktibow/material-color-utilities-nightly": "^0.3.11754876552597",
35
+ "svelte": "^5.38.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@eslint/compat": "^1.3.1",
39
- "@eslint/js": "^9.31.0",
40
- "@sveltejs/adapter-static": "^3.0.8",
41
- "@sveltejs/kit": "^2.25.1",
42
- "@sveltejs/package": "^2.4.0",
43
- "@sveltejs/vite-plugin-svelte": "^6.1.0",
38
+ "@eslint/compat": "^1.3.2",
39
+ "@eslint/js": "^9.33.0",
40
+ "@sveltejs/adapter-static": "^3.0.9",
41
+ "@sveltejs/kit": "^2.27.3",
42
+ "@sveltejs/package": "^2.4.1",
43
+ "@sveltejs/vite-plugin-svelte": "^6.1.1",
44
44
  "eslint": "^9.27.0",
45
45
  "eslint-config-prettier": "^10.1.8",
46
46
  "eslint-plugin-svelte": "^3.11.0",
@@ -49,11 +49,11 @@
49
49
  "prettier": "^3.6.2",
50
50
  "prettier-plugin-svelte": "^3.4.0",
51
51
  "publint": "^0.3.12",
52
- "svelte-check": "^4.3.0",
52
+ "svelte-check": "^4.3.1",
53
53
  "svelte-highlight": "^7.8.3",
54
- "typescript": "^5.8.3",
55
- "typescript-eslint": "^8.38.0",
56
- "vite": "^7.0.5"
54
+ "typescript": "^5.9.2",
55
+ "typescript-eslint": "^8.39.1",
56
+ "vite": "^7.1.1"
57
57
  },
58
58
  "keywords": [
59
59
  "svelte",
@@ -1,179 +0,0 @@
1
- <script lang="ts">
2
- let cancelRipples: (() => void)[] = $state([]);
3
-
4
- const createRipple = (node: HTMLDivElement) => {
5
- node.classList.remove("broken");
6
-
7
- const parent = node.parentElement!;
8
-
9
- const ripple = (e: MouseEvent) => {
10
- if (e.button != 0) return;
11
- if (parent instanceof HTMLButtonElement) {
12
- if (parent.disabled) return;
13
- }
14
- if (parent instanceof HTMLLabelElement) {
15
- const control = parent.control;
16
- if (control instanceof HTMLInputElement && control.disabled) return;
17
- }
18
- if (parent.classList.contains("layer-container")) {
19
- const input = parent.previousElementSibling;
20
- if (input instanceof HTMLInputElement && input.disabled) return;
21
- }
22
-
23
- const rect = parent.getBoundingClientRect();
24
- const x = e.clientX - rect.left;
25
- const y = e.clientY - rect.top;
26
- const size = Math.hypot(Math.max(x, rect.width - x), Math.max(y, rect.height - y)) * 2.5;
27
- const speed = Math.max(Math.min(Math.log(size) * 50, 600), 200);
28
-
29
- const gradient = document.createElementNS("http://www.w3.org/2000/svg", "radialGradient");
30
- gradient.id = `ripple-${Date.now()}`;
31
-
32
- const stops = [
33
- { offset: "0%", opacity: "0.12" },
34
- { offset: "70%", opacity: "0.12" },
35
- { offset: "100%", opacity: "0" },
36
- ];
37
-
38
- stops.forEach(({ offset, opacity }) => {
39
- const stop = document.createElementNS("http://www.w3.org/2000/svg", "stop");
40
- stop.setAttribute("offset", offset);
41
- stop.setAttribute("stop-color", "currentColor");
42
- stop.setAttribute("stop-opacity", opacity);
43
- gradient.appendChild(stop);
44
- });
45
-
46
- const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
47
- circle.setAttribute("cx", `${size / 2}`);
48
- circle.setAttribute("cy", `${size / 2}`);
49
- circle.setAttribute("r", "0");
50
- circle.setAttribute("fill", `url(#${gradient.id})`);
51
-
52
- const expand = document.createElementNS("http://www.w3.org/2000/svg", "animate");
53
- expand.setAttribute("attributeName", "r");
54
- expand.setAttribute("from", "0");
55
- expand.setAttribute("to", `${size / 2}`);
56
- expand.setAttribute("dur", `${speed}ms`);
57
- expand.setAttribute("fill", "freeze");
58
- expand.setAttribute("calcMode", "spline");
59
- expand.setAttribute("keySplines", "0.4 0, 0.2 1");
60
-
61
- circle.appendChild(expand);
62
-
63
- const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
64
- svg.style.cssText = `
65
- position: absolute;
66
- left: ${x - size / 2}px;
67
- top: ${y - size / 2}px;
68
- width: ${size}px;
69
- height: ${size}px;
70
- pointer-events: none;
71
- overflow: visible;
72
- `;
73
- svg.appendChild(gradient);
74
- svg.appendChild(circle);
75
-
76
- const ua = navigator.userAgent;
77
- const isFirefox = ua.includes("Firefox");
78
- const isTrulySafari = !ua.includes("Chrome") && ua.includes("Safari");
79
- if (!isFirefox && !isTrulySafari && size > 100) {
80
- const filter = document.createElementNS("http://www.w3.org/2000/svg", "filter");
81
- filter.id = `noise-${Date.now()}`;
82
-
83
- const turb = document.createElementNS("http://www.w3.org/2000/svg", "feTurbulence");
84
- turb.setAttribute("type", "fractalNoise");
85
- turb.setAttribute("baseFrequency", "0.6");
86
- turb.setAttribute("seed", Math.random().toString());
87
-
88
- const blur = document.createElementNS("http://www.w3.org/2000/svg", "feDisplacementMap");
89
- blur.setAttribute("in", "SourceGraphic");
90
- blur.setAttribute("in2", "turbulence");
91
- blur.setAttribute("scale", `${size ** 2 * 0.0002}`);
92
- blur.setAttribute("xChannelSelector", "R");
93
- blur.setAttribute("yChannelSelector", "B");
94
-
95
- filter.appendChild(turb);
96
- filter.appendChild(blur);
97
-
98
- circle.setAttribute("filter", `url(#${filter.id})`);
99
- svg.appendChild(filter);
100
- }
101
-
102
- node.appendChild(svg);
103
-
104
- cancelRipples.push(() => {
105
- const fade = document.createElementNS("http://www.w3.org/2000/svg", "animate");
106
- fade.setAttribute("attributeName", "opacity");
107
- fade.setAttribute("from", "1");
108
- fade.setAttribute("to", "0");
109
- fade.setAttribute("dur", "800ms");
110
- fade.setAttribute("fill", "freeze");
111
- fade.setAttribute("calcMode", "spline");
112
- fade.setAttribute("keySplines", "0.4 0, 0.2 1");
113
- circle.appendChild(fade);
114
- fade.beginElement();
115
- setTimeout(() => svg.remove(), 800);
116
- });
117
- };
118
-
119
- parent.addEventListener("pointerdown", ripple);
120
-
121
- return {
122
- destroy() {
123
- parent.removeEventListener("pointerdown", ripple);
124
- },
125
- };
126
- };
127
- </script>
128
-
129
- <svelte:window
130
- onpointerup={() => {
131
- cancelRipples.forEach((cancel) => cancel());
132
- cancelRipples = [];
133
- }}
134
- ondragend={() => {
135
- cancelRipples.forEach((cancel) => cancel());
136
- cancelRipples = [];
137
- }}
138
- />
139
-
140
- <div class="ripple-container broken" use:createRipple></div>
141
- <div class="tint"></div>
142
-
143
- <style>
144
- .ripple-container {
145
- position: absolute;
146
- inset: 0;
147
- border-radius: inherit;
148
- pointer-events: none;
149
-
150
- overflow: hidden;
151
- }
152
- .tint {
153
- position: absolute;
154
- inset: 0;
155
- border-radius: inherit;
156
- pointer-events: none;
157
-
158
- background-color: currentColor;
159
- opacity: 0;
160
- transition: opacity var(--m3-util-easing-fast);
161
-
162
- &:not(
163
- :global(input:disabled + label) > .tint,
164
- :global(input:disabled + .layer-container) > .tint,
165
- :global(:disabled) > .tint
166
- ) {
167
- @media (hover: hover) {
168
- &:is(:global(:hover) > .tint) {
169
- opacity: 0.08;
170
- }
171
- }
172
- &:is(:global(input:focus-visible + label) > .tint),
173
- &:is(:global(:focus-visible) > .tint),
174
- &:is(.ripple-container.broken + .tint):is(:global(:active) > .tint) {
175
- opacity: 0.12;
176
- }
177
- }
178
- }
179
- </style>
@@ -1,3 +0,0 @@
1
- declare const Ripple: import("svelte").Component<Record<string, never>, {}, "">;
2
- type Ripple = ReturnType<typeof Ripple>;
3
- export default Ripple;
@@ -1,33 +0,0 @@
1
- <svelte:options runes />
2
-
3
- <div class="tint"></div>
4
-
5
- <style>
6
- .tint {
7
- position: absolute;
8
- inset: 0;
9
- border-radius: inherit;
10
- pointer-events: none;
11
-
12
- background-color: currentColor;
13
- opacity: 0;
14
- transition: opacity var(--m3-util-easing-fast);
15
-
16
- &:not(
17
- :global(input:disabled + label) > .tint,
18
- :global(input:disabled + .layer-container) > .tint,
19
- :global(:disabled) > .tint
20
- ) {
21
- @media (hover: hover) {
22
- &:is(:global(:hover) > .tint) {
23
- opacity: 0.08;
24
- }
25
- }
26
- &:is(:global(input:focus-visible + label) > .tint),
27
- &:is(:global(:focus-visible) > .tint),
28
- &:is(:global(:active) > .tint) {
29
- opacity: 0.12;
30
- }
31
- }
32
- }
33
- </style>
@@ -1,6 +0,0 @@
1
- export default Ripplesimple;
2
- type Ripplesimple = {
3
- $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<Record<string, never>>): void;
5
- };
6
- declare const Ripplesimple: import("svelte").Component<Record<string, never>, {}, "">;