design-system-next 1.2.5 → 1.2.7
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/design-system-next.js +1959 -1870
- package/dist/design-system-next.js.gz +0 -0
- package/dist/main.css +1 -1
- package/dist/main.css.gz +0 -0
- package/package.json +1 -1
- package/src/App.vue +2 -5
- package/src/assets/images/sample-profile-image.jpg +0 -0
- package/src/assets/images/sprout-hr-logo.svg +33 -0
- package/src/assets/styles/tailwind.css +0 -66
- package/src/components/avatar/avatar.vue +2 -0
- package/src/components/badge/badge.vue +1 -0
- package/src/components/button/button.ts +1 -1
- package/src/components/button/button.vue +1 -9
- package/src/components/button/use-button.ts +27 -6
- package/src/components/{emptyState/emptyState.vue → empty-state/empty-state.vue} +3 -2
- package/src/components/{emptyState/use-emptyState.ts → empty-state/use-empty-state.ts} +1 -1
- package/src/components/input/input.vue +4 -2
- package/src/components/lozenge/lozenge.vue +5 -4
- package/src/components/lozenge/use-lozenge.ts +31 -7
- package/src/components/radio/radio.vue +3 -2
- package/src/components/sidenav/sidenav.vue +5 -5
- package/src/components/switch/switch.vue +6 -2
- package/src/components/tabs/tabs.vue +63 -26
- package/src/components/tabs/use-tabs.ts +41 -14
- package/src/components/timePicker/timePicker.vue +1 -1
- package/src/components/timePicker/use-timePicker.ts +1 -1
- /package/src/assets/scripts/{borderRadius.ts → border-radius.ts} +0 -0
- /package/src/assets/scripts/{maxWidth.ts → max-width.ts} +0 -0
- /package/src/components/{emptyState/emptyState.ts → empty-state/empty-state.ts} +0 -0
|
@@ -617,16 +617,16 @@
|
|
|
617
617
|
</template>
|
|
618
618
|
|
|
619
619
|
<script lang="ts" setup>
|
|
620
|
-
import { sidenavPropTypes, sidenavEmitTypes } from './sidenav';
|
|
621
|
-
import { useSidenav } from './use-sidenav';
|
|
622
|
-
|
|
623
620
|
import { Menu, Tooltip } from 'floating-vue';
|
|
624
621
|
import { Icon } from '@iconify/vue';
|
|
625
622
|
|
|
626
|
-
import badge from '../badge/badge.vue';
|
|
627
|
-
|
|
628
623
|
import 'floating-vue/dist/style.css';
|
|
629
624
|
|
|
625
|
+
import { sidenavPropTypes, sidenavEmitTypes } from './sidenav';
|
|
626
|
+
import { useSidenav } from './use-sidenav';
|
|
627
|
+
|
|
628
|
+
import badge from '../badge/badge.vue';
|
|
629
|
+
|
|
630
630
|
const props = defineProps(sidenavPropTypes);
|
|
631
631
|
const emit = defineEmits(sidenavEmitTypes);
|
|
632
632
|
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
</label>
|
|
8
8
|
<div
|
|
9
9
|
ref="switchWrapperRef"
|
|
10
|
-
:class="
|
|
10
|
+
:class="{
|
|
11
|
+
'relative flex items-center': true,
|
|
12
|
+
'cursor-pointer transition duration-300 ease-in-out active:scale-90': !props.disabled,
|
|
13
|
+
}"
|
|
11
14
|
>
|
|
12
15
|
<input
|
|
13
16
|
ref="switchRef"
|
|
@@ -28,9 +31,10 @@
|
|
|
28
31
|
</template>
|
|
29
32
|
|
|
30
33
|
<script lang="ts" setup>
|
|
34
|
+
import { useVModel } from '@vueuse/core';
|
|
35
|
+
|
|
31
36
|
import { switchEmitTypes, switchPropTypes } from './switch';
|
|
32
37
|
import { useSwitch } from './use-switch';
|
|
33
|
-
import { useVModel } from '@vueuse/core';
|
|
34
38
|
|
|
35
39
|
const props = defineProps(switchPropTypes);
|
|
36
40
|
const emit = defineEmits(switchEmitTypes);
|
|
@@ -1,46 +1,52 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="flex">
|
|
2
|
+
<div class="relative flex">
|
|
3
3
|
<div
|
|
4
4
|
v-for="(tab, index) in list"
|
|
5
5
|
:key="index"
|
|
6
|
+
ref="tabElements"
|
|
6
7
|
:class="[
|
|
7
8
|
tabsClasses,
|
|
8
|
-
'body-sm-regular text-color-strong cursor-pointer border-solid',
|
|
9
9
|
{
|
|
10
|
-
//
|
|
11
|
-
'
|
|
10
|
+
// Regular Tab
|
|
11
|
+
'rounded-l-md': !underlined && index === 0,
|
|
12
|
+
'rounded-r-md': !underlined && index === tabElements.length - 1,
|
|
12
13
|
|
|
13
|
-
//
|
|
14
|
-
'
|
|
15
|
-
!underlined &&
|
|
14
|
+
// Regular Tab - Active
|
|
15
|
+
'text-color-brand-base border-color-success-base cursor-pointer border border-solid':
|
|
16
|
+
!underlined && activeTab.index === index,
|
|
16
17
|
|
|
17
|
-
//
|
|
18
|
-
'border-color-
|
|
18
|
+
// Regular Tab - Inactive
|
|
19
|
+
'border-color-weak hover:background-color-hover cursor-pointer border-x-[0.5px] border-y border-solid':
|
|
20
|
+
!underlined && activeTab.index !== index,
|
|
19
21
|
|
|
20
|
-
//
|
|
21
|
-
'
|
|
22
|
+
// Regular Tab - Disabled
|
|
23
|
+
'background-color-base !cursor-not-allowed': !underlined && tab.disabled,
|
|
22
24
|
|
|
23
|
-
//
|
|
24
|
-
'
|
|
25
|
-
|
|
26
|
-
// Regular text for non-selected tabs
|
|
27
|
-
'body-sm-regular': selectedTabIndex !== index,
|
|
25
|
+
// Underlined Tab - Active
|
|
26
|
+
'text-color-brand-base cursor-pointer': underlined && activeTab.index === index,
|
|
28
27
|
|
|
29
|
-
//
|
|
30
|
-
'
|
|
28
|
+
// Underlined Tab - Inactive
|
|
29
|
+
'border-color-base cursor-pointer border-b border-solid': underlined && activeTab.index !== index,
|
|
30
|
+
'hover:background-color-hover cursor-pointer': underlined && activeTab.index !== index && !tab.disabled,
|
|
31
31
|
|
|
32
|
-
//
|
|
33
|
-
'border-
|
|
34
|
-
'border-r-0': selectedTabIndex - index === 1,
|
|
32
|
+
// Underlined Tab - Disabled
|
|
33
|
+
'border-color-disabled text-color-disabled !cursor-not-allowed border-b': underlined && tab.disabled,
|
|
35
34
|
},
|
|
36
35
|
]"
|
|
37
36
|
@click="updateSelectedTabIndex(index, tab.disabled)"
|
|
38
37
|
>
|
|
39
|
-
<div
|
|
38
|
+
<div
|
|
39
|
+
:class="{
|
|
40
|
+
'flex items-center gap-size-spacing-5xs leading-none': true,
|
|
41
|
+
'transition duration-150 ease-in-out': true,
|
|
42
|
+
'cursor-pointer group-active:scale-75': !tab.disabled,
|
|
43
|
+
'cursor-not-allowed': tab.disabled,
|
|
44
|
+
}"
|
|
45
|
+
>
|
|
40
46
|
<div v-if="!!tab.icon">
|
|
41
47
|
<Icon
|
|
42
|
-
:icon="selectedTabIndex === index && !!tab.iconFill ? tab.iconFill : tab.icon"
|
|
43
48
|
class="body-sm-regular"
|
|
49
|
+
:icon="activeTab.index === index && typeof tab.iconFill === 'string' ? tab.iconFill : tab.icon"
|
|
44
50
|
/>
|
|
45
51
|
</div>
|
|
46
52
|
<div v-if="!!tab.label">
|
|
@@ -48,17 +54,48 @@
|
|
|
48
54
|
</div>
|
|
49
55
|
</div>
|
|
50
56
|
</div>
|
|
57
|
+
|
|
58
|
+
<!-- Regular Tab Background Active Indicator -->
|
|
59
|
+
<div
|
|
60
|
+
v-if="!underlined"
|
|
61
|
+
:class="[
|
|
62
|
+
'background-color-single-active absolute bottom-0 left-0 z-[5] block',
|
|
63
|
+
'transition-left duration-150 ease-in-out',
|
|
64
|
+
{
|
|
65
|
+
'rounded-l-md': activeTab.index === 0,
|
|
66
|
+
'rounded-r-md': activeTab.index === tabElements.length - 1,
|
|
67
|
+
},
|
|
68
|
+
]"
|
|
69
|
+
:style="{
|
|
70
|
+
height: `${activeTab.height}px`,
|
|
71
|
+
width: `${activeTab.width}px`,
|
|
72
|
+
left: `${activeTab.undelineLeftOffset}px`,
|
|
73
|
+
}"
|
|
74
|
+
/>
|
|
75
|
+
|
|
76
|
+
<!-- Underlined Tab Active Indicator -->
|
|
77
|
+
<div
|
|
78
|
+
v-if="underlined"
|
|
79
|
+
:class="[
|
|
80
|
+
'background-color-success-base absolute bottom-0 left-0 z-10 block h-0.5 rounded-full',
|
|
81
|
+
'transition-left duration-150 ease-in-out',
|
|
82
|
+
]"
|
|
83
|
+
:style="{
|
|
84
|
+
width: `${activeTab.width}px`,
|
|
85
|
+
left: `calc(${activeTab.undelineLeftOffset}px - 2.3px)`,
|
|
86
|
+
}"
|
|
87
|
+
/>
|
|
51
88
|
</div>
|
|
52
89
|
</template>
|
|
53
90
|
|
|
54
91
|
<script lang="ts" setup>
|
|
92
|
+
import { Icon } from '@iconify/vue';
|
|
93
|
+
|
|
55
94
|
import { tabsPropTypes, tabsEmitTypes } from './tabs';
|
|
56
95
|
import { useTabs } from './use-tabs';
|
|
57
96
|
|
|
58
|
-
import { Icon } from '@iconify/vue';
|
|
59
|
-
|
|
60
97
|
const emit = defineEmits(tabsEmitTypes);
|
|
61
98
|
const props = defineProps(tabsPropTypes);
|
|
62
99
|
|
|
63
|
-
const {
|
|
100
|
+
const { tabsClasses, activeTab, tabElements, updateSelectedTabIndex } = useTabs(props, emit);
|
|
64
101
|
</script>
|
|
@@ -1,33 +1,60 @@
|
|
|
1
|
-
import { ref, computed, SetupContext } from 'vue';
|
|
1
|
+
import { ref, computed, onMounted, SetupContext } from 'vue';
|
|
2
2
|
import type { TabsPropTypes, TabsEmitTypes } from './tabs';
|
|
3
3
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
|
|
6
6
|
export const useTabs = (props: TabsPropTypes, emit: SetupContext<TabsEmitTypes>['emit']) => {
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const tabsClasses = computed(() => {
|
|
8
|
+
return classNames({
|
|
9
|
+
'relative z-[10] px-size-spacing-xs py-size-spacing-3xs body-sm text-color-strong group': true,
|
|
10
|
+
'transition-left duration-150 ease-in-out': true,
|
|
11
|
+
capitalize: !props.underlined,
|
|
12
|
+
'uppercase border-x-0 border-t-0': props.underlined,
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const activeTab = ref({
|
|
17
|
+
index: 0,
|
|
18
|
+
previousIndex: -1,
|
|
19
|
+
height: 0,
|
|
20
|
+
width: 0,
|
|
21
|
+
undelineLeftOffset: 0,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const tabElements = ref<HTMLElement[]>([]);
|
|
9
25
|
|
|
10
|
-
|
|
26
|
+
const updateSelectedTabIndex = (index: number, disabled = false) => {
|
|
11
27
|
if (disabled) return;
|
|
12
28
|
|
|
13
|
-
|
|
29
|
+
activeTab.value.previousIndex = activeTab.value.index;
|
|
14
30
|
|
|
15
|
-
|
|
31
|
+
if (activeTab.value.index === index) return;
|
|
32
|
+
|
|
33
|
+
activeTab.value.index = index;
|
|
34
|
+
|
|
35
|
+
// Update underline left offset based on previous index
|
|
36
|
+
const indexDifference = Math.abs(activeTab.value.index - activeTab.value.previousIndex);
|
|
37
|
+
|
|
38
|
+
if (activeTab.value.index > activeTab.value.previousIndex) {
|
|
39
|
+
// Moving right: increase the offset by the width of each tab
|
|
40
|
+
activeTab.value.undelineLeftOffset += indexDifference * activeTab.value.width;
|
|
41
|
+
} else {
|
|
42
|
+
// Moving left: decrease the offset by the width of each tab
|
|
43
|
+
activeTab.value.undelineLeftOffset -= indexDifference * activeTab.value.width;
|
|
44
|
+
}
|
|
16
45
|
|
|
17
46
|
emit('tabIndex', index);
|
|
18
|
-
}
|
|
47
|
+
};
|
|
19
48
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
!underlined,
|
|
24
|
-
'p-size-spacing-xs uppercase border-x-0 border-t-0': underlined,
|
|
25
|
-
});
|
|
49
|
+
onMounted(() => {
|
|
50
|
+
activeTab.value.height = tabElements.value[activeTab.value.index].offsetHeight;
|
|
51
|
+
activeTab.value.width = tabElements.value[activeTab.value.index].offsetWidth;
|
|
26
52
|
});
|
|
27
53
|
|
|
28
54
|
return {
|
|
29
55
|
tabsClasses,
|
|
30
|
-
|
|
56
|
+
activeTab,
|
|
57
|
+
tabElements,
|
|
31
58
|
updateSelectedTabIndex,
|
|
32
59
|
};
|
|
33
60
|
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|