m3-svelte 5.2.0 → 5.2.2
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/forms/DateField.svelte +2 -2
- package/package/forms/DateFieldOutlined.svelte +3 -2
- package/package/forms/TextField.svelte +5 -2
- package/package/forms/TextFieldMultiline.svelte +5 -2
- package/package/forms/TextFieldOutlined.svelte +7 -6
- package/package/forms/TextFieldOutlinedMultiline.svelte +6 -5
- package/package/misc/Layer.svelte +177 -13
- package/package.json +1 -1
- package/package/misc/_ripple.svelte +0 -179
- package/package/misc/_ripple.svelte.d.ts +0 -3
- package/package/misc/_ripplesimple.svelte +0 -33
- package/package/misc/_ripplesimple.svelte.d.ts +0 -6
|
@@ -93,7 +93,7 @@ opacity: ${Math.min(t * 3, 1)};`,
|
|
|
93
93
|
}
|
|
94
94
|
.m3-container {
|
|
95
95
|
position: relative;
|
|
96
|
-
height: 3.5rem;
|
|
96
|
+
height: calc(3.5rem + var(--m3-util-density-term));
|
|
97
97
|
min-width: 15rem;
|
|
98
98
|
background-color: rgb(var(--m3-scheme-surface-container-highest));
|
|
99
99
|
border-radius: var(--m3-datefield-shape) var(--m3-datefield-shape) 0 0;
|
|
@@ -106,7 +106,7 @@ opacity: ${Math.min(t * 3, 1)};`,
|
|
|
106
106
|
height: 100%;
|
|
107
107
|
border: none;
|
|
108
108
|
outline: none;
|
|
109
|
-
padding:
|
|
109
|
+
padding: 1rem 1rem 0rem 1rem;
|
|
110
110
|
background-color: transparent;
|
|
111
111
|
color: rgb(var(--m3-scheme-on-surface));
|
|
112
112
|
}
|
|
@@ -99,7 +99,7 @@ opacity: ${Math.min(t * 3, 1)};`,
|
|
|
99
99
|
.m3-container {
|
|
100
100
|
display: inline-flex;
|
|
101
101
|
position: relative;
|
|
102
|
-
height: 3.5rem;
|
|
102
|
+
height: calc(3.5rem + var(--m3-util-density-term));
|
|
103
103
|
min-width: 15rem;
|
|
104
104
|
}
|
|
105
105
|
input {
|
|
@@ -117,7 +117,8 @@ opacity: ${Math.min(t * 3, 1)};`,
|
|
|
117
117
|
label {
|
|
118
118
|
position: absolute;
|
|
119
119
|
left: 0.75rem;
|
|
120
|
-
top:
|
|
120
|
+
top: 0;
|
|
121
|
+
translate: 0 -50%;
|
|
121
122
|
color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
|
|
122
123
|
background-color: var(--m3-util-background, rgb(var(--m3-scheme-surface)));
|
|
123
124
|
padding: 0 0.25rem;
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
display: inline-flex;
|
|
70
70
|
position: relative;
|
|
71
71
|
align-items: center;
|
|
72
|
-
height: 3.5rem;
|
|
72
|
+
height: calc(3.5rem + var(--m3-util-density-term));
|
|
73
73
|
min-width: 15rem;
|
|
74
74
|
}
|
|
75
75
|
input {
|
|
@@ -87,7 +87,8 @@
|
|
|
87
87
|
label {
|
|
88
88
|
position: absolute;
|
|
89
89
|
left: 1rem;
|
|
90
|
-
top:
|
|
90
|
+
top: 50%;
|
|
91
|
+
translate: 0 -50%;
|
|
91
92
|
color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
|
|
92
93
|
&:is(input:hover ~ label) {
|
|
93
94
|
color: rgb(var(--error, var(--m3-scheme-on-surface)));
|
|
@@ -100,6 +101,7 @@
|
|
|
100
101
|
}
|
|
101
102
|
&:is(input:focus ~ label, input:not(:placeholder-shown) ~ label) {
|
|
102
103
|
top: 0.5rem;
|
|
104
|
+
translate: 0 0;
|
|
103
105
|
font-size: var(--m3-font-body-small-size, 0.75rem);
|
|
104
106
|
line-height: var(--m3-font-body-small-height, 1.333);
|
|
105
107
|
letter-spacing: var(--m3-font-body-small-tracking, 0.025rem);
|
|
@@ -108,6 +110,7 @@
|
|
|
108
110
|
transition:
|
|
109
111
|
color 100ms,
|
|
110
112
|
top 100ms,
|
|
113
|
+
translate 100ms,
|
|
111
114
|
font-size 300ms,
|
|
112
115
|
line-height 300ms,
|
|
113
116
|
letter-spacing 300ms;
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
display: inline-flex;
|
|
64
64
|
position: relative;
|
|
65
65
|
align-items: center;
|
|
66
|
-
min-height: 5rem;
|
|
66
|
+
min-height: calc(5rem + var(--m3-util-density-term));
|
|
67
67
|
min-width: 15rem;
|
|
68
68
|
}
|
|
69
69
|
textarea {
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
label {
|
|
83
83
|
position: absolute;
|
|
84
84
|
left: 1rem;
|
|
85
|
-
top:
|
|
85
|
+
top: 50%;
|
|
86
|
+
translate: 0 -50%;
|
|
86
87
|
color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
|
|
87
88
|
&:is(textarea:hover ~ label) {
|
|
88
89
|
color: rgb(var(--error, var(--m3-scheme-on-surface)));
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
}
|
|
96
97
|
&:is(textarea:focus ~ label, textarea:not(:placeholder-shown) ~ label) {
|
|
97
98
|
top: 0.5rem;
|
|
99
|
+
translate: 0 0;
|
|
98
100
|
font-size: var(--m3-font-body-small-size, 0.75rem);
|
|
99
101
|
line-height: var(--m3-font-body-small-height, 1.333);
|
|
100
102
|
letter-spacing: var(--m3-font-body-small-tracking, 0.025rem);
|
|
@@ -103,6 +105,7 @@
|
|
|
103
105
|
transition:
|
|
104
106
|
color 100ms,
|
|
105
107
|
top 100ms,
|
|
108
|
+
translate 100ms,
|
|
106
109
|
font-size 300ms,
|
|
107
110
|
line-height 300ms,
|
|
108
111
|
letter-spacing 300ms;
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
display: inline-flex;
|
|
73
73
|
position: relative;
|
|
74
74
|
align-items: center;
|
|
75
|
-
height: 3.5rem;
|
|
75
|
+
height: calc(3.5rem + var(--m3-util-density-term));
|
|
76
76
|
min-width: 15rem;
|
|
77
77
|
}
|
|
78
78
|
input {
|
|
@@ -90,21 +90,22 @@
|
|
|
90
90
|
label {
|
|
91
91
|
position: absolute;
|
|
92
92
|
left: 0.75rem;
|
|
93
|
-
top:
|
|
93
|
+
top: 50%;
|
|
94
|
+
translate: 0 -50%;
|
|
94
95
|
color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
|
|
95
96
|
background-color: var(--m3-util-background, rgb(var(--m3-scheme-surface)));
|
|
96
97
|
padding: 0 0.25rem;
|
|
97
98
|
&:is(input:hover ~ label) {
|
|
98
99
|
color: rgb(var(--error, var(--m3-scheme-on-surface)));
|
|
99
100
|
}
|
|
100
|
-
&:is(input:focus ~ label) {
|
|
101
|
+
&:is(input:enabled:focus ~ label) {
|
|
101
102
|
color: rgb(var(--error, var(--m3-scheme-primary)));
|
|
102
103
|
}
|
|
103
104
|
&:is(input:disabled ~ label) {
|
|
104
105
|
color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
105
106
|
}
|
|
106
107
|
&:is(input:focus ~ label, input:not(:placeholder-shown) ~ label) {
|
|
107
|
-
top:
|
|
108
|
+
top: 0;
|
|
108
109
|
font-size: var(--m3-font-body-small-size, 0.75rem);
|
|
109
110
|
line-height: var(--m3-font-body-small-height, 1.333);
|
|
110
111
|
letter-spacing: var(--m3-font-body-small-tracking, 0.025rem);
|
|
@@ -124,10 +125,10 @@
|
|
|
124
125
|
border-radius: var(--m3-textfield-outlined-shape);
|
|
125
126
|
pointer-events: none;
|
|
126
127
|
transition: all 100ms;
|
|
127
|
-
&:is(input:hover ~ .layer) {
|
|
128
|
+
&:is(input:enabled:hover ~ .layer) {
|
|
128
129
|
border-color: rgb(var(--error, var(--m3-scheme-on-surface)));
|
|
129
130
|
}
|
|
130
|
-
&:is(input:focus ~ .layer) {
|
|
131
|
+
&:is(input:enabled:focus ~ .layer) {
|
|
131
132
|
border-color: rgb(var(--error, var(--m3-scheme-primary)));
|
|
132
133
|
border-width: 0.125rem;
|
|
133
134
|
}
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
display: inline-flex;
|
|
68
68
|
position: relative;
|
|
69
69
|
align-items: center;
|
|
70
|
-
min-height: 5rem;
|
|
70
|
+
min-height: calc(5rem + var(--m3-util-density-term));
|
|
71
71
|
min-width: 15rem;
|
|
72
72
|
}
|
|
73
73
|
textarea {
|
|
@@ -86,7 +86,8 @@
|
|
|
86
86
|
label {
|
|
87
87
|
position: absolute;
|
|
88
88
|
left: 0.75rem;
|
|
89
|
-
top:
|
|
89
|
+
top: 50%;
|
|
90
|
+
translate: 0 -50%;
|
|
90
91
|
color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
|
|
91
92
|
background-color: var(--m3-util-background, rgb(var(--m3-scheme-surface)));
|
|
92
93
|
padding: 0 0.25rem;
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
color: rgb(var(--m3-scheme-on-surface) / 0.38);
|
|
101
102
|
}
|
|
102
103
|
&:is(textarea:focus ~ label, textarea:not(:placeholder-shown) ~ label) {
|
|
103
|
-
top:
|
|
104
|
+
top: 0;
|
|
104
105
|
font-size: var(--m3-font-body-small-size, 0.75rem);
|
|
105
106
|
line-height: var(--m3-font-body-small-height, 1.333);
|
|
106
107
|
letter-spacing: var(--m3-font-body-small-tracking, 0.025rem);
|
|
@@ -120,10 +121,10 @@
|
|
|
120
121
|
border-radius: var(--m3-textfield-outlined-shape);
|
|
121
122
|
pointer-events: none;
|
|
122
123
|
transition: all 100ms;
|
|
123
|
-
&:is(textarea:hover ~ .layer) {
|
|
124
|
+
&:is(textarea:enabled:hover ~ .layer) {
|
|
124
125
|
border-color: rgb(var(--error, var(--m3-scheme-on-surface)));
|
|
125
126
|
}
|
|
126
|
-
&:is(textarea:focus ~ .layer) {
|
|
127
|
+
&:is(textarea:enabled:focus ~ .layer) {
|
|
127
128
|
border-color: rgb(var(--error, var(--m3-scheme-primary)));
|
|
128
129
|
border-width: 0.125rem;
|
|
129
130
|
}
|
|
@@ -1,17 +1,181 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
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
|
-
|
|
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
|
-
<
|
|
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>
|
package/package.json
CHANGED
|
@@ -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,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>
|