Skip to content

Commit b9d10a6

Browse files
Updated the sliding indicator
1 parent 216ab7b commit b9d10a6

2 files changed

Lines changed: 47 additions & 20 deletions

File tree

contentcuration/contentcuration/frontend/shared/views/StudioNavigation.vue

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@
142142
@keydown="handleTabsKeydown"
143143
>
144144
<slot name="tabs"></slot>
145+
<div
146+
class="sliding-indicator"
147+
:style="[indicatorStyle, { backgroundColor: $themeTokens.surface }]"
148+
></div>
145149
</div>
146150

147151
<div
@@ -317,8 +321,13 @@
317321
canScrollLeft: false,
318322
canScrollRight: false,
319323
toolbarWidth: 0,
324+
indicatorStyle: {
325+
width: '0px',
326+
transform: 'translateX(0px)',
327+
},
320328
};
321329
},
330+
322331
computed: {
323332
...mapState({
324333
user: state => state.session.currentUser,
@@ -404,11 +413,20 @@
404413
];
405414
},
406415
},
416+
watch: {
417+
'$route'() {
418+
this.$nextTick(() => {
419+
this.moveIndicator();
420+
});
421+
},
422+
},
407423
mounted() {
408424
this.updateTabIndices();
409425
this.updateWindowWidth();
410426
this.updateToolbarWidth();
411427
window.addEventListener('resize', this.handleResize);
428+
window.addEventListener('resize', this.moveIndicator);
429+
this.$nextTick(() => this.moveIndicator());
412430
const el = this.$refs.tabsContainer;
413431
if (el) {
414432
el.addEventListener('scroll', this.checkScrollPositions);
@@ -426,12 +444,29 @@
426444
},
427445
beforeDestroy() {
428446
window.removeEventListener('resize', this.handleResize);
447+
window.removeEventListener('resize', this.moveIndicator);
429448
},
430449
methods: {
431450
...mapActions(['logout']),
432451
toggleSidePanel() {
433452
this.sidePanelOpen = !this.sidePanelOpen;
434453
},
454+
moveIndicator() {
455+
const container = this.$refs.tabsContainer;
456+
if (!container) return;
457+
const activeTab = container.querySelector('.studio-navigation-tab--active');
458+
459+
if (activeTab) {
460+
const containerRect = container.getBoundingClientRect();
461+
const tabRect = activeTab.getBoundingClientRect();
462+
const leftPosition = tabRect.left - containerRect.left + container.scrollLeft;
463+
464+
this.indicatorStyle = {
465+
width: `${tabRect.width}px`,
466+
transform: `translateX(${leftPosition}px)`,
467+
};
468+
}
469+
},
435470
checkScrollPositions() {
436471
const el = this.$refs.tabsContainer;
437472
if (!el) return;
@@ -697,6 +732,7 @@
697732
}
698733
699734
.studio-navigation__tabs-container {
735+
position: relative;
700736
display: flex;
701737
flex: 1;
702738
padding: 0 24px;
@@ -707,6 +743,16 @@
707743
scrollbar-width: none;
708744
scroll-behavior: auto;
709745
}
746+
.sliding-indicator {
747+
position: absolute;
748+
bottom: 0;
749+
left: 0;
750+
height: 2px;
751+
752+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
753+
pointer-events: none;
754+
z-index: 1;
755+
}
710756
711757
/* Side panel styles */
712758
.side-panel-header {

contentcuration/contentcuration/frontend/shared/views/StudioNavigationTab.vue

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
{{ badgeValue }}
2828
</span>
2929
</span>
30-
<span
31-
v-if="isActive"
32-
class="studio-navigation-tab__indicator"
33-
:style="indicatorStyles"
34-
aria-hidden="true"
35-
></span>
3630
</RouterLink>
3731

3832
</template>
@@ -42,7 +36,6 @@
4236
4337
export default {
4438
name: 'StudioNavigationTab',
45-
inject: ['$themeTokens'],
4639
props: {
4740
to: {
4841
type: [String, Object],
@@ -74,11 +67,7 @@
7467
color: this.$themeTokens.text,
7568
};
7669
},
77-
indicatorStyles() {
78-
return {
79-
backgroundColor: this.$themeTokens.surface,
80-
};
81-
},
70+
8271
isActive() {
8372
if (!this.to || !this.$route) return false;
8473
@@ -154,12 +143,4 @@
154143
transition: 0.3s;
155144
}
156145
157-
.studio-navigation-tab__indicator {
158-
position: absolute;
159-
bottom: 0;
160-
left: 0;
161-
width: 100%;
162-
height: 2px;
163-
}
164-
165146
</style>

0 commit comments

Comments
 (0)