Skip to content

Commit 8dcf5e8

Browse files
Updated the link design
1 parent 7459391 commit 8dcf5e8

1 file changed

Lines changed: 35 additions & 20 deletions

File tree

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

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<header>
1313

1414
<KToolbar
15+
ref="toolbar"
1516
type="clear"
1617
:style="{
1718
overflowX: 'auto',
@@ -21,16 +22,13 @@
2122
:raised="false"
2223
>
2324
<template #icon>
24-
<!-- Menu button for logged in users -->
2525
<KIconButton
2626
v-if="loggedIn"
2727
icon="menu"
2828
:color="$themeTokens.text"
2929
:ariaLabel="$tr('openMenu')"
3030
@click="toggleSidePanel"
3131
/>
32-
33-
<!-- Logo link for non-logged in users -->
3432
<KExternalLink
3533
v-else
3634
:href="homeLink"
@@ -45,11 +43,11 @@
4543

4644
<template #brand>
4745
<div
48-
class="text-truncate"
46+
class="studio-navigation__title-container"
4947
style="max-width: 160px"
5048
>
51-
<span class="studio-navigation__title">
52-
{{ title || $tr('title') }}
49+
<span>
50+
{{ truncatedTitle }}
5351
</span>
5452
</div>
5553
</template>
@@ -120,10 +118,6 @@
120118
</KToolbar>
121119

122120
</header>
123-
124-
125-
126-
<!-- Tabs extension area (for when tabs are provided) -->
127121
<div
128122
v-if="hasTabs"
129123
:aria-label="$tr('mainNavigationLabel')"
@@ -164,8 +158,6 @@
164158
</div>
165159
</div>
166160
</div>
167-
168-
<!-- Side panel (replaces MainNavigationDrawer) -->
169161
<SidePanelModal
170162
v-if="loggedIn && sidePanelOpen"
171163
alignment="left"
@@ -284,8 +276,6 @@
284276
</div>
285277
</template>
286278
</SidePanelModal>
287-
288-
<!-- Language Switcher Modal -->
289279
<LanguageSwitcherModal
290280
v-if="showLanguageModal"
291281
:style="{ color: $themeTokens.text }"
@@ -326,6 +316,7 @@
326316
isOverflowing: false,
327317
canScrollLeft: false,
328318
canScrollRight: false,
319+
toolbarWidth: 0,
329320
};
330321
},
331322
computed: {
@@ -354,6 +345,14 @@
354345
copyrightLink() {
355346
return 'https://learningequality.org/';
356347
},
348+
truncatedTitle() {
349+
const displayTitle = this.title || this.$tr('title');
350+
const offset = (this.$refs.studioNavigationActions?.clientWidth || 0) + 100;
351+
const averageCharWidth = 10;
352+
const availableWidth = this.toolbarWidth - offset;
353+
const maxChars = availableWidth > 0 ? Math.floor(availableWidth / averageCharWidth) : 1;
354+
return this.truncateText(displayTitle, maxChars);
355+
},
357356
userMenuItems() {
358357
const items = [];
359358
@@ -408,7 +407,8 @@
408407
mounted() {
409408
this.updateTabIndices();
410409
this.updateWindowWidth();
411-
window.addEventListener('resize', this.updateWindowWidth);
410+
this.updateToolbarWidth();
411+
window.addEventListener('resize', this.handleResize);
412412
const el = this.$refs.tabsContainer;
413413
if (el) {
414414
el.addEventListener('scroll', this.checkScrollPositions);
@@ -421,10 +421,11 @@
421421
updated() {
422422
this.$nextTick(() => {
423423
this.updateTabIndices();
424+
this.updateToolbarWidth();
424425
});
425426
},
426427
beforeDestroy() {
427-
window.removeEventListener('resize', this.updateWindowWidth);
428+
window.removeEventListener('resize', this.handleResize);
428429
},
429430
methods: {
430431
...mapActions(['logout']),
@@ -510,9 +511,22 @@
510511
this.sidePanelOpen = false;
511512
this.showLanguageModal = true;
512513
},
514+
handleResize() {
515+
this.updateWindowWidth();
516+
this.updateToolbarWidth();
517+
},
513518
updateWindowWidth() {
514519
this.windowWidth = window.innerWidth;
515520
},
521+
updateToolbarWidth() {
522+
this.toolbarWidth = this.$refs.studioNavigation?.clientWidth || 0;
523+
},
524+
truncateText(value, maxLength) {
525+
if (value && value.length > maxLength) {
526+
return value.substring(0, maxLength) + '...';
527+
}
528+
return value;
529+
},
516530
handleTabsKeydown(event) {
517531
const tabs = this.getTabElements();
518532
if (!tabs.length) return;
@@ -633,9 +647,11 @@
633647
}
634648
}
635649
636-
.studio-navigation__title {
637-
display: block;
638-
width: 100%;
650+
.studio-navigation__title-container {
651+
display: block;
652+
overflow: hidden;
653+
white-space: nowrap;
654+
text-overflow: ellipsis;
639655
font-size: 20px;
640656
font-weight: 500;
641657
padding-inline-start: 20px;
@@ -649,7 +665,6 @@
649665
650666
.studio-navigation__actions {
651667
display: flex;
652-
gap: 16px;
653668
align-items: center;
654669
}
655670

0 commit comments

Comments
 (0)