lapikit 0.1.9 → 0.1.11
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/dist/assets/icons/arrow-down.svelte +2 -0
- package/dist/assets/icons/arrow-down.svelte.d.ts +6 -14
- package/dist/assets/icons/arrow-up.svelte +2 -0
- package/dist/assets/icons/arrow-up.svelte.d.ts +6 -14
- package/dist/assets/icons/close-fill.svelte +2 -0
- package/dist/assets/icons/close-fill.svelte.d.ts +6 -14
- package/dist/assets/icons/loading-fill.svelte +2 -0
- package/dist/assets/icons/loading-fill.svelte.d.ts +6 -14
- package/dist/components/accordion/accordion.css +4 -4
- package/dist/components/alert/alert.css +2 -2
- package/dist/components/appbar/appbar.css +0 -1
- package/dist/components/aspect-ratio/aspect-ratio.svelte +0 -1
- package/dist/components/avatar/avatar.css +5 -5
- package/dist/components/button/button.css +163 -193
- package/dist/components/button/button.svelte +38 -31
- package/dist/components/button/button.svelte.d.ts +2 -2
- package/dist/components/button/types.d.ts +7 -5
- package/dist/components/card/card.css +62 -56
- package/dist/components/card/card.svelte +13 -1
- package/dist/components/card/types.d.ts +1 -1
- package/dist/components/chip/chip.css +111 -81
- package/dist/components/chip/chip.svelte +17 -7
- package/dist/components/chip/types.d.ts +2 -1
- package/dist/components/dialog/dialog.css +2 -2
- package/dist/components/dropdown/dropdown.css +2 -2
- package/dist/components/icon/icon.css +13 -10
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/list/list.css +144 -119
- package/dist/components/list/list.svelte +1 -3
- package/dist/components/list/modules/list-item.svelte +8 -1
- package/dist/components/list/types.d.ts +2 -5
- package/dist/components/modal/modal.css +9 -6
- package/dist/components/popover/popover.css +2 -2
- package/dist/components/toolbar/toolbar.css +3 -3
- package/dist/components/tooltip/tooltip.css +2 -2
- package/dist/internal/assets.svelte.js +2 -0
- package/dist/internal/ripple.d.ts +11 -0
- package/dist/internal/ripple.js +90 -0
- package/dist/preset.js +1 -1
- package/dist/style/animation.css +40 -0
- package/dist/style/normalize.css +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const triggerEvents = ['pointerdown', 'touchstart', 'keydown'];
|
|
2
|
+
const cancelEvents = ['mouseleave', 'dragleave', 'touchmove', 'touchcancel', 'pointerup', 'keyup'];
|
|
3
|
+
export function ripple(el, options = {}) {
|
|
4
|
+
const rippleContainer = document.createElement('div');
|
|
5
|
+
addClasses();
|
|
6
|
+
setOptions(options);
|
|
7
|
+
function addClasses(center) {
|
|
8
|
+
const shouldBeCentered = center || options.center;
|
|
9
|
+
if (!rippleContainer.classList.contains('kit-ripple--effect')) {
|
|
10
|
+
rippleContainer.classList.add('kit-ripple--effect');
|
|
11
|
+
}
|
|
12
|
+
if (!shouldBeCentered && rippleContainer.classList.contains('kit-ripple--center')) {
|
|
13
|
+
rippleContainer.classList.remove('kit-ripple--center');
|
|
14
|
+
}
|
|
15
|
+
if (shouldBeCentered) {
|
|
16
|
+
rippleContainer.classList.add('kit-ripple--center');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function setOptions(options) {
|
|
20
|
+
if (options.disabled || el.hasAttribute('aria-disabled')) {
|
|
21
|
+
rippleContainer.remove();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
el.appendChild(rippleContainer);
|
|
25
|
+
}
|
|
26
|
+
if (options.duration && options.duration < 0) {
|
|
27
|
+
options.duration = undefined;
|
|
28
|
+
}
|
|
29
|
+
if (options.color) {
|
|
30
|
+
rippleContainer.style.setProperty('--ripple-color', options.color);
|
|
31
|
+
}
|
|
32
|
+
if (options.duration) {
|
|
33
|
+
rippleContainer.style.setProperty('--ripple-duration', `${options.duration}ms`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function createRipple(e, center) {
|
|
37
|
+
if (options.disabled || el.hasAttribute('aria-disabled')) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (e instanceof KeyboardEvent) {
|
|
41
|
+
if (!['Enter', 'Space'].includes(e.code) || e.repeat) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
const click = new PointerEvent('pointerdown');
|
|
46
|
+
createRipple(click, true);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
addClasses(center);
|
|
50
|
+
const rect = el.getBoundingClientRect();
|
|
51
|
+
const clientX = window.TouchEvent && e instanceof TouchEvent
|
|
52
|
+
? e.touches[0].clientX
|
|
53
|
+
: e.clientX;
|
|
54
|
+
const clientY = window.TouchEvent && e instanceof TouchEvent
|
|
55
|
+
? e.touches[0].clientY
|
|
56
|
+
: e.clientY;
|
|
57
|
+
const x = clientX - rect.left > el.offsetWidth / 2 ? 0 : el.offsetWidth;
|
|
58
|
+
const y = clientY - rect.top > el.offsetHeight / 2 ? 0 : el.offsetHeight;
|
|
59
|
+
const radius = Math.hypot(x - (clientX - rect.left), y - (clientY - rect.top));
|
|
60
|
+
const ripple = document.createElement('div');
|
|
61
|
+
ripple.classList.add('kit-ripple');
|
|
62
|
+
ripple.style.left = `${clientX - rect.left - radius}px`;
|
|
63
|
+
ripple.style.top = `${clientY - rect.top - radius}px`;
|
|
64
|
+
ripple.style.width = ripple.style.height = `${radius * 2}px`;
|
|
65
|
+
rippleContainer.appendChild(ripple);
|
|
66
|
+
function removeRipple() {
|
|
67
|
+
if (ripple === null) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
ripple.style.opacity = '0';
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
ripple.remove();
|
|
73
|
+
}, options.duration || 1000);
|
|
74
|
+
cancelEvents.forEach((event) => el.removeEventListener(event, removeRipple));
|
|
75
|
+
}
|
|
76
|
+
cancelEvents.forEach((event) => el.addEventListener(event, removeRipple, { passive: true }));
|
|
77
|
+
}
|
|
78
|
+
triggerEvents.forEach((event) => el.addEventListener(event, createRipple, { passive: event === 'touchstart' }));
|
|
79
|
+
return {
|
|
80
|
+
destroy() {
|
|
81
|
+
triggerEvents.forEach((event) => {
|
|
82
|
+
el.removeEventListener(event, createRipple);
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
update(newOptions) {
|
|
86
|
+
options = newOptions;
|
|
87
|
+
setOptions(newOptions);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
package/dist/preset.js
CHANGED
|
@@ -4,7 +4,7 @@ export const config = {
|
|
|
4
4
|
minify: false // true | false
|
|
5
5
|
},
|
|
6
6
|
theme: {
|
|
7
|
-
colorScheme: '
|
|
7
|
+
colorScheme: 'system', // 'light' | 'dark' | 'system'
|
|
8
8
|
colors: {
|
|
9
9
|
primary: { light: 'oklch(45% 0.24 277.023)', dark: 'oklch(45% 0.24 277.023)' },
|
|
10
10
|
'on-primary': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
package/dist/style/animation.css
CHANGED
|
@@ -18,3 +18,43 @@
|
|
|
18
18
|
transform: rotate(380deg);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
.kit-ripple {
|
|
23
|
+
background-color: currentColor;
|
|
24
|
+
opacity: 0.1;
|
|
25
|
+
position: absolute;
|
|
26
|
+
border-radius: 50%;
|
|
27
|
+
pointer-events: none;
|
|
28
|
+
-webkit-transition: 0.6s;
|
|
29
|
+
transition: 0.6s;
|
|
30
|
+
-webkit-animation: lapikit-ripple var(--ripple-duration, 0.4s) cubic-bezier(0.4, 0, 0.2, 1);
|
|
31
|
+
animation: lapikit-ripple var(--ripple-duration, 0.4s) cubic-bezier(0.4, 0, 0.2, 1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.kit-ripple--center {
|
|
35
|
+
top: 50% !important;
|
|
36
|
+
left: 50% !important;
|
|
37
|
+
translate: -50% -50% !important;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.kit-ripple--effect {
|
|
41
|
+
position: absolute;
|
|
42
|
+
left: 0;
|
|
43
|
+
right: 0;
|
|
44
|
+
top: 0;
|
|
45
|
+
bottom: 0;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
background: none;
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
z-index: 999;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@keyframes lapikit-ripple {
|
|
53
|
+
from {
|
|
54
|
+
scale: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
to {
|
|
58
|
+
scale: 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
package/dist/style/normalize.css
CHANGED