noph-ui 0.2.3 → 0.2.5
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.
|
@@ -266,7 +266,7 @@
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
:global(.np-button .button-icon) {
|
|
269
|
-
--_icon-size: calc((var(--button-height) - 0.
|
|
269
|
+
--_icon-size: calc((var(--button-height) - 0.375rem) / 2);
|
|
270
270
|
--_icon-color: inherit;
|
|
271
271
|
}
|
|
272
272
|
|
|
@@ -275,7 +275,7 @@
|
|
|
275
275
|
display: block;
|
|
276
276
|
}
|
|
277
277
|
:global(.np-button .button-icon svg) {
|
|
278
|
-
width: calc((var(--button-height) - 0.
|
|
279
|
-
height: calc((var(--button-height) - 0.
|
|
278
|
+
width: calc((var(--button-height) - 0.375rem) / 2);
|
|
279
|
+
height: calc((var(--button-height) - 0.375rem) / 2);
|
|
280
280
|
}
|
|
281
281
|
</style>
|
|
@@ -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()}
|
|
@@ -79,10 +80,11 @@
|
|
|
79
80
|
: ''}{selectedState
|
|
80
81
|
? (variant === 'outlined' || variant === 'text') && !toggle
|
|
81
82
|
? ''
|
|
82
|
-
: 'selected'
|
|
83
|
+
: ' selected'
|
|
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
|
|
@@ -93,7 +95,7 @@
|
|
|
93
95
|
class="np-icon-button enabled {variant} {selectedState
|
|
94
96
|
? (variant === 'outlined' || variant === 'text') && !toggle
|
|
95
97
|
? ''
|
|
96
|
-
: 'selected'
|
|
98
|
+
: ' selected'
|
|
97
99
|
: ''} {attributes.class}"
|
|
98
100
|
>
|
|
99
101
|
{@render content()}
|
|
@@ -114,7 +116,6 @@
|
|
|
114
116
|
display: flex;
|
|
115
117
|
padding: 0;
|
|
116
118
|
user-select: none;
|
|
117
|
-
overflow: hidden;
|
|
118
119
|
text-decoration: none;
|
|
119
120
|
align-items: center;
|
|
120
121
|
justify-content: center;
|
|
@@ -264,4 +265,9 @@
|
|
|
264
265
|
color: var(--np-color-inverse-on-surface);
|
|
265
266
|
background-color: var(--np-color-inverse-surface);
|
|
266
267
|
}
|
|
268
|
+
.np-touch {
|
|
269
|
+
position: absolute;
|
|
270
|
+
height: max(48px, 100%);
|
|
271
|
+
width: max(48px, 100%);
|
|
272
|
+
}
|
|
267
273
|
</style>
|
package/dist/icons/Icon.svelte
CHANGED
|
@@ -2,41 +2,43 @@
|
|
|
2
2
|
let { children } = $props()
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
|
-
<
|
|
5
|
+
<svelte:head>
|
|
6
|
+
<style>
|
|
7
|
+
.np-icon {
|
|
8
|
+
font-family: 'Material Symbols Outlined';
|
|
9
|
+
font-weight: normal;
|
|
10
|
+
font-style: normal;
|
|
11
|
+
font-size: 24px;
|
|
12
|
+
line-height: 1;
|
|
13
|
+
letter-spacing: normal;
|
|
14
|
+
text-transform: none;
|
|
15
|
+
display: inline-block;
|
|
16
|
+
white-space: nowrap;
|
|
17
|
+
word-wrap: normal;
|
|
18
|
+
direction: ltr;
|
|
19
|
+
font-feature-settings: 'liga';
|
|
20
|
+
-webkit-font-feature-settings: 'liga';
|
|
21
|
+
-webkit-font-smoothing: antialiased;
|
|
22
|
+
}
|
|
23
|
+
.np-icon {
|
|
24
|
+
font-variation-settings:
|
|
25
|
+
'FILL' 0,
|
|
26
|
+
'wght' 400,
|
|
27
|
+
'GRAD' 0,
|
|
28
|
+
'opsz' 24;
|
|
29
|
+
}
|
|
30
|
+
:where(.button-icon) .np-icon {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
fill: currentColor;
|
|
33
|
+
color: var(--_icon-color);
|
|
34
|
+
font-size: var(--_icon-size);
|
|
35
|
+
inline-size: var(--_icon-size);
|
|
36
|
+
block-size: var(--_icon-size);
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
writing-mode: horizontal-tb;
|
|
39
|
+
position: relative;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
42
|
+
</svelte:head>
|
|
6
43
|
|
|
7
|
-
<
|
|
8
|
-
:global(.material-symbols-outlined) {
|
|
9
|
-
font-family: 'Material Symbols Outlined';
|
|
10
|
-
font-weight: normal;
|
|
11
|
-
font-style: normal;
|
|
12
|
-
font-size: 24px;
|
|
13
|
-
line-height: 1;
|
|
14
|
-
letter-spacing: normal;
|
|
15
|
-
text-transform: none;
|
|
16
|
-
display: inline-block;
|
|
17
|
-
white-space: nowrap;
|
|
18
|
-
word-wrap: normal;
|
|
19
|
-
direction: ltr;
|
|
20
|
-
font-feature-settings: 'liga';
|
|
21
|
-
-webkit-font-feature-settings: 'liga';
|
|
22
|
-
-webkit-font-smoothing: antialiased;
|
|
23
|
-
}
|
|
24
|
-
.material-symbols-outlined {
|
|
25
|
-
font-variation-settings:
|
|
26
|
-
'FILL' 0,
|
|
27
|
-
'wght' 400,
|
|
28
|
-
'GRAD' 0,
|
|
29
|
-
'opsz' 24;
|
|
30
|
-
}
|
|
31
|
-
:global(:where(.button-icon) .material-symbols-outlined) {
|
|
32
|
-
display: inline-flex;
|
|
33
|
-
fill: currentColor;
|
|
34
|
-
color: var(--_icon-color);
|
|
35
|
-
font-size: var(--_icon-size);
|
|
36
|
-
inline-size: var(--_icon-size);
|
|
37
|
-
block-size: var(--_icon-size);
|
|
38
|
-
flex-shrink: 0;
|
|
39
|
-
writing-mode: horizontal-tb;
|
|
40
|
-
position: relative;
|
|
41
|
-
}
|
|
42
|
-
</style>
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "noph-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://noph.dev",
|
|
6
6
|
"repository": {
|
|
@@ -64,20 +64,20 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@material/material-color-utilities": "^0.3.0",
|
|
67
|
-
"@playwright/test": "^1.49.
|
|
68
|
-
"@sveltejs/adapter-vercel": "^5.5.
|
|
69
|
-
"@sveltejs/kit": "^2.
|
|
67
|
+
"@playwright/test": "^1.49.1",
|
|
68
|
+
"@sveltejs/adapter-vercel": "^5.5.2",
|
|
69
|
+
"@sveltejs/kit": "^2.11.1",
|
|
70
70
|
"@sveltejs/package": "^2.3.7",
|
|
71
|
-
"@sveltejs/vite-plugin-svelte": "^5.0.
|
|
71
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.2",
|
|
72
72
|
"@types/eslint": "^9.6.1",
|
|
73
|
-
"eslint": "^9.
|
|
73
|
+
"eslint": "^9.17.0",
|
|
74
74
|
"eslint-config-prettier": "^9.1.0",
|
|
75
75
|
"eslint-plugin-svelte": "^2.46.1",
|
|
76
76
|
"globals": "^15.13.0",
|
|
77
77
|
"prettier": "^3.4.2",
|
|
78
78
|
"prettier-plugin-svelte": "^3.3.2",
|
|
79
79
|
"publint": "^0.2.12",
|
|
80
|
-
"svelte": "^5.
|
|
80
|
+
"svelte": "^5.14.0",
|
|
81
81
|
"svelte-check": "^4.1.1",
|
|
82
82
|
"typescript": "^5.7.2",
|
|
83
83
|
"typescript-eslint": "^8.18.0",
|