@citizenplane/pimp 10.0.5 → 10.0.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/pimp.es.js +150 -150
- package/dist/pimp.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CpTabs.vue +32 -25
- package/src/stories/CpTabs.stories.ts +1 -1
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</template>
|
|
26
26
|
|
|
27
27
|
<script setup lang="ts">
|
|
28
|
-
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
28
|
+
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
29
29
|
|
|
30
30
|
type EmitType = {
|
|
31
31
|
(e: 'onTabClick', index: number): void
|
|
@@ -41,9 +41,7 @@ interface Props {
|
|
|
41
41
|
}[]
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
45
|
-
defaultActiveIndex: 0,
|
|
46
|
-
})
|
|
44
|
+
const props = withDefaults(defineProps<Props>(), { defaultActiveIndex: 0 })
|
|
47
45
|
|
|
48
46
|
const emit = defineEmits<EmitType>()
|
|
49
47
|
|
|
@@ -88,15 +86,16 @@ const getUnderlineElement = () => {
|
|
|
88
86
|
const setUnderlineStyle = () => {
|
|
89
87
|
const activeTabElement = getActiveTabElement()
|
|
90
88
|
const underlineElement = getUnderlineElement()
|
|
89
|
+
const containerElement = cpTabsElement.value
|
|
91
90
|
|
|
92
|
-
if (!activeTabElement) return
|
|
91
|
+
if (!activeTabElement || !underlineElement || !containerElement) return
|
|
93
92
|
|
|
94
|
-
const
|
|
93
|
+
const tabRect = activeTabElement.getBoundingClientRect()
|
|
94
|
+
const containerRect = containerElement.getBoundingClientRect()
|
|
95
|
+
const left = tabRect.left - containerRect.left + containerElement.scrollLeft
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
underlineElement.style.width = `${clientWidth}px`
|
|
99
|
-
underlineElement.style.transform = `translate3d(${offsetLeft}px, 0, 0)`
|
|
97
|
+
underlineElement.style.width = `${tabRect.width}px`
|
|
98
|
+
underlineElement.style.transform = `translate3d(${left}px, 0, 0)`
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
const scrollToActiveElement = () => {
|
|
@@ -111,11 +110,12 @@ onBeforeUnmount(() => window.removeEventListener('resize', setUnderlineStyle))
|
|
|
111
110
|
onMounted(() => {
|
|
112
111
|
window.addEventListener('resize', setUnderlineStyle)
|
|
113
112
|
|
|
114
|
-
setUnderlineStyle()
|
|
115
113
|
activeTabIndex.value = props.defaultActiveIndex
|
|
114
|
+
|
|
115
|
+
nextTick(setUnderlineStyle)
|
|
116
116
|
})
|
|
117
117
|
|
|
118
|
-
watch(activeTabIndex, () => setUnderlineStyle
|
|
118
|
+
watch(activeTabIndex, () => nextTick(setUnderlineStyle))
|
|
119
119
|
|
|
120
120
|
watch(
|
|
121
121
|
() => props.defaultActiveIndex,
|
|
@@ -131,19 +131,10 @@ watch(
|
|
|
131
131
|
|
|
132
132
|
/* Scrolling Visual Cue */
|
|
133
133
|
background:
|
|
134
|
-
linear-gradient(
|
|
135
|
-
linear-gradient(
|
|
136
|
-
radial-gradient(
|
|
137
|
-
|
|
138
|
-
rgba(fn.v(foreground-secondary), 0.2),
|
|
139
|
-
rgba(fn.v(foreground-secondary), 0)
|
|
140
|
-
),
|
|
141
|
-
radial-gradient(
|
|
142
|
-
farthest-side at 100% 50%,
|
|
143
|
-
rgba(fn.v(foreground-secondary), 0.2),
|
|
144
|
-
rgba(fn.v(foreground-secondary), 0)
|
|
145
|
-
)
|
|
146
|
-
0 100%;
|
|
134
|
+
linear-gradient(90deg, #fff 30%, #fff0),
|
|
135
|
+
linear-gradient(90deg, #fff0, #fff 70%) 0 100%,
|
|
136
|
+
radial-gradient(farthest-side at 0 50%, #3e3e5b33, #3e3e5b00),
|
|
137
|
+
radial-gradient(farthest-side at 100% 50%, #3e3e5b33, #3e3e5b00) 0 100%;
|
|
147
138
|
background-attachment: local, local, scroll, scroll;
|
|
148
139
|
background-color: fn.v(background-primary);
|
|
149
140
|
background-position:
|
|
@@ -222,4 +213,20 @@ watch(
|
|
|
222
213
|
border-radius: fn.px-to-rem(4);
|
|
223
214
|
}
|
|
224
215
|
}
|
|
216
|
+
|
|
217
|
+
@include mx.media-query-max(768px) {
|
|
218
|
+
.cpTabs {
|
|
219
|
+
margin-right: sp.$space-lg;
|
|
220
|
+
padding: fn.px-to-rem(3) 0;
|
|
221
|
+
overflow-x: auto;
|
|
222
|
+
|
|
223
|
+
&__activeUnderline {
|
|
224
|
+
top: auto;
|
|
225
|
+
bottom: auto;
|
|
226
|
+
height: 100%;
|
|
227
|
+
border-radius: var(--pimp-radius-md);
|
|
228
|
+
opacity: 0.14;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
225
232
|
</style>
|
|
@@ -40,7 +40,7 @@ export const Default: Story = {
|
|
|
40
40
|
args: {
|
|
41
41
|
defaultActiveIndex: 0,
|
|
42
42
|
isLoading: false,
|
|
43
|
-
tabs: [{ title: 'Tab 1' }, { title: 'Tab 2' }, { title: 'Tab 3' }],
|
|
43
|
+
tabs: [{ title: 'Tab 1' }, { title: 'Tab 2' }, { title: 'Tab 3' }, { title: 'Tab 4' }],
|
|
44
44
|
onOnTabClick: action('tab-clicked'),
|
|
45
45
|
},
|
|
46
46
|
render: defaultRender,
|