glasslikeui 1.2.0 → 1.2.1
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.
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
type GlassIntensity
|
|
10
10
|
} from '../../constants/variants';
|
|
11
11
|
import { CORNER_RADIUS, PADDING, type CornerRadius, type Padding } from '../../constants';
|
|
12
|
+
import { fromAction } from 'svelte/attachments';
|
|
12
13
|
import { deviceMotion } from '../../actions/deviceMotion';
|
|
13
14
|
|
|
14
15
|
interface Props {
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
class:has-lensing={cfg.displacementScale > 0}
|
|
50
51
|
class:has-shadow={shadow}
|
|
51
52
|
class:is-interactive={interactive}
|
|
52
|
-
|
|
53
|
+
{@attach fromAction(deviceMotion)}
|
|
53
54
|
style="
|
|
54
55
|
--glass-blur: {cfg.blur}px;
|
|
55
56
|
--glass-saturation: {cfg.saturation};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { fromAction } from 'svelte/attachments';
|
|
3
4
|
import { HStack, Spacer } from '../layout';
|
|
4
5
|
import {
|
|
5
6
|
dragSnap,
|
|
@@ -38,13 +39,9 @@
|
|
|
38
39
|
const fractions = $derived(detentFractions(detents));
|
|
39
40
|
const initialIndex = $derived(Math.max(0, detents.indexOf(initialDetent)));
|
|
40
41
|
|
|
41
|
-
let currentIndex = $
|
|
42
|
+
let currentIndex = $derived(initialIndex);
|
|
42
43
|
let sheetEl = $state<HTMLElement | undefined>();
|
|
43
44
|
|
|
44
|
-
$effect(() => {
|
|
45
|
-
currentIndex = initialIndex;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
45
|
function close() {
|
|
49
46
|
isOpen = false;
|
|
50
47
|
onClose?.();
|
|
@@ -72,13 +69,11 @@
|
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
$effect(() => {
|
|
75
|
-
if (
|
|
72
|
+
if (isOpen) {
|
|
76
73
|
document.body.style.overflow = 'hidden';
|
|
77
74
|
}
|
|
78
75
|
return () => {
|
|
79
|
-
|
|
80
|
-
document.body.style.overflow = '';
|
|
81
|
-
}
|
|
76
|
+
document.body.style.overflow = '';
|
|
82
77
|
};
|
|
83
78
|
});
|
|
84
79
|
</script>
|
|
@@ -101,13 +96,13 @@
|
|
|
101
96
|
{#if showHandle}
|
|
102
97
|
<div
|
|
103
98
|
class="sheet-handle-container"
|
|
104
|
-
|
|
99
|
+
{@attach fromAction(dragSnap, () => ({
|
|
105
100
|
target: sheetEl,
|
|
106
101
|
detents: fractions,
|
|
107
102
|
initial: currentIndex,
|
|
108
103
|
disabled: !draggable || fractions.length < 2,
|
|
109
104
|
onSnap: handleSnap
|
|
110
|
-
}}
|
|
105
|
+
}))}
|
|
111
106
|
>
|
|
112
107
|
<div class="sheet-handle"></div>
|
|
113
108
|
</div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { fromAction } from 'svelte/attachments';
|
|
3
4
|
import {
|
|
4
5
|
scrollEdge,
|
|
5
6
|
type ScrollEdgeEffect,
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
<div
|
|
38
39
|
class="scroll-view axis-{axis} {className}"
|
|
39
40
|
class:hide-indicators={!showsIndicators}
|
|
40
|
-
|
|
41
|
+
{@attach fromAction(scrollEdge, () => ({ edges, effect: edgeEffect, size: edgeSize }))}
|
|
41
42
|
>
|
|
42
43
|
<div class="scroll-content">
|
|
43
44
|
{@render children()}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
let counter = 0;
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
1
|
<script lang="ts">
|
|
6
2
|
import type { Snippet } from 'svelte';
|
|
7
3
|
import { tick } from 'svelte';
|
|
@@ -15,10 +11,7 @@
|
|
|
15
11
|
|
|
16
12
|
let { label, children, align = 'start', class: className = '' }: Props = $props();
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
// is inert because the panel is not rendered on initial load (open defaults false).
|
|
20
|
-
const panelId = `glass-menu-${++counter}`;
|
|
21
|
-
const isBrowser = typeof window !== 'undefined';
|
|
14
|
+
const panelId = $props.id();
|
|
22
15
|
|
|
23
16
|
let open = $state(false);
|
|
24
17
|
let triggerEl = $state<HTMLButtonElement>();
|
|
@@ -75,29 +68,16 @@
|
|
|
75
68
|
}
|
|
76
69
|
}
|
|
77
70
|
|
|
78
|
-
|
|
79
|
-
if (!open
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const target = e.target as Node;
|
|
85
|
-
if (triggerEl?.contains(target) || panel.contains(target)) return;
|
|
86
|
-
closeMenu();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
panel.addEventListener('keydown', handlePanelKeydown);
|
|
90
|
-
panel.addEventListener('click', handlePanelClick);
|
|
91
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
92
|
-
|
|
93
|
-
return () => {
|
|
94
|
-
panel.removeEventListener('keydown', handlePanelKeydown);
|
|
95
|
-
panel.removeEventListener('click', handlePanelClick);
|
|
96
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
97
|
-
};
|
|
98
|
-
});
|
|
71
|
+
function handleDocumentPointerDown(e: PointerEvent) {
|
|
72
|
+
if (!open) return;
|
|
73
|
+
const target = e.target as Node;
|
|
74
|
+
if (triggerEl?.contains(target) || panelEl?.contains(target)) return;
|
|
75
|
+
closeMenu();
|
|
76
|
+
}
|
|
99
77
|
</script>
|
|
100
78
|
|
|
79
|
+
<svelte:document onpointerdown={handleDocumentPointerDown} />
|
|
80
|
+
|
|
101
81
|
<div class="glass-menu">
|
|
102
82
|
<button
|
|
103
83
|
bind:this={triggerEl}
|
|
@@ -116,8 +96,11 @@
|
|
|
116
96
|
bind:this={panelEl}
|
|
117
97
|
id={panelId}
|
|
118
98
|
role="menu"
|
|
99
|
+
tabindex="-1"
|
|
119
100
|
class="glass-menu-panel"
|
|
120
101
|
class:align-end={align === 'end'}
|
|
102
|
+
onkeydown={handlePanelKeydown}
|
|
103
|
+
onclick={handlePanelClick}
|
|
121
104
|
>
|
|
122
105
|
{@render children()}
|
|
123
106
|
</div>
|