histoire 0.2.5 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/app/App.vue +8 -3
- package/dist/client/app/codegen/const.d.ts +1 -0
- package/dist/client/app/codegen/const.js +3 -0
- package/dist/client/app/codegen/vue3.js +83 -21
- package/dist/client/app/codegen/vue3.js.map +1 -0
- package/dist/client/app/components/base/BaseEmpty.vue +17 -1
- package/dist/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/dist/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/dist/client/app/components/exposed/Story.vue +33 -1
- package/dist/client/app/components/exposed/Variant.vue +19 -1
- package/dist/client/app/components/panel/PaneTabs.vue +64 -0
- package/dist/client/app/components/{story → panel}/StoryControls.vue +6 -1
- package/dist/client/app/components/{story → panel}/StoryDocs.vue +18 -11
- package/dist/client/app/components/panel/StoryEvent.vue +53 -0
- package/dist/client/app/components/panel/StoryEvents.vue +45 -0
- package/{src/client/app/components/story → dist/client/app/components/panel}/StorySidePanel.vue +17 -20
- package/{src/client/app/components/story → dist/client/app/components/panel}/StorySourceCode.vue +24 -14
- package/dist/client/app/components/sandbox/SandboxVue3.vue +16 -4
- package/dist/client/app/components/sandbox/lib.js +2 -1
- package/dist/client/app/components/search/SearchLoading.vue +16 -0
- package/dist/client/app/components/search/SearchModal.vue +12 -149
- package/dist/client/app/components/search/SearchPane.vue +210 -0
- package/dist/client/app/components/search/search-data.d.ts +2 -0
- package/dist/client/app/components/search/search-data.js +8 -0
- package/dist/client/app/components/search/search-data.js.map +1 -0
- package/dist/client/app/components/story/StoryResponsivePreview.vue +9 -98
- package/dist/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/dist/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/dist/client/app/components/story/StoryView.vue +17 -3
- package/dist/client/app/components/story/StoryViewer.vue +2 -92
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantBackground.vue +3 -3
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantNewTab.vue +2 -2
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantResponsiveSize.vue +3 -3
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
- package/dist/client/app/components/tree/StoryGroup.vue +4 -4
- package/dist/client/app/components/tree/StoryListFolder.vue +4 -4
- package/dist/client/app/components/tree/StoryListItem.vue +4 -1
- package/dist/client/app/global-components.js +1 -0
- package/dist/client/app/global-components.js.map +1 -0
- package/dist/client/app/index.js +1 -0
- package/dist/client/app/index.js.map +1 -0
- package/dist/client/app/router.d.ts +1 -0
- package/dist/client/app/router.js +3 -1
- package/dist/client/app/sandbox.js +12 -1
- package/dist/client/app/sandbox.js.map +1 -0
- package/dist/client/app/stores/events.d.ts +29 -0
- package/dist/client/app/stores/events.js +26 -0
- package/dist/client/app/stores/events.js.map +1 -0
- package/dist/client/app/stores/folder.d.ts +10 -0
- package/dist/client/app/stores/folder.js +48 -0
- package/dist/client/app/stores/folder.js.map +1 -0
- package/dist/client/app/stores/story.d.ts +41 -8
- package/dist/client/app/stores/story.js +21 -33
- package/dist/client/app/stores/story.js.map +1 -0
- package/dist/client/app/style/main.pcss +5 -0
- package/dist/client/app/style/sandbox.css +2 -0
- package/dist/client/app/style/transitions.pcss +13 -0
- package/dist/client/app/types.d.ts +4 -0
- package/dist/client/app/types.js +1 -0
- package/dist/client/app/types.js.map +1 -0
- package/dist/client/app/util/const.d.ts +1 -0
- package/dist/client/app/util/const.js +1 -0
- package/dist/client/app/util/events.d.ts +1 -0
- package/dist/client/app/util/events.js +32 -0
- package/dist/client/app/util/events.js.map +1 -0
- package/dist/client/app/util/keyboard.js +1 -0
- package/dist/client/app/util/keyboard.js.map +1 -0
- package/dist/client/app/util/mapping.js +5 -2
- package/dist/client/app/util/mapping.js.map +1 -0
- package/dist/client/app/util/preview-settings.js +1 -0
- package/dist/client/app/util/preview-settings.js.map +1 -0
- package/dist/client/app/util/reactivity.js +1 -0
- package/dist/client/app/util/reactivity.js.map +1 -0
- package/dist/client/app/util/scroll.js +1 -0
- package/dist/client/app/util/scroll.js.map +1 -0
- package/dist/client/app/util/variant.js +1 -0
- package/dist/client/app/util/variant.js.map +1 -0
- package/dist/client/index.d.ts +4 -3
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -0
- package/dist/client/server/index.d.ts +7 -2
- package/dist/client/server/index.js +8 -26
- package/{src/client/server/Story.server.vue → dist/client/server/vue3/Story.vue} +14 -3
- package/dist/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
- package/dist/client/server/vue3/run.d.ts +2 -0
- package/dist/client/server/vue3/run.js +33 -0
- package/dist/client/server/vue3/run.js.map +1 -0
- package/dist/controls.js +1 -0
- package/dist/controls.js.map +1 -0
- package/dist/node/alias.d.ts +2 -1
- package/dist/node/alias.js +3 -2
- package/dist/node/build.js +74 -21
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts +5 -0
- package/dist/node/builtin-plugins/tailwind-tokens.js +510 -0
- package/dist/node/collect/index.js +3 -1
- package/dist/node/collect/worker.js +6 -2
- package/dist/node/commands/preview.js +4 -25
- package/dist/node/config.d.ts +103 -3
- package/dist/node/config.js +40 -23
- package/dist/node/context.d.ts +3 -3
- package/dist/node/context.js +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/load.d.ts +12 -0
- package/dist/node/load.js +42 -0
- package/dist/node/plugin.d.ts +67 -11
- package/dist/node/plugin.js +42 -245
- package/dist/node/preview.d.ts +8 -0
- package/dist/node/preview.js +41 -0
- package/dist/node/search.d.ts +2 -0
- package/dist/node/search.js +68 -0
- package/dist/node/server.js +43 -21
- package/dist/node/stories.d.ts +2 -0
- package/dist/node/stories.js +4 -4
- package/dist/node/types.d.ts +1 -0
- package/dist/node/util/find-up.d.ts +1 -0
- package/dist/node/util/find-up.js +20 -0
- package/dist/node/vite.d.ts +13 -0
- package/dist/node/vite.js +278 -0
- package/dist/style.css +174 -86
- package/package.json +7 -6
- package/scripts/copy.mjs +2 -1
- package/src/client/app/App.vue +8 -3
- package/src/client/app/codegen/const.ts +3 -0
- package/src/client/app/codegen/vue3.ts +80 -22
- package/src/client/app/components/base/BaseEmpty.vue +17 -1
- package/src/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/src/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/src/client/app/components/exposed/Story.vue +33 -1
- package/src/client/app/components/exposed/Variant.vue +19 -1
- package/src/client/app/components/panel/PaneTabs.vue +64 -0
- package/src/client/app/components/{story → panel}/StoryControls.vue +6 -1
- package/src/client/app/components/{story → panel}/StoryDocs.vue +18 -11
- package/src/client/app/components/panel/StoryEvent.vue +53 -0
- package/src/client/app/components/panel/StoryEvents.vue +45 -0
- package/{dist/client/app/components/story → src/client/app/components/panel}/StorySidePanel.vue +17 -20
- package/{dist/client/app/components/story → src/client/app/components/panel}/StorySourceCode.vue +24 -14
- package/src/client/app/components/sandbox/SandboxVue3.vue +16 -4
- package/src/client/app/components/sandbox/lib.ts +3 -1
- package/src/client/app/components/search/SearchLoading.vue +16 -0
- package/src/client/app/components/search/SearchModal.vue +12 -149
- package/src/client/app/components/search/SearchPane.vue +210 -0
- package/src/client/app/components/search/search-data.ts +9 -0
- package/src/client/app/components/story/StoryResponsivePreview.vue +9 -98
- package/src/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/src/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/src/client/app/components/story/StoryView.vue +17 -3
- package/src/client/app/components/story/StoryViewer.vue +2 -92
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantBackground.vue +3 -3
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantNewTab.vue +2 -2
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantResponsiveSize.vue +3 -3
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
- package/src/client/app/components/tree/StoryGroup.vue +4 -4
- package/src/client/app/components/tree/StoryListFolder.vue +4 -4
- package/src/client/app/components/tree/StoryListItem.vue +4 -1
- package/src/client/app/router.ts +4 -1
- package/src/client/app/sandbox.ts +11 -1
- package/src/client/app/stores/events.ts +36 -0
- package/{dist/client/app/stores/story.ts → src/client/app/stores/folder.ts} +16 -23
- package/src/client/app/stores/story.ts +21 -40
- package/src/client/app/style/main.pcss +5 -0
- package/src/client/app/style/sandbox.css +2 -0
- package/src/client/app/style/transitions.pcss +13 -0
- package/src/client/app/types.ts +5 -0
- package/src/client/app/util/const.ts +1 -0
- package/src/client/app/util/events.ts +30 -0
- package/src/client/app/util/mapping.ts +4 -2
- package/src/client/index.ts +4 -3
- package/src/client/server/index.ts +14 -27
- package/{dist/client/server/Story.server.vue → src/client/server/vue3/Story.vue} +14 -3
- package/src/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
- package/{dist/client/server/index.ts → src/client/server/vue3/run.ts} +10 -4
- package/src/node/alias.ts +4 -2
- package/src/node/build.ts +86 -21
- package/src/node/builtin-plugins/tailwind-tokens.ts +521 -0
- package/src/node/collect/index.ts +3 -1
- package/src/node/collect/worker.ts +7 -2
- package/src/node/commands/preview.ts +4 -33
- package/src/node/config.ts +53 -27
- package/src/node/context.ts +3 -3
- package/src/node/index.ts +1 -0
- package/src/node/load.ts +63 -0
- package/src/node/plugin.ts +75 -252
- package/src/node/preview.ts +56 -0
- package/src/node/search.ts +75 -0
- package/src/node/server.ts +49 -23
- package/src/node/stories.ts +4 -4
- package/src/node/types.ts +1 -0
- package/src/node/util/find-up.ts +24 -0
- package/src/node/vite.ts +296 -0
- package/tailwind.config.cjs +1 -0
- package/dist/client/app/codegen/serialize-js.ts +0 -119
- package/dist/client/app/codegen/util.ts +0 -79
- package/dist/client/app/codegen/vue3.ts +0 -276
- package/dist/client/app/components/sandbox/lib.ts +0 -8
- package/dist/client/app/global-components.ts +0 -13
- package/dist/client/app/index.ts +0 -28
- package/dist/client/app/router.ts +0 -17
- package/dist/client/app/sandbox.ts +0 -94
- package/dist/client/app/stores/preview-settings.ts +0 -17
- package/dist/client/app/types.ts +0 -78
- package/dist/client/app/util/config.ts +0 -6
- package/dist/client/app/util/const.ts +0 -3
- package/dist/client/app/util/dark.ts +0 -4
- package/dist/client/app/util/env.ts +0 -1
- package/dist/client/app/util/keyboard.ts +0 -99
- package/dist/client/app/util/mapping.ts +0 -48
- package/dist/client/app/util/preview-settings.ts +0 -8
- package/dist/client/app/util/reactivity.ts +0 -22
- package/dist/client/app/util/responsive.ts +0 -3
- package/dist/client/app/util/scroll.ts +0 -31
- package/dist/client/app/util/tooltip.ts +0 -13
- package/dist/client/app/util/variant.ts +0 -20
- package/dist/client/index.ts +0 -12
- package/dist/client/shim.d.ts +0 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { PropType, ref, watchEffect } from 'vue'
|
|
3
|
+
import { Icon } from '@iconify/vue'
|
|
3
4
|
import type { Story } from '../../types'
|
|
4
5
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
5
6
|
|
|
@@ -24,15 +25,21 @@ watchEffect(async () => {
|
|
|
24
25
|
</script>
|
|
25
26
|
|
|
26
27
|
<template>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
<div>
|
|
29
|
+
<BaseEmpty
|
|
30
|
+
v-if="!renderedDoc"
|
|
31
|
+
>
|
|
32
|
+
<Icon
|
|
33
|
+
icon="carbon:document-unknown"
|
|
34
|
+
class="htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
|
|
35
|
+
/>
|
|
36
|
+
No documentation available
|
|
37
|
+
</BaseEmpty>
|
|
38
|
+
<div
|
|
39
|
+
v-else
|
|
40
|
+
class="htw-prose dark:htw-prose-invert htw-p-4 htw-max-w-none"
|
|
41
|
+
data-test-id="story-docs"
|
|
42
|
+
v-html="renderedDoc"
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
38
45
|
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { HstEvent } from '../../stores/events'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
event: HstEvent
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const formattedArgument = computed(() => {
|
|
10
|
+
switch (typeof props.event.argument) {
|
|
11
|
+
case 'string':
|
|
12
|
+
return `"${props.event.argument}"`
|
|
13
|
+
case 'object':
|
|
14
|
+
return `{ ${Object.keys(props.event.argument).map((key) => `${key}: ${props.event.argument[key]}`).join(', ')} }`
|
|
15
|
+
default:
|
|
16
|
+
return props.event.argument
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<VDropdown
|
|
23
|
+
class="htw-group"
|
|
24
|
+
placement="right"
|
|
25
|
+
>
|
|
26
|
+
<template #default="{ shown }">
|
|
27
|
+
<div
|
|
28
|
+
class="group-hover:htw-bg-primary-100 dark:group-hover:htw-bg-primary-700 htw-cursor-pointer htw-py-2 htw-px-4 htw-flex htw-items-baseline htw-gap-1 htw-leading-normal"
|
|
29
|
+
:class="[
|
|
30
|
+
shown ? 'htw-bg-primary-50 dark:htw-bg-primary-600' : 'group-odd:htw-bg-gray-100/50 dark:group-odd:htw-bg-gray-750/40',
|
|
31
|
+
]"
|
|
32
|
+
>
|
|
33
|
+
<span
|
|
34
|
+
:class="{
|
|
35
|
+
'htw-text-primary-500': shown,
|
|
36
|
+
}"
|
|
37
|
+
>
|
|
38
|
+
{{ event.name }}
|
|
39
|
+
</span>
|
|
40
|
+
<span
|
|
41
|
+
v-if="event.argument"
|
|
42
|
+
class="htw-text-xs htw-opacity-50 htw-truncate"
|
|
43
|
+
>{{ formattedArgument }}</span>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<template #popper>
|
|
48
|
+
<div class="htw-overflow-auto htw-max-w-[400px] htw-max-h-[400px]">
|
|
49
|
+
<pre class="htw-p-4">{{ event.argument }}</pre>
|
|
50
|
+
</div>
|
|
51
|
+
</template>
|
|
52
|
+
</VDropdown>
|
|
53
|
+
</template>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ref, computed, watch, onMounted, nextTick } from 'vue'
|
|
3
|
+
import { Icon } from '@iconify/vue'
|
|
4
|
+
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
5
|
+
import { useEventsStore } from '../../stores/events'
|
|
6
|
+
import StoryEvent from './StoryEvent.vue'
|
|
7
|
+
|
|
8
|
+
const eventsStore = useEventsStore()
|
|
9
|
+
|
|
10
|
+
const hasEvents = computed(() => eventsStore.events.length)
|
|
11
|
+
|
|
12
|
+
onMounted(resetUnseen)
|
|
13
|
+
watch(() => eventsStore.unseen, resetUnseen)
|
|
14
|
+
|
|
15
|
+
async function resetUnseen () {
|
|
16
|
+
if (eventsStore.unseen > 0) {
|
|
17
|
+
eventsStore.unseen = 0
|
|
18
|
+
}
|
|
19
|
+
await nextTick()
|
|
20
|
+
eventsElement.value.scrollTo({ top: eventsElement.value.scrollHeight })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const eventsElement = ref<HTMLDivElement>()
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<div ref="eventsElement">
|
|
28
|
+
<BaseEmpty
|
|
29
|
+
v-if="!hasEvents"
|
|
30
|
+
>
|
|
31
|
+
<Icon
|
|
32
|
+
icon="carbon:event-schedule"
|
|
33
|
+
class="htw-w-8 htw-h-8 htw-opacity-50 htw-mb-6"
|
|
34
|
+
/>
|
|
35
|
+
No event fired
|
|
36
|
+
</BaseEmpty>
|
|
37
|
+
<div v-else>
|
|
38
|
+
<StoryEvent
|
|
39
|
+
v-for="(event, key) of eventsStore.events"
|
|
40
|
+
:key="key"
|
|
41
|
+
:event="event"
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
package/{src/client/app/components/story → dist/client/app/components/panel}/StorySidePanel.vue
RENAMED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useRoute } from 'vue-router'
|
|
3
4
|
import { useStoryStore } from '../../stores/story'
|
|
4
5
|
|
|
5
6
|
import BaseSplitPane from '../base/BaseSplitPane.vue'
|
|
6
7
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
7
|
-
import BaseTab from '../base/BaseTab.vue'
|
|
8
8
|
import StoryControls from './StoryControls.vue'
|
|
9
9
|
import StoryDocs from './StoryDocs.vue'
|
|
10
|
+
import StoryEvents from './StoryEvents.vue'
|
|
10
11
|
import StorySourceCode from './StorySourceCode.vue'
|
|
12
|
+
import PaneTabs from './PaneTabs.vue'
|
|
11
13
|
|
|
12
14
|
const storyStore = useStoryStore()
|
|
13
15
|
|
|
14
|
-
const router = useRouter()
|
|
15
16
|
const route = useRoute()
|
|
17
|
+
|
|
18
|
+
const panelContentComponent = computed(() => {
|
|
19
|
+
switch (route.query.tab) {
|
|
20
|
+
case 'docs':
|
|
21
|
+
return StoryDocs
|
|
22
|
+
case 'events':
|
|
23
|
+
return StoryEvents
|
|
24
|
+
default:
|
|
25
|
+
return StoryControls
|
|
26
|
+
}
|
|
27
|
+
})
|
|
16
28
|
</script>
|
|
17
29
|
|
|
18
30
|
<template>
|
|
@@ -33,25 +45,10 @@ const route = useRoute()
|
|
|
33
45
|
>
|
|
34
46
|
<template #first>
|
|
35
47
|
<div class="htw-flex htw-flex-col htw-h-full">
|
|
36
|
-
<
|
|
37
|
-
<BaseTab
|
|
38
|
-
:to="{ ...$route, query: { ...$route.query, tab: '' } }"
|
|
39
|
-
:matched="!$route.query.tab"
|
|
40
|
-
>
|
|
41
|
-
Controls
|
|
42
|
-
</BaseTab>
|
|
43
|
-
<BaseTab
|
|
44
|
-
:to="{ ...$route, query: { ...$route.query, tab: 'docs' } }"
|
|
45
|
-
:matched="$route.query.tab === 'docs'"
|
|
46
|
-
>
|
|
47
|
-
Docs
|
|
48
|
-
</BaseTab>
|
|
49
|
-
</nav>
|
|
48
|
+
<PaneTabs />
|
|
50
49
|
|
|
51
50
|
<component
|
|
52
|
-
:is="
|
|
53
|
-
? StoryDocs
|
|
54
|
-
: StoryControls"
|
|
51
|
+
:is="panelContentComponent"
|
|
55
52
|
:story="storyStore.currentStory"
|
|
56
53
|
:variant="storyStore.currentVariant"
|
|
57
54
|
class="htw-h-full htw-overflow-auto"
|
package/{src/client/app/components/story → dist/client/app/components/panel}/StorySourceCode.vue
RENAMED
|
@@ -62,9 +62,23 @@ const sourceHtml = computed(() => highlighter.value?.codeToHtml(sourceCode.value
|
|
|
62
62
|
|
|
63
63
|
<template>
|
|
64
64
|
<div
|
|
65
|
-
class="htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-
|
|
66
|
-
data-test-id="story-source-code"
|
|
65
|
+
class="htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-flex htw-flex-col"
|
|
67
66
|
>
|
|
67
|
+
<!-- Toolbar -->
|
|
68
|
+
<div
|
|
69
|
+
v-if="!error"
|
|
70
|
+
class="htw-h-10 htw-flex-none htw-border-b htw-border-solid htw-border-gray-150 dark:htw-border-gray-850 htw-px-4 htw-flex htw-items-center"
|
|
71
|
+
>
|
|
72
|
+
<div class="htw-text-gray-900 dark:htw-text-gray-100">
|
|
73
|
+
Source
|
|
74
|
+
</div>
|
|
75
|
+
<div class="htw-flex-1" />
|
|
76
|
+
<HstCopyIcon
|
|
77
|
+
:content="sourceCode"
|
|
78
|
+
class="htw-flex-none"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
68
82
|
<div
|
|
69
83
|
v-if="error"
|
|
70
84
|
class="htw-text-red-500 htw-h-full htw-p-2 htw-overflow-auto htw-font-mono htw-text-sm"
|
|
@@ -74,27 +88,23 @@ const sourceHtml = computed(() => highlighter.value?.codeToHtml(sourceCode.value
|
|
|
74
88
|
|
|
75
89
|
<textarea
|
|
76
90
|
v-else-if="!sourceHtml"
|
|
77
|
-
class="__histoire-code-placeholder htw-w-full htw-h-full htw-p-
|
|
91
|
+
class="__histoire-code-placeholder htw-w-full htw-h-full htw-p-4 htw-outline-none htw-bg-transparent htw-resize-none htw-m-0"
|
|
78
92
|
:value="sourceCode"
|
|
79
93
|
readonly
|
|
94
|
+
data-test-id="story-source-code"
|
|
80
95
|
/>
|
|
81
96
|
<!-- eslint-disable vue/no-v-html -->
|
|
82
97
|
<div
|
|
83
98
|
v-else
|
|
84
|
-
class="
|
|
85
|
-
|
|
86
|
-
/>
|
|
87
|
-
<!-- eslint-enable vue/no-v-html -->
|
|
88
|
-
|
|
89
|
-
<!-- Toolbar -->
|
|
90
|
-
<div
|
|
91
|
-
v-if="!error"
|
|
92
|
-
class="htw-absolute htw-top-2 htw-right-6 htw-p-1 htw-bg-gray-100 dark:htw-bg-gray-800"
|
|
99
|
+
class="htw-w-full htw-h-full htw-overflow-auto"
|
|
100
|
+
data-test-id="story-source-code"
|
|
93
101
|
>
|
|
94
|
-
<
|
|
95
|
-
|
|
102
|
+
<div
|
|
103
|
+
class="__histoire-code htw-p-4 htw-w-fit"
|
|
104
|
+
v-html="sourceHtml"
|
|
96
105
|
/>
|
|
97
106
|
</div>
|
|
107
|
+
<!-- eslint-enable vue/no-v-html -->
|
|
98
108
|
</div>
|
|
99
109
|
</template>
|
|
100
110
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { App, createApp, onMounted, onUnmounted, PropType, ref, watch } from 'vue'
|
|
3
3
|
import { Story, Variant } from '../../types'
|
|
4
4
|
// @ts-expect-error virtual module id
|
|
5
|
-
import setup from '$histoire-setup'
|
|
5
|
+
import * as setup from '$histoire-setup'
|
|
6
6
|
|
|
7
7
|
const props = defineProps({
|
|
8
8
|
variant: {
|
|
@@ -35,15 +35,27 @@ async function mountVariant () {
|
|
|
35
35
|
await props.variant.initState()
|
|
36
36
|
|
|
37
37
|
app = createApp({
|
|
38
|
+
name: 'SandboxVue3',
|
|
39
|
+
|
|
38
40
|
render: () => {
|
|
39
41
|
return props.variant.slots()?.[props.slotName]?.({
|
|
40
|
-
state: props.variant.state,
|
|
42
|
+
state: props.variant.state ?? {},
|
|
43
|
+
}) ?? props.story.slots()?.[props.slotName]?.({
|
|
44
|
+
state: props.variant.state ?? {},
|
|
41
45
|
})
|
|
42
46
|
},
|
|
43
47
|
})
|
|
44
48
|
|
|
45
|
-
if (typeof setup === 'function') {
|
|
46
|
-
await setup({
|
|
49
|
+
if (typeof setup?.setupVue3 === 'function') {
|
|
50
|
+
await setup.setupVue3({
|
|
51
|
+
app,
|
|
52
|
+
story: props.story,
|
|
53
|
+
variant: props.variant,
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (typeof props.variant.setupApp === 'function') {
|
|
58
|
+
await props.variant.setupApp({
|
|
47
59
|
app,
|
|
48
60
|
story: props.story,
|
|
49
61
|
variant: props.variant,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { base } from '../../router';
|
|
1
2
|
export function getSandboxUrl(story, variant) {
|
|
2
3
|
const url = new URLSearchParams();
|
|
3
4
|
url.append('storyId', story.id);
|
|
4
5
|
url.append('variantId', variant.id);
|
|
5
|
-
return
|
|
6
|
+
return `${base}__sandbox?${url.toString()}`;
|
|
6
7
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Icon } from '@iconify/vue'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div
|
|
7
|
+
class="htw-flex htw-items-center htw-gap-4 htw-pl-6 htw-border htw-border-transparent focus-visible:htw-border-primary-500 htw-h-[51px] htw-opacity-30"
|
|
8
|
+
>
|
|
9
|
+
<Icon
|
|
10
|
+
icon="carbon:search"
|
|
11
|
+
class="flex-none htw-w-4 htw-h-4"
|
|
12
|
+
/>
|
|
13
|
+
|
|
14
|
+
Loading...
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { defineAsyncComponent } from 'vue'
|
|
3
|
+
import SearchLoading from './SearchLoading.vue'
|
|
4
|
+
const SearchPane = defineAsyncComponent({
|
|
5
|
+
loader: () => import('./SearchPane.vue'),
|
|
6
|
+
loadingComponent: SearchLoading,
|
|
7
|
+
delay: 0,
|
|
8
|
+
})
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
defineProps({
|
|
11
11
|
shown: {
|
|
12
12
|
type: Boolean,
|
|
13
13
|
default: false,
|
|
@@ -21,111 +21,6 @@ const emit = defineEmits({
|
|
|
21
21
|
function close () {
|
|
22
22
|
emit('close')
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
// Autofocus
|
|
26
|
-
|
|
27
|
-
const input = ref<HTMLInputElement>()
|
|
28
|
-
const { focused } = useFocus(input, {
|
|
29
|
-
initialValue: true,
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
watch(() => props.shown, value => {
|
|
33
|
-
if (value) {
|
|
34
|
-
requestAnimationFrame(() => {
|
|
35
|
-
focused.value = true
|
|
36
|
-
input.value.select()
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
// Search
|
|
42
|
-
|
|
43
|
-
const searchInputText = ref('')
|
|
44
|
-
const rateLimitedSearch = useDebounce(searchInputText, 300)
|
|
45
|
-
|
|
46
|
-
const storyStore = useStoryStore()
|
|
47
|
-
|
|
48
|
-
function storyResultFactory (story: Story, rank: number): SearchResult {
|
|
49
|
-
return {
|
|
50
|
-
kind: 'story',
|
|
51
|
-
rank,
|
|
52
|
-
id: story.id,
|
|
53
|
-
title: story.title,
|
|
54
|
-
route: {
|
|
55
|
-
name: 'story',
|
|
56
|
-
params: {
|
|
57
|
-
storyId: story.id,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
path: story.file.path.slice(0, -1),
|
|
61
|
-
icon: story.icon,
|
|
62
|
-
iconColor: story.iconColor,
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function variantResultFactory (story: Story, variant: Variant, rank: number): SearchResult {
|
|
67
|
-
return {
|
|
68
|
-
kind: 'variant',
|
|
69
|
-
rank,
|
|
70
|
-
id: variant.id,
|
|
71
|
-
title: variant.title,
|
|
72
|
-
route: {
|
|
73
|
-
name: 'story',
|
|
74
|
-
params: {
|
|
75
|
-
storyId: story.id,
|
|
76
|
-
},
|
|
77
|
-
query: {
|
|
78
|
-
variantId: variant.id,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
path: [...story.file.path ?? [], story.title],
|
|
82
|
-
icon: variant.icon,
|
|
83
|
-
iconColor: variant.iconColor,
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const results = computed(() => {
|
|
88
|
-
const list: SearchResult[] = []
|
|
89
|
-
if (rateLimitedSearch.value) {
|
|
90
|
-
const s = rateLimitedSearch.value.toLowerCase()
|
|
91
|
-
for (const story of storyStore.stories) {
|
|
92
|
-
const storyMatched = story.title.toLowerCase().includes(s)
|
|
93
|
-
let storyPathMatched = false
|
|
94
|
-
if (storyMatched || (storyPathMatched = story.file.path.some(p => p.toLowerCase().includes(s)))) {
|
|
95
|
-
list.push(storyResultFactory(story, storyMatched ? 1 : 4))
|
|
96
|
-
}
|
|
97
|
-
for (const variant of story.variants) {
|
|
98
|
-
const variantMatched = variant.title.toLowerCase().includes(s)
|
|
99
|
-
if (storyMatched || storyPathMatched || variantMatched) {
|
|
100
|
-
list.push(variantResultFactory(story, variant, variantMatched ? 2 : storyMatched ? 3 : 5))
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return list.sort((a, b) => a.rank - b.rank)
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
// Selection
|
|
109
|
-
|
|
110
|
-
const selectedIndex = ref(0)
|
|
111
|
-
|
|
112
|
-
watch(results, () => {
|
|
113
|
-
selectedIndex.value = 0
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
function selectNext () {
|
|
117
|
-
selectedIndex.value++
|
|
118
|
-
if (selectedIndex.value > results.value.length - 1) {
|
|
119
|
-
selectedIndex.value = 0
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function selectPrevious () {
|
|
124
|
-
selectedIndex.value--
|
|
125
|
-
if (selectedIndex.value < 0) {
|
|
126
|
-
selectedIndex.value = results.value.length - 1
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
24
|
</script>
|
|
130
25
|
|
|
131
26
|
<template>
|
|
@@ -139,42 +34,10 @@ function selectPrevious () {
|
|
|
139
34
|
@click="close()"
|
|
140
35
|
/>
|
|
141
36
|
<div class="htw-bg-white dark:htw-bg-gray-700 md:htw-mt-16 md:htw-mx-auto htw-w-screen htw-max-w-[512px] htw-shadow-xl htw-border htw-border-gray-200 dark:htw-border-gray-850 htw-rounded-lg htw-relative htw-divide-y htw-divide-gray-200 dark:htw-divide-gray-850">
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
@
|
|
145
|
-
|
|
146
|
-
<Icon
|
|
147
|
-
icon="carbon:search"
|
|
148
|
-
class="flex-none htw-w-4 htw-h-4"
|
|
149
|
-
/>
|
|
150
|
-
|
|
151
|
-
<input
|
|
152
|
-
ref="input"
|
|
153
|
-
v-model="searchInputText"
|
|
154
|
-
placeholder="Search for stories, variants..."
|
|
155
|
-
class="htw-bg-transparent htw-w-full htw-flex-1 htw-pl-0 htw-pr-6 htw-py-4 htw-outline-none"
|
|
156
|
-
@keydown.down.prevent="selectNext()"
|
|
157
|
-
@keydown.up.prevent="selectPrevious()"
|
|
158
|
-
@keydown.escape="close()"
|
|
159
|
-
>
|
|
160
|
-
</div>
|
|
161
|
-
|
|
162
|
-
<BaseEmpty v-if="rateLimitedSearch && !results.length">
|
|
163
|
-
No results
|
|
164
|
-
</BaseEmpty>
|
|
165
|
-
|
|
166
|
-
<div
|
|
167
|
-
v-else-if="results.length"
|
|
168
|
-
class="htw-max-h-[400px] htw-overflow-y-auto htw-rounded-b-lg"
|
|
169
|
-
>
|
|
170
|
-
<SearchItem
|
|
171
|
-
v-for="(result, index) of results"
|
|
172
|
-
:key="`${result.kind}-${result.id}`"
|
|
173
|
-
:result="result"
|
|
174
|
-
:selected="index === selectedIndex"
|
|
175
|
-
@close="close()"
|
|
176
|
-
/>
|
|
177
|
-
</div>
|
|
37
|
+
<SearchPane
|
|
38
|
+
:shown="shown"
|
|
39
|
+
@close="close()"
|
|
40
|
+
/>
|
|
178
41
|
</div>
|
|
179
42
|
</div>
|
|
180
43
|
</template>
|