/
Breadcrumb.vue
98 lines (86 loc) · 2.22 KB
/
Breadcrumb.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<script lang="ts" setup>
import { computed, ref, watch } from 'vue'
import { Icon } from '@iconify/vue'
import { useStoryStore } from '../../stores/story'
import { Story, Tree } from '../../types'
import MobileOverlay from './MobileOverlay.vue'
import StoryList from '../tree/StoryList.vue'
defineProps<{
tree: Tree
stories: Story[]
}>()
const storyStore = useStoryStore()
const story = computed(() => storyStore.currentStory)
const folders = computed(() => {
return story.value.file.path.slice(0, -1)
})
const isMenuOpened = ref(false)
function openMenu () {
isMenuOpened.value = true
}
function closeMenu () {
isMenuOpened.value = false
}
watch(story, () => {
isMenuOpened.value = false
})
</script>
<template>
<div class="histoire-breadcrumb">
<a
class="htw-px-6 htw-h-12 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-flex htw-gap-2 htw-flex-wrap htw-w-full htw-items-center"
@click="openMenu"
>
<template v-if="story">
<template
v-for="(file, key) of folders"
:key="key"
>
<span>
{{ file }}
</span>
<span class="htw-opacity-40">
/
</span>
</template>
<span class="htw-flex htw-items-center htw-gap-2">
<Icon
:icon="story.icon ?? 'carbon:cube'"
class="htw-w-5 htw-h-5 htw-flex-none"
:class="{
'htw-text-primary-500': !story.iconColor,
'bind-icon-color': story.iconColor,
}"
/>
{{ story.title }}
<span class="htw-opacity-40 htw-text-sm">
{{ story.variants.length }}
</span>
</span>
</template>
<template v-else>
Select a story...
</template>
<Icon
icon="carbon:chevron-sort"
class="htw-w-5 htw-h-5 htw-shrink-0 htw-ml-auto"
/>
</a>
</div>
<MobileOverlay
title="Select a story"
:opened="isMenuOpened"
@close="closeMenu"
>
<StoryList
:tree="tree"
:stories="stories"
class="htw-flex-1 htw-overflow-y-scroll"
/>
</MobileOverlay>
</template>
<style scoped>
.bind-icon-color {
color: v-bind('story?.iconColor');
}
</style>