-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
226 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<template> | ||
<Story> | ||
<Story group="top"> | ||
This is a demo book using Vue 3. | ||
</Story> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
packages/histoire/src/client/app/components/tree/StoryGroup.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<script lang="ts" setup> | ||
import type { Story, TreeGroup, TreeFolder, TreeLeaf } from '../../types' | ||
import StoryListItem from './StoryListItem.vue' | ||
import StoryListFolder from './StoryListFolder.vue' | ||
import { Icon } from '@iconify/vue' | ||
import { computed, withDefaults } from 'vue' | ||
import { useStoryStore } from '../../stores/story' | ||
const props = withDefaults(defineProps<{ | ||
path?: Array<string> | ||
group: TreeGroup | ||
stories: Story[] | ||
}>(), { | ||
path: () => [], | ||
}) | ||
const storyStore = useStoryStore() | ||
const folderPath = computed(() => [...props.path, props.group.title]) | ||
const isFolderOpen = computed(() => storyStore.isFolderOpened(folderPath.value, true)) | ||
function toggleOpen () { | ||
storyStore.toggleFolder(folderPath.value, false) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div | ||
data-test-id="story-group" | ||
class="htw-my-2 first:htw-mt-0 last:htw-mb-0" | ||
> | ||
<div | ||
v-if="group.title" | ||
role="button" | ||
tabindex="0" | ||
class="htw-px-0.5 htw-py-2 md:htw-py-1.5 htw-mx-1 htw-rounded-sm hover:htw-bg-primary-100 dark:hover:htw-bg-primary-900 htw-cursor-pointer htw-select-none htw-flex htw-items-center htw-gap-1 htw-min-w-0" | ||
@click="toggleOpen" | ||
@keyup.enter="toggleOpen" | ||
@keyup.space="toggleOpen" | ||
> | ||
<Icon | ||
icon="carbon:caret-right" | ||
class="htw-w-4 htw-h-4 htw-transition-transform htw-duration-150 htw-opacity-30 htw-flex-none" | ||
:class="{ | ||
'htw-rotate-90': isFolderOpen, | ||
}" | ||
/> | ||
<span class="htw-truncate htw-opacity-50">{{ group.title }}</span> | ||
<span class="htw-h-[1px] htw-flex-1 htw-bg-gray-500/10 htw-mx-2" /> | ||
</div> | ||
|
||
<!-- Children --> | ||
<div | ||
v-if="isFolderOpen" | ||
> | ||
<template | ||
v-for="element of group.children" | ||
:key="element.title" | ||
> | ||
<StoryListFolder | ||
v-if="(element as TreeFolder).children" | ||
:path="folderPath" | ||
:folder="(element as TreeFolder)" | ||
:stories="stories" | ||
:depth="0" | ||
/> | ||
<StoryListItem | ||
v-else | ||
:story="stories[(element as TreeLeaf).index]" | ||
:depth="0" | ||
/> | ||
</template> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.