noph-ui 0.16.23 → 0.16.24
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/card/Card.svelte
CHANGED
|
@@ -174,6 +174,8 @@
|
|
|
174
174
|
position: relative;
|
|
175
175
|
padding: 0;
|
|
176
176
|
box-sizing: border-box;
|
|
177
|
+
color: var(--np-color-on-surface);
|
|
178
|
+
text-decoration: none;
|
|
177
179
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
178
180
|
border-radius: var(--border-radius);
|
|
179
181
|
background-color: var(--background-color);
|
package/dist/list/Item.svelte
CHANGED
package/dist/tabs/Tab.svelte
CHANGED
|
@@ -10,19 +10,20 @@
|
|
|
10
10
|
onclick,
|
|
11
11
|
onkeydown,
|
|
12
12
|
value,
|
|
13
|
+
href,
|
|
13
14
|
variant = 'primary',
|
|
14
15
|
...attributes
|
|
15
16
|
}: TabProps = $props()
|
|
16
17
|
let activeTab: { value: string | number; node: HTMLElement } = getContext('activeTab')
|
|
17
18
|
let isActive = $derived(activeTab.value === value)
|
|
18
19
|
|
|
19
|
-
const setTabActive = (el:
|
|
20
|
+
const setTabActive = (el: HTMLElement) => {
|
|
20
21
|
const oldTab = activeTab.node as HTMLElement | undefined
|
|
21
22
|
const oldIndicator = oldTab?.querySelector('.np-indicator') as HTMLElement
|
|
22
23
|
const oldIndicatorRect = oldIndicator?.getBoundingClientRect()
|
|
23
24
|
if (oldIndicatorRect) {
|
|
24
|
-
const newIndicator = el.querySelector('.np-indicator')
|
|
25
|
-
newIndicator
|
|
25
|
+
const newIndicator = el.querySelector<HTMLElement>('.np-indicator')
|
|
26
|
+
newIndicator?.style.setProperty(
|
|
26
27
|
'--np-tab-indicator-start',
|
|
27
28
|
`${oldIndicatorRect.x - newIndicator.getBoundingClientRect().x}px`,
|
|
28
29
|
)
|
|
@@ -30,38 +31,28 @@
|
|
|
30
31
|
activeTab.value = value
|
|
31
32
|
activeTab.node = el
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<div
|
|
36
|
-
{@attach (el) => {
|
|
34
|
+
const setActiveTab = (el: HTMLElement) => {
|
|
37
35
|
if (isActive) {
|
|
38
36
|
activeTab.node = el
|
|
39
37
|
}
|
|
40
|
-
}
|
|
41
|
-
{
|
|
42
|
-
tabindex={isActive ? 0 : -1}
|
|
43
|
-
role="tab"
|
|
44
|
-
class={[
|
|
45
|
-
'np-tab',
|
|
46
|
-
variant === 'secondary' && 'np-tab-secondary',
|
|
47
|
-
isActive && 'np-tab-content-active',
|
|
48
|
-
attributes.class,
|
|
49
|
-
]}
|
|
50
|
-
onclick={(event) => {
|
|
38
|
+
}
|
|
39
|
+
const onClick = (event: MouseEvent & { currentTarget: EventTarget & HTMLElement }) => {
|
|
51
40
|
setTabActive(event.currentTarget)
|
|
52
41
|
if (onclick) {
|
|
53
42
|
onclick(event)
|
|
54
43
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
44
|
+
}
|
|
45
|
+
const onKeyDown = (event: KeyboardEvent & { currentTarget: EventTarget & HTMLElement }) => {
|
|
57
46
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
58
47
|
setTabActive(event.currentTarget)
|
|
59
48
|
}
|
|
60
49
|
if (onkeydown) {
|
|
61
50
|
onkeydown(event)
|
|
62
51
|
}
|
|
63
|
-
}
|
|
64
|
-
>
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
{#snippet content()}
|
|
65
56
|
<div
|
|
66
57
|
class="np-tab-content"
|
|
67
58
|
style={variant === 'secondary' ? '--np-indicator-radius: 0;--_indicator-gap: 0' : ''}
|
|
@@ -84,7 +75,44 @@
|
|
|
84
75
|
</div>
|
|
85
76
|
<div class="focus-area"></div>
|
|
86
77
|
<Ripple />
|
|
87
|
-
|
|
78
|
+
{/snippet}
|
|
79
|
+
|
|
80
|
+
{#if href}
|
|
81
|
+
<a
|
|
82
|
+
{@attach setActiveTab}
|
|
83
|
+
{...attributes}
|
|
84
|
+
tabindex={isActive ? 0 : -1}
|
|
85
|
+
role="tab"
|
|
86
|
+
{href}
|
|
87
|
+
class={[
|
|
88
|
+
'np-tab',
|
|
89
|
+
variant === 'secondary' && 'np-tab-secondary',
|
|
90
|
+
isActive && 'np-tab-content-active',
|
|
91
|
+
attributes.class,
|
|
92
|
+
]}
|
|
93
|
+
onclick={onClick}
|
|
94
|
+
onkeydown={onKeyDown}
|
|
95
|
+
>
|
|
96
|
+
{@render content()}
|
|
97
|
+
</a>
|
|
98
|
+
{:else}
|
|
99
|
+
<div
|
|
100
|
+
{@attach setActiveTab}
|
|
101
|
+
{...attributes}
|
|
102
|
+
tabindex={isActive ? 0 : -1}
|
|
103
|
+
role="tab"
|
|
104
|
+
class={[
|
|
105
|
+
'np-tab',
|
|
106
|
+
variant === 'secondary' && 'np-tab-secondary',
|
|
107
|
+
isActive && 'np-tab-content-active',
|
|
108
|
+
attributes.class,
|
|
109
|
+
]}
|
|
110
|
+
onclick={onClick}
|
|
111
|
+
onkeydown={onKeyDown}
|
|
112
|
+
>
|
|
113
|
+
{@render content()}
|
|
114
|
+
</div>
|
|
115
|
+
{/if}
|
|
88
116
|
|
|
89
117
|
<style>
|
|
90
118
|
.np-tab {
|
|
@@ -94,9 +122,7 @@
|
|
|
94
122
|
justify-content: center;
|
|
95
123
|
font-family: inherit;
|
|
96
124
|
box-sizing: border-box;
|
|
97
|
-
-
|
|
98
|
-
background-color: transparent;
|
|
99
|
-
border-width: 0;
|
|
125
|
+
text-decoration: none;
|
|
100
126
|
position: relative;
|
|
101
127
|
cursor: pointer;
|
|
102
128
|
padding: 0 1rem;
|
package/dist/tabs/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
export interface TabProps extends HTMLAttributes<
|
|
3
|
+
export interface TabProps extends HTMLAttributes<HTMLElement> {
|
|
4
4
|
variant?: 'primary' | 'secondary';
|
|
5
5
|
inlineIcon?: boolean;
|
|
6
6
|
value: string | number;
|
|
7
|
+
href?: string;
|
|
7
8
|
icon?: Snippet;
|
|
8
9
|
}
|
|
9
10
|
export interface TabsProps extends HTMLAttributes<HTMLDivElement> {
|