sprintify-ui 0.5.2 → 0.5.4

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.
@@ -4,9 +4,20 @@
4
4
  <div
5
5
  ref="scrollable"
6
6
  class="scrollable relative overflow-x-auto overflow-y-hidden"
7
+ :class="{
8
+ '-mx-2': size == 'xs',
9
+ '-mx-3': size == 'sm',
10
+ '-mx-4': size == 'md',
11
+ '-mx-5': size == 'lg',
12
+ }"
7
13
  data-scroll-lock-scrollable
8
14
  >
9
15
  <ul class="flex text-center">
16
+ <div
17
+ ref="lineRef"
18
+ style="visibility: hidden; width: 0px;"
19
+ class="absolute left-0 bottom-0 w-full h-[2px] bg-primary-600"
20
+ />
10
21
  <slot />
11
22
  </ul>
12
23
  </div>
@@ -31,6 +42,7 @@ watch(
31
42
  () => {
32
43
  nextTick(() => {
33
44
  scrollToCenter();
45
+ animateLine();
34
46
  });
35
47
  }
36
48
  );
@@ -40,15 +52,37 @@ provide(
40
52
  computed(() => props.size)
41
53
  );
42
54
 
43
- function scrollToCenter() {
55
+ function getActiveTab(): HTMLElement | null {
56
+
44
57
  if (!scrollable.value) {
45
- return;
58
+ return null;
46
59
  }
47
60
 
48
- const activeTab = scrollable.value.querySelector(
61
+ return scrollable.value.querySelector(
49
62
  '.active'
50
63
  ) as HTMLElement | null;
51
64
 
65
+ }
66
+
67
+ function getActiveTabSlot(): HTMLElement | null {
68
+
69
+ if (!scrollable.value) {
70
+ return null;
71
+ }
72
+
73
+ return scrollable.value.querySelector(
74
+ '.active .base-tab-item-slot'
75
+ ) as HTMLElement | null;
76
+
77
+ }
78
+
79
+ function scrollToCenter() {
80
+ if (!scrollable.value) {
81
+ return;
82
+ }
83
+
84
+ const activeTab = getActiveTab();
85
+
52
86
  if (!activeTab) {
53
87
  return;
54
88
  }
@@ -56,14 +90,69 @@ function scrollToCenter() {
56
90
  const scrollableRect = scrollable.value.getBoundingClientRect();
57
91
  const activeTabRect = activeTab.getBoundingClientRect();
58
92
 
59
- const scrollLeft =
60
- activeTab.offsetLeft - (scrollableRect.width - activeTabRect.width) / 2;
93
+ const scrollLeft = activeTab.offsetLeft - (scrollableRect.width - activeTabRect.width) / 2;
61
94
 
62
95
  scrollable.value.scrollTo({
63
96
  left: scrollLeft,
64
97
  behavior: 'smooth',
65
98
  });
66
99
  }
100
+
101
+ // Line animation
102
+
103
+ const lineRef = ref<HTMLElement | null>(null);
104
+
105
+ onMounted(() => {
106
+ nextTick(() => {
107
+ animateLine(false);
108
+ });
109
+ });
110
+
111
+ function animateLine(animate = true) {
112
+
113
+ const activeTabSlot = getActiveTabSlot();
114
+
115
+ if (!scrollable.value) {
116
+ return;
117
+ }
118
+
119
+ if (!lineRef.value) {
120
+ return;
121
+ }
122
+
123
+ if (!activeTabSlot) {
124
+ return;
125
+ }
126
+
127
+ const width = activeTabSlot.clientWidth;
128
+ const activeTabSlotRect = activeTabSlot.getBoundingClientRect();
129
+ const scrollableRect = scrollable.value.getBoundingClientRect();
130
+
131
+ const x = activeTabSlotRect.left - scrollableRect.left + scrollable.value.scrollLeft;
132
+
133
+ lineRef.value.style.visibility = 'visible';
134
+
135
+ if (!animate) {
136
+ lineRef.value.style.transform = `translateX(${x}px)`;
137
+ lineRef.value.style.width = `${width}px`;
138
+ return;
139
+ }
140
+
141
+ lineRef.value.animate(
142
+ [
143
+ {
144
+ transform: `translateX(${x}px)`,
145
+ width: `${width}px`,
146
+ },
147
+ ],
148
+ {
149
+ duration: 200,
150
+ easing: 'ease-in-out',
151
+ fill: 'both',
152
+ }
153
+ );
154
+
155
+ }
67
156
  </script>
68
157
 
69
158
  <style scoped>
@@ -3,6 +3,7 @@ import { ActionColors } from ".";
3
3
 
4
4
  export interface ActionItem {
5
5
  label?: string;
6
+ description?: string;
6
7
  href?: string;
7
8
  to?: RouteLocationRaw;
8
9
  action?: () => Promise<void> | void;
@@ -237,3 +237,5 @@ export interface BaseCropperConfig {
237
237
  presetOptions?: Record<string, any>;
238
238
  saveOptions?: ResultOptions;
239
239
  }
240
+
241
+ export { ActionItem } from './ActionItem';