Skip to content

Commit

Permalink
Add badge title support (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoglo authored Jul 22, 2024
1 parent 3155434 commit 7ef9d8d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
68 changes: 65 additions & 3 deletions src/components/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<template>
<div class="layout-main">
<header class="layout-main__header" :class="{ 'layout-main__header--margin': !$slots.search }">
<div class="layout-main__logo"><img src="../../assets/images/logo.svg" width="40" height="40" alt="Contao Logo" />Contao Manager</div>
<header class="layout-main__header" :class="{ 'layout-main__header--margin': !$slots.search, 'layout-main__has-badge-title': badgeTitle }">
<div class="layout-main__logo"><img src="../../assets/images/logo.svg" width="40" height="40" alt="Contao Logo" />
<span class="layout-main__title">
<span class="layout-main__manager-title">Contao Manager</span>
<span v-if="badgeTitle" class="layout-main__badge-title">{{ badgeTitle }}</span>
</span>
</div>
<navigation-fragment/>
</header>

Expand All @@ -25,7 +30,7 @@
</template>

<script>
import { mapState } from 'vuex';
import { mapState, mapGetters } from 'vuex';
import NavigationFragment from '../fragments/NavigationFragment';
import FooterFragment from '../fragments/FooterFragment';
Expand All @@ -35,9 +40,16 @@
computed: {
...mapState('algolia', ['news']),
...mapGetters('server/contao', ['badgeTitle']),
currentNews: vm => vm.news.length ? vm.news[0] : null,
},
mounted () {
// Fetch the Contao config for the badge title.
// This is most likely already done by the boot process.
this.$store.dispatch('server/contao/get');
}
};
</script>

Expand All @@ -59,6 +71,24 @@
}
}
&__badge-title {
background: var(--border);
color: var(--text);
padding: 2px 5px;
position: relative;
top: -5px;
border-radius: 8px;
font-size: .75rem;
font-weight: 600;
line-height: 1;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
word-break: break-word;
overflow: hidden;
text-overflow: ellipsis;
}
&__subheader {
margin: 0 0 45px;
padding: 20px 0;
Expand Down Expand Up @@ -109,6 +139,31 @@
margin: 0 20px;
}
&__has-badge-title {
display: flex;
justify-content: space-between;
.layout-main__logo {
display: flex;
}
.layout-main__title {
display: flex;
flex-wrap: wrap;
align-items: center;
line-height: 1;
column-gap: 10px;
// Counter top positioning for row-wrap
row-gap: 5px;
}
}
@media (max-width: 600px) {
&__badge-title {
max-width: 220px;
}
}
@include screen(700) {
&__subheader-inside {
flex-direction: row;
Expand All @@ -120,6 +175,13 @@
}
@include screen(1024) {
&__has-badge-title {
// Do not allow wrapping navigation items
.navigation__group--main {
display: flex;
}
}
&__subheader-inside,
&__content,
footer {
Expand Down
4 changes: 4 additions & 0 deletions src/store/server/contao.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default {
contaoConfig: null,
},

getters: {
badgeTitle: state => state.contaoConfig?.backend?.badge_title,
},

mutations: {
setCache(state, response) {
state.cache = response;
Expand Down

0 comments on commit 7ef9d8d

Please sign in to comment.