dml_frontend/components/Breadcrumbs.vue
2025-05-21 15:53:22 +02:00

118 lines
3.4 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<nav v-if="breadcrumbs && breadcrumbs.length" class="breadcrumbs" aria-label="Breadcrumb">
<ul>
<li>
<router-link to="/" aria-label="Startseite">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" aria-hidden="true" focusable="false">
<title>Startseite</title>
<path d="M575.8 255.5c0 18-15 32.1-32 32.1l-32 0 .7 160.2c0 2.7-.2 5.4-.5 8.1l0 16.2c0 22.1-17.9 40-40 40l-16 0c-1.1 0-2.2 0-3.3-.1c-1.4 .1-2.8 .1-4.2 .1L416 512l-24 0c-22.1 0-40-17.9-40-40l0-24 0-64c0-17.7-14.3-32-32-32l-64 0c-17.7 0-32 14.3-32 32l0 64 0 24c0 22.1-17.9 40-40 40l-24 0-31.9 0c-1.5 0-3-.1-4.5-.2c-1.2 .1-2.4 .2-3.6 .2l-16 0c-22.1 0-40-17.9-40-40l0-112c0-.9 0-1.9 .1-2.8l0-69.7-32 0c-18 0-32-14-32-32.1c0-9 3-17 10-24L266.4 8c7-7 15-8 22-8s15 2 21 7L564.8 231.5c8 7 12 15 11 24z"/>
</svg>
</router-link>
</li>
<li v-for="(crumb, index) in breadcrumbs" :key="index">
<router-link v-if="index < breadcrumbs.length - 1" :to="crumb.to">
{{ crumb.label }}
</router-link>
<span v-else>{{ crumb.label }}</span>
</li>
</ul>
</nav>
</template>
<script>
import { useI18n } from 'vue-i18n'
export default {
name: 'Breadcrumb',
computed: {
breadcrumbs() {
const locale = this.$i18n.locale // aktives Sprachpräfix (z.B. "en", "de", etc.)
const pathWithoutLang = this.$route.path.replace(`/${locale}`, '') // Sprachprefix entfernen
const pathArray = pathWithoutLang.split('/').filter(p => p)
let path = ''
return pathArray.map(segment => {
path += '/' + segment
return {
label: this.formatLabel(segment),
to: `/${locale}${path}` // Sprachprefix im Link wieder einfügen
}
})
}
},
methods: {
formatLabel(segment) {
return segment.charAt(0).toUpperCase() + segment.slice(1).replace(/-/g, ' ')
}
}
}
</script>
<style lang="sass">
.breadcrumbs
position: fixed
top: 22vh
left: 0
text-align: left
padding: 1rem .25rem 1rem .5rem
//min-width: 200px
background-color: rgba(white, .98)
border: 1px solid darken($lightgrey, 5%)
writing-mode: vertical-rl
transform: rotate(180deg)
//border-bottom-left-radius: .65rem
border-top-left-radius: .8rem
border-bottom-left-radius: .8rem
text-transform: uppercase
letter-spacing: .05rem
z-index: 22
ul
display: flex
flex-wrap: wrap
list-style: none
padding: 0
margin: 0
gap: 0.5rem
cursor: pointer
li
display: flex
align-items: center
color: darken($primaryColor, 10%)
font-size: .7rem
svg
width: .8rem
height: .8rem
transform: rotate(90deg)
margin-bottom: .35rem
transition: .3s
path
fill: darken($lightgrey, 20%)
&:hover
transform: scale(1.3) rotate(90deg)
path
fill: darken($lightgrey, 30%)
&::after
content: '>'
margin: 0 0.5rem
color: $pink
&:last-child::after
content: ''
a
color: #007BFF
text-decoration: none
&:hover
transform: scale(1.2)
span
font-weight: bold
</style>