noph-ui 0.2.4 → 0.2.6
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.
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
let tooltipId = $state(title ? generateUUIDv4() : '')
|
|
36
36
|
let selectedState = $state(!toggle || selected)
|
|
37
|
+
let touchEl: HTMLSpanElement | undefined = $state()
|
|
37
38
|
|
|
38
39
|
const isButton = (
|
|
39
40
|
obj: HTMLAnchorAttributes | HTMLButtonAttributes,
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
|
|
58
59
|
{#snippet content()}
|
|
59
60
|
{#if !disabled}
|
|
60
|
-
<Ripple />
|
|
61
|
+
<Ripple forElement={touchEl} />
|
|
61
62
|
{/if}
|
|
62
63
|
{#if selectedIcon && selectedState}
|
|
63
64
|
{@render selectedIcon()}
|
|
@@ -83,6 +84,7 @@
|
|
|
83
84
|
: ''} {attributes.class}"
|
|
84
85
|
>
|
|
85
86
|
{@render content()}
|
|
87
|
+
<span class="np-touch" bind:this={touchEl}></span>
|
|
86
88
|
</button>
|
|
87
89
|
{:else if isLink(attributes)}
|
|
88
90
|
<a
|
|
@@ -107,6 +109,7 @@
|
|
|
107
109
|
<style>
|
|
108
110
|
.np-icon-button {
|
|
109
111
|
box-sizing: border-box;
|
|
112
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
110
113
|
background-color: transparent;
|
|
111
114
|
border-width: 0;
|
|
112
115
|
position: relative;
|
|
@@ -114,7 +117,6 @@
|
|
|
114
117
|
display: flex;
|
|
115
118
|
padding: 0;
|
|
116
119
|
user-select: none;
|
|
117
|
-
overflow: hidden;
|
|
118
120
|
text-decoration: none;
|
|
119
121
|
align-items: center;
|
|
120
122
|
justify-content: center;
|
|
@@ -264,4 +266,9 @@
|
|
|
264
266
|
color: var(--np-color-inverse-on-surface);
|
|
265
267
|
background-color: var(--np-color-inverse-surface);
|
|
266
268
|
}
|
|
269
|
+
.np-touch {
|
|
270
|
+
position: absolute;
|
|
271
|
+
height: max(48px, 100%);
|
|
272
|
+
width: max(48px, 100%);
|
|
273
|
+
}
|
|
267
274
|
</style>
|
package/dist/icons/Icon.svelte
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<svelte:head>
|
|
6
6
|
<style>
|
|
7
|
-
.
|
|
7
|
+
.np-icon {
|
|
8
8
|
font-family: 'Material Symbols Outlined';
|
|
9
9
|
font-weight: normal;
|
|
10
10
|
font-style: normal;
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
-webkit-font-feature-settings: 'liga';
|
|
21
21
|
-webkit-font-smoothing: antialiased;
|
|
22
22
|
}
|
|
23
|
-
.
|
|
23
|
+
.np-icon {
|
|
24
24
|
font-variation-settings:
|
|
25
25
|
'FILL' 0,
|
|
26
26
|
'wght' 400,
|
|
27
27
|
'GRAD' 0,
|
|
28
28
|
'opsz' 24;
|
|
29
29
|
}
|
|
30
|
-
:where(.button-icon) .
|
|
30
|
+
:where(.button-icon) .np-icon {
|
|
31
31
|
display: inline-flex;
|
|
32
32
|
fill: currentColor;
|
|
33
33
|
color: var(--_icon-color);
|
|
@@ -41,4 +41,4 @@
|
|
|
41
41
|
</style>
|
|
42
42
|
</svelte:head>
|
|
43
43
|
|
|
44
|
-
<span class="
|
|
44
|
+
<span class="np-icon">{@render children()}</span>
|
|
@@ -4,8 +4,14 @@
|
|
|
4
4
|
interface RippleProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
forceHover?: boolean
|
|
6
6
|
element?: HTMLDivElement
|
|
7
|
+
forElement?: HTMLElement
|
|
7
8
|
}
|
|
8
|
-
let {
|
|
9
|
+
let {
|
|
10
|
+
forceHover = false,
|
|
11
|
+
element = $bindable(),
|
|
12
|
+
forElement,
|
|
13
|
+
...attributes
|
|
14
|
+
}: RippleProps = $props()
|
|
9
15
|
let pressed = $state(false)
|
|
10
16
|
let hovered = $state(false)
|
|
11
17
|
|
|
@@ -257,16 +263,32 @@
|
|
|
257
263
|
endPressAnimation()
|
|
258
264
|
}
|
|
259
265
|
|
|
266
|
+
const addEvents = (el: HTMLElement) => {
|
|
267
|
+
el.removeEventListener('click', handleClick)
|
|
268
|
+
el.removeEventListener('contextmenu', handleContextmenu)
|
|
269
|
+
el.removeEventListener('pointercancel', handlePointercancel)
|
|
270
|
+
el.removeEventListener('pointerdown', handlePointerdown)
|
|
271
|
+
el.removeEventListener('pointerenter', handlePointerenter)
|
|
272
|
+
el.removeEventListener('pointerleave', handlePointerleave)
|
|
273
|
+
el.removeEventListener('pointerup', handlePointerup)
|
|
274
|
+
|
|
275
|
+
el.addEventListener('click', handleClick)
|
|
276
|
+
el.addEventListener('contextmenu', handleContextmenu)
|
|
277
|
+
el.addEventListener('pointercancel', handlePointercancel)
|
|
278
|
+
el.addEventListener('pointerdown', handlePointerdown)
|
|
279
|
+
el.addEventListener('pointerenter', handlePointerenter)
|
|
280
|
+
el.addEventListener('pointerleave', handlePointerleave)
|
|
281
|
+
el.addEventListener('pointerup', handlePointerup)
|
|
282
|
+
}
|
|
283
|
+
|
|
260
284
|
$effect(() => {
|
|
261
285
|
const forcedColors = window?.matchMedia('(forced-colors: active)')
|
|
262
|
-
if (!forcedColors.matches &&
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
element.addEventListener('pointerleave', handlePointerleave)
|
|
269
|
-
element.addEventListener('pointerup', handlePointerup)
|
|
286
|
+
if (!forcedColors.matches && forElement) {
|
|
287
|
+
addEvents(forElement)
|
|
288
|
+
} else {
|
|
289
|
+
if (!forcedColors.matches && element) {
|
|
290
|
+
addEvents(element)
|
|
291
|
+
}
|
|
270
292
|
}
|
|
271
293
|
})
|
|
272
294
|
</script>
|
|
@@ -2,6 +2,7 @@ import type { HTMLAttributes } from 'svelte/elements';
|
|
|
2
2
|
declare const Ripple: import("svelte").Component<HTMLAttributes<HTMLDivElement> & {
|
|
3
3
|
forceHover?: boolean;
|
|
4
4
|
element?: HTMLDivElement;
|
|
5
|
+
forElement?: HTMLElement;
|
|
5
6
|
}, {}, "element">;
|
|
6
7
|
type Ripple = ReturnType<typeof Ripple>;
|
|
7
8
|
export default Ripple;
|