noph-ui 0.17.9 → 0.17.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/button/Button.svelte +2 -0
- package/dist/tabs/Tab.svelte +19 -1
- package/dist/tabs/Tabs.svelte +3 -0
- package/package.json +1 -1
|
@@ -157,6 +157,8 @@
|
|
|
157
157
|
.text-disabled {
|
|
158
158
|
--button-height: var(--np-text-button-container-height, 2.5rem);
|
|
159
159
|
border-radius: var(--np-text-button-container-shape, var(--np-shape-corner-full));
|
|
160
|
+
padding-left: calc((var(--button-height) - 1.5rem) / 2);
|
|
161
|
+
padding-right: calc((var(--button-height) - 1.5rem) / 2);
|
|
160
162
|
}
|
|
161
163
|
.enabled {
|
|
162
164
|
transition: background-color 0.3s ease;
|
package/dist/tabs/Tab.svelte
CHANGED
|
@@ -15,7 +15,19 @@
|
|
|
15
15
|
...attributes
|
|
16
16
|
}: TabProps = $props()
|
|
17
17
|
let activeTab: { value: string | number; node: HTMLElement } = getContext('activeTab')
|
|
18
|
-
let
|
|
18
|
+
let element: HTMLElement | undefined = $state()
|
|
19
|
+
let isActive = $state(activeTab.value === value)
|
|
20
|
+
|
|
21
|
+
$effect(() => {
|
|
22
|
+
if (activeTab.value === value) {
|
|
23
|
+
if (element && element !== activeTab.node) {
|
|
24
|
+
setTabActive(element)
|
|
25
|
+
}
|
|
26
|
+
isActive = true
|
|
27
|
+
} else {
|
|
28
|
+
isActive = false
|
|
29
|
+
}
|
|
30
|
+
})
|
|
19
31
|
|
|
20
32
|
const setTabActive = (el: HTMLElement) => {
|
|
21
33
|
const oldTab = activeTab.node as HTMLElement | undefined
|
|
@@ -27,10 +39,12 @@
|
|
|
27
39
|
'--np-tab-indicator-start',
|
|
28
40
|
`${oldIndicatorRect.x - newIndicator.getBoundingClientRect().x}px`,
|
|
29
41
|
)
|
|
42
|
+
newIndicator?.style.setProperty('--np-tab-indicator-width', `${oldIndicatorRect.width}px`)
|
|
30
43
|
}
|
|
31
44
|
activeTab.value = value
|
|
32
45
|
activeTab.node = el
|
|
33
46
|
}
|
|
47
|
+
|
|
34
48
|
const setActiveTab = (el: HTMLElement) => {
|
|
35
49
|
if (isActive) {
|
|
36
50
|
activeTab.node = el
|
|
@@ -83,6 +97,7 @@
|
|
|
83
97
|
{...attributes}
|
|
84
98
|
tabindex={isActive ? 0 : -1}
|
|
85
99
|
role="tab"
|
|
100
|
+
bind:this={element}
|
|
86
101
|
{href}
|
|
87
102
|
class={[
|
|
88
103
|
'np-tab',
|
|
@@ -101,6 +116,7 @@
|
|
|
101
116
|
{...attributes}
|
|
102
117
|
tabindex={isActive ? 0 : -1}
|
|
103
118
|
role="tab"
|
|
119
|
+
bind:this={element}
|
|
104
120
|
class={[
|
|
105
121
|
'np-tab',
|
|
106
122
|
variant === 'secondary' && 'np-tab-secondary',
|
|
@@ -177,9 +193,11 @@
|
|
|
177
193
|
|
|
178
194
|
@keyframes slide {
|
|
179
195
|
0% {
|
|
196
|
+
width: var(--np-tab-indicator-width, 100%);
|
|
180
197
|
transform: translateX(var(--np-tab-indicator-start));
|
|
181
198
|
}
|
|
182
199
|
100% {
|
|
200
|
+
width: 100%;
|
|
183
201
|
transform: translateX(0);
|
|
184
202
|
}
|
|
185
203
|
}
|
package/dist/tabs/Tabs.svelte
CHANGED