sprintify-ui 0.0.199 → 0.0.200

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.
@@ -7,52 +7,86 @@
7
7
  <a
8
8
  :href="disabled ? undefined : href"
9
9
  :disabled="disabled"
10
- class="group relative flex items-center px-3 py-1"
10
+ class="group block"
11
11
  :class="[
12
- (activeStrategy == 'default' ? isActive : isExactActive)
12
+ isActiveInternal(isActive, isExactActive)
13
13
  ? 'font-semibold text-primary-600'
14
14
  : 'text-slate-600 hover:text-slate-900',
15
15
  disabled ? 'cursor-not-allowed opacity-60' : '',
16
+ sizeClassOuter,
16
17
  ]"
17
18
  @click.prevent="onClick(navigate)"
18
19
  >
19
- <div
20
- class="absolute left-0 top-0 h-full"
21
- :class="[
22
- (activeStrategy == 'default' ? isActive : isExactActive)
23
- ? 'w-[2px] bg-primary-600'
24
- : 'group-hover:w-px group-hover:bg-slate-700',
25
- ]"
26
- ></div>
27
- <slot />
20
+ <div class="relative flex items-center" :class="[sizeClassInner]">
21
+ <div
22
+ class="absolute left-0 top-0 h-full"
23
+ :class="[
24
+ isActiveInternal(isActive, isExactActive)
25
+ ? 'w-[2px] bg-primary-600'
26
+ : 'group-hover:w-px group-hover:bg-slate-700',
27
+ ]"
28
+ ></div>
29
+ <slot :active="isActiveInternal(isActive, isExactActive)" />
30
+ </div>
28
31
  </a>
29
32
  </router-link>
30
33
  </template>
31
34
 
32
35
  <script lang="ts" setup>
33
- import { PropType } from 'vue';
34
- import { RouteLocationRaw } from 'vue-router';
35
-
36
- const props = defineProps({
37
- to: {
38
- required: true,
39
- type: [Object, String] as PropType<RouteLocationRaw>,
40
- },
41
- disabled: {
42
- default: false,
43
- type: Boolean,
44
- },
45
- activeStrategy: {
46
- default: 'default',
47
- type: String as PropType<'default' | 'exact'>,
48
- },
49
- });
36
+ import { NavigationFailure, RouteLocationRaw } from 'vue-router';
37
+
38
+ const props = withDefaults(
39
+ defineProps<{
40
+ to: RouteLocationRaw;
41
+ disabled?: boolean;
42
+ activeStrategy?: 'default' | 'exact';
43
+ }>(),
44
+ {
45
+ disabled: false,
46
+ activeStrategy: 'default',
47
+ }
48
+ );
50
49
 
51
- const onClick = (navigate: () => void) => {
50
+ const size = inject(
51
+ 'sideNavigation:size',
52
+ ref<'xs' | 'sm' | 'md' | 'lg'>('md')
53
+ );
54
+
55
+ function onClick(navigate: () => Promise<void | NavigationFailure>) {
52
56
  if (props.disabled) {
53
57
  return;
54
58
  }
55
59
 
56
- navigate();
57
- };
60
+ return navigate();
61
+ }
62
+
63
+ function isActiveInternal(isActive: boolean, isExactActive: boolean) {
64
+ return props.activeStrategy == 'default' ? isActive : isExactActive;
65
+ }
66
+
67
+ const sizeClassOuter = computed(() => {
68
+ switch (size.value) {
69
+ case 'xs':
70
+ return 'py-0.5';
71
+ case 'sm':
72
+ return 'py-1';
73
+ case 'md':
74
+ return 'py-2';
75
+ case 'lg':
76
+ return 'py-2';
77
+ }
78
+ });
79
+
80
+ const sizeClassInner = computed(() => {
81
+ switch (size.value) {
82
+ case 'xs':
83
+ return 'text-xs px-3 py-0.5 font-normal';
84
+ case 'sm':
85
+ return 'text-sm px-4 py-0.5 font-normal';
86
+ case 'md':
87
+ return 'text-sm px-4 py-0.5 font-normal';
88
+ case 'lg':
89
+ return 'text-base px-5 py-0.5 font-normal';
90
+ }
91
+ });
58
92
  </script>
@@ -1,32 +1,35 @@
1
1
  <template>
2
- <li role="presentation">
2
+ <li>
3
3
  <router-link
4
4
  v-slot="{ href, navigate, isActive, isExactActive }"
5
5
  :to="to"
6
6
  custom
7
7
  >
8
8
  <a
9
- :href="href"
10
- class="group relative inline-block rounded-t-lg"
9
+ :href="disabled ? undefined : href"
10
+ :disabled="disabled"
11
+ class="group inline-block rounded-t-lg"
11
12
  :class="[
12
- tabIsActive(isActive, isExactActive)
13
+ isActiveInternal(isActive, isExactActive)
13
14
  ? 'active text-primary-600'
14
15
  : 'text-slate-600 hover:text-slate-900',
15
16
  disabled ? 'cursor-not-allowed opacity-60' : '',
16
- sizeClass,
17
+ sizeClassOuter,
17
18
  ]"
18
19
  @click.prevent="onClick(navigate)"
19
20
  >
20
- <div
21
- class="absolute left-0 bottom-0 w-full"
22
- :class="[
23
- tabIsActive(isActive, isExactActive)
24
- ? 'h-[2px] bg-primary-600'
25
- : 'group-hover:h-px group-hover:bg-slate-700',
26
- ]"
27
- ></div>
28
- <div class="whitespace-nowrap">
29
- <slot :active="tabIsActive(isActive, isExactActive)" />
21
+ <div class="relative flex" :class="sizeClassInner">
22
+ <div
23
+ class="absolute left-0 bottom-0 w-full"
24
+ :class="[
25
+ isActiveInternal(isActive, isExactActive)
26
+ ? 'h-[2px] bg-primary-600'
27
+ : 'group-hover:h-px group-hover:bg-slate-700',
28
+ ]"
29
+ ></div>
30
+ <div class="whitespace-nowrap">
31
+ <slot :active="isActiveInternal(isActive, isExactActive)" />
32
+ </div>
30
33
  </div>
31
34
  </a>
32
35
  </router-link>
@@ -34,7 +37,6 @@
34
37
  </template>
35
38
 
36
39
  <script lang="ts" setup>
37
- import { ComputedRef } from 'vue';
38
40
  import { NavigationFailure, RouteLocationRaw } from 'vue-router';
39
41
 
40
42
  const props = withDefaults(
@@ -49,9 +51,7 @@ const props = withDefaults(
49
51
  }
50
52
  );
51
53
 
52
- const size = inject('tabs:size', ref('md')) as ComputedRef<
53
- 'xs' | 'sm' | 'md' | 'lg'
54
- >;
54
+ const size = inject('tabs:size', ref<'xs' | 'sm' | 'md' | 'lg'>('md'));
55
55
 
56
56
  function onClick(navigate: () => Promise<void | NavigationFailure>) {
57
57
  if (props.disabled) {
@@ -61,24 +61,33 @@ function onClick(navigate: () => Promise<void | NavigationFailure>) {
61
61
  return navigate();
62
62
  }
63
63
 
64
- function tabIsActive(isActive: boolean, isExactActive: boolean) {
65
- if (props.activeStrategy == 'default') {
66
- return isActive;
67
- }
68
-
69
- return isExactActive;
64
+ function isActiveInternal(isActive: boolean, isExactActive: boolean) {
65
+ return props.activeStrategy == 'default' ? isActive : isExactActive;
70
66
  }
71
67
 
72
- const sizeClass = computed(() => {
68
+ const sizeClassOuter = computed(() => {
69
+ switch (size.value) {
70
+ case 'xs':
71
+ return 'px-1';
72
+ case 'sm':
73
+ return 'px-2';
74
+ case 'md':
75
+ return 'px-2.5';
76
+ case 'lg':
77
+ return 'px-3';
78
+ }
79
+ });
80
+
81
+ const sizeClassInner = computed(() => {
73
82
  switch (size.value) {
74
83
  case 'xs':
75
- return 'text-xs px-1 py-2 font-normal';
84
+ return 'text-xs py-2 px-1 font-normal';
76
85
  case 'sm':
77
- return 'text-sm px-1 py-2.5 font-normal';
86
+ return 'text-sm py-2.5 px-1 font-normal';
78
87
  case 'md':
79
- return 'text-sm px-1 py-4 font-normal';
88
+ return 'text-sm py-4 px-1 font-normal';
80
89
  case 'lg':
81
- return 'text-base px-1 py-4 font-normal';
90
+ return 'text-base py-4 px-1 font-normal';
82
91
  }
83
92
  });
84
93
  </script>
@@ -30,8 +30,8 @@ const Template = (args) => ({
30
30
  <BaseTabItem to="/" v-slot="{active}">
31
31
  <div class="flex items-center">
32
32
  <span class="mr-1">Home</span>
33
- <BaseCounter :size="args.size" :color="active ? 'primary' : 'light'" :count="1"></BaseCounter>
34
- </div>
33
+ <BaseCounter :size="['lg', 'md'].includes(args.size) ? 'sm' : 'xs'" :color="active ? 'primary' : 'light'" :count="1"></BaseCounter>
34
+ </div>
35
35
  </BaseTabItem>
36
36
  <BaseTabItem to="/setup">
37
37
  Setup
@@ -6,7 +6,7 @@
6
6
  class="scrollable relative overflow-x-auto overflow-y-hidden"
7
7
  data-scroll-lock-scrollable
8
8
  >
9
- <ul class="flex text-center" :class="[sizeClass]">
9
+ <ul class="flex text-center">
10
10
  <slot />
11
11
  </ul>
12
12
  </div>
@@ -40,19 +40,6 @@ provide(
40
40
  computed(() => props.size)
41
41
  );
42
42
 
43
- const sizeClass = computed(() => {
44
- switch (props.size) {
45
- case 'xs':
46
- return 'space-x-2';
47
- case 'sm':
48
- return 'space-x-4';
49
- case 'md':
50
- return 'space-x-5';
51
- case 'lg':
52
- return 'space-x-6';
53
- }
54
- });
55
-
56
43
  function scrollToCenter() {
57
44
  if (!scrollable.value) {
58
45
  return;