@histoire/app 0.13.2 → 0.14.0

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.
Files changed (81) hide show
  1. package/dist/bundled/App.vue2.js +11 -2
  2. package/dist/bundled/components/base/BaseButton.vue.js +5 -0
  3. package/dist/bundled/components/base/BaseButton.vue2.js +39 -0
  4. package/dist/bundled/components/base/BaseIcon.vue.js +8 -0
  5. package/dist/bundled/components/base/BaseIcon.vue2.js +30 -0
  6. package/dist/bundled/components/base/BaseIcon.vue3.js +4 -0
  7. package/dist/bundled/components/base/BaseKeyboardShortcut.vue.js +5 -0
  8. package/dist/bundled/components/base/BaseKeyboardShortcut.vue2.js +20 -0
  9. package/dist/bundled/components/base/BaseListItem.vue.js +5 -0
  10. package/dist/bundled/components/base/BaseListItem.vue2.js +32 -0
  11. package/dist/bundled/components/command/CommandPrompts.vue.js +5 -0
  12. package/dist/bundled/components/command/CommandPrompts.vue2.js +95 -0
  13. package/dist/bundled/components/command/CommandPromptsModal.vue.js +5 -0
  14. package/dist/bundled/components/command/CommandPromptsModal.vue2.js +44 -0
  15. package/dist/bundled/components/command/PromptSelect.vue.js +5 -0
  16. package/dist/bundled/components/command/PromptSelect.vue2.js +142 -0
  17. package/dist/bundled/components/command/PromptText.vue.js +5 -0
  18. package/dist/bundled/components/command/PromptText.vue2.js +67 -0
  19. package/dist/bundled/components/panel/StoryDocs.vue2.js +25 -3
  20. package/dist/bundled/components/panel/StorySourceCode.vue.js +1 -1
  21. package/dist/bundled/components/panel/StorySourceCode.vue2.js +1 -1
  22. package/dist/bundled/components/panel/StorySourceCode.vue3.js +2 -2
  23. package/dist/bundled/components/search/SearchItem.vue.js +1 -1
  24. package/dist/bundled/components/search/SearchItem.vue2.js +42 -62
  25. package/dist/bundled/components/search/SearchItem.vue3.js +2 -2
  26. package/dist/bundled/components/search/SearchItemContent.vue.js +5 -0
  27. package/dist/bundled/components/search/SearchItemContent.vue2.js +72 -0
  28. package/dist/bundled/components/search/SearchModal.vue2.js +2 -2
  29. package/dist/bundled/components/search/SearchPane.vue2.js +46 -24
  30. package/dist/bundled/components/story/StoryVariantGrid.vue2.js +10 -2
  31. package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +13 -6
  32. package/dist/bundled/components/story/StoryView.vue2.js +1 -0
  33. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue.js +5 -0
  34. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue2.js +31 -0
  35. package/dist/bundled/index.js +3 -1
  36. package/dist/bundled/plugin.js +50 -0
  37. package/dist/bundled/sandbox.js +4 -0
  38. package/dist/bundled/stores/command.js +26 -0
  39. package/dist/bundled/style.css +15 -11
  40. package/dist/bundled/util/commands.js +59 -0
  41. package/dist/bundled/util/keyboard.js +3 -0
  42. package/dist/bundled/util/open-in-editor.js +6 -0
  43. package/dist/bundled/util/select.js +28 -0
  44. package/dist/bundled/util/tooltip.js +1 -1
  45. package/dist/style.css +116 -63
  46. package/package.json +4 -4
  47. package/src/app/App.vue +10 -1
  48. package/src/app/components/base/BaseButton.vue +33 -0
  49. package/src/app/components/base/BaseIcon.vue +31 -0
  50. package/src/app/components/base/BaseKeyboardShortcut.vue +16 -0
  51. package/src/app/components/base/BaseListItem.vue +30 -0
  52. package/src/app/components/command/CommandPrompts.vue +97 -0
  53. package/src/app/components/command/CommandPromptsModal.vue +40 -0
  54. package/src/app/components/command/PromptSelect.vue +140 -0
  55. package/src/app/components/command/PromptText.vue +64 -0
  56. package/src/app/components/panel/StoryDocs.vue +25 -2
  57. package/src/app/components/panel/StorySourceCode.vue +0 -1
  58. package/src/app/components/search/SearchItem.vue +29 -52
  59. package/src/app/components/search/SearchItemContent.vue +67 -0
  60. package/src/app/components/search/SearchModal.vue +2 -2
  61. package/src/app/components/search/SearchPane.vue +50 -22
  62. package/src/app/components/search/search-docs-data.ts +0 -1
  63. package/src/app/components/search/search-title-data.ts +0 -1
  64. package/src/app/components/story/GenericMountStory.vue +0 -1
  65. package/src/app/components/story/GenericRenderStory.vue +0 -1
  66. package/src/app/components/story/StoryVariantGrid.vue +7 -0
  67. package/src/app/components/story/StoryVariantSingleView.vue +7 -0
  68. package/src/app/components/story/StoryView.vue +1 -0
  69. package/src/app/components/toolbar/DevOnlyToolbarOpenInEditor.vue +23 -0
  70. package/src/app/index.ts +5 -1
  71. package/src/app/plugin.ts +58 -0
  72. package/src/app/sandbox.ts +6 -1
  73. package/src/app/stores/command.ts +25 -0
  74. package/src/app/types.ts +26 -4
  75. package/src/app/util/commands.ts +56 -0
  76. package/src/app/util/config.ts +0 -1
  77. package/src/app/util/keyboard.ts +3 -0
  78. package/src/app/util/open-in-editor.ts +3 -0
  79. package/src/app/util/select.ts +29 -0
  80. package/src/app/util/tooltip.ts +1 -1
  81. package/src/virtual.d.ts +6 -0
@@ -0,0 +1,16 @@
1
+ <script lang="ts" setup>
2
+ import { formatKey } from '../../util/keyboard.js'
3
+ import { computed } from 'vue'
4
+
5
+ const props = defineProps<{
6
+ shortcut: string
7
+ }>()
8
+
9
+ const formatted = computed(() => props.shortcut.split('+').map(k => formatKey(k.trim())).join(' '))
10
+ </script>
11
+
12
+ <template>
13
+ <span class="histoire-base-keyboard-shortcut htw-border htw-border-current htw-opacity-50 htw-px-1 htw-rounded-sm">
14
+ {{ formatted }}
15
+ </span>
16
+ </template>
@@ -0,0 +1,30 @@
1
+ <script lang="ts" setup>
2
+ defineProps<{
3
+ isActive?: boolean
4
+ }>()
5
+
6
+ const emit = defineEmits<{
7
+ (e: 'navigate'): void
8
+ }>()
9
+
10
+ function handleNavigate () {
11
+ emit('navigate')
12
+ }
13
+ </script>
14
+
15
+ <template>
16
+ <a
17
+ class="istoire-base-list-ite htw-flex htw-items-center htw-gap-2 htw-text-gray-900 dark:htw-text-gray-100"
18
+ :class="[
19
+ $attrs.class,
20
+ isActive
21
+ ? 'active htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
22
+ : 'hover:htw-bg-primary-100 dark:hover:htw-bg-primary-900'
23
+ ]"
24
+ @click="handleNavigate()"
25
+ @keyup.enter="handleNavigate()"
26
+ @keyup.space="handleNavigate()"
27
+ >
28
+ <slot />
29
+ </a>
30
+ </template>
@@ -0,0 +1,97 @@
1
+ <script lang="ts" setup>
2
+ import { reactive, ref, nextTick, onMounted } from 'vue'
3
+ import type { ClientCommand } from '@histoire/shared'
4
+ import { getCommandContext, executeCommand } from '../../util/commands.js'
5
+ import BaseButton from '../base/BaseButton.vue'
6
+ import BaseKeyboardShortcut from '../base/BaseKeyboardShortcut.vue'
7
+ import PromptText from './PromptText.vue'
8
+ import PromptSelect from './PromptSelect.vue'
9
+
10
+ const props = defineProps<{
11
+ command: ClientCommand
12
+ }>()
13
+
14
+ const emit = defineEmits<{
15
+ (e: 'close'): void
16
+ }>()
17
+
18
+ const promptTypes = {
19
+ text: PromptText,
20
+ select: PromptSelect,
21
+ }
22
+
23
+ const answers = reactive<Record<string, any>>({})
24
+
25
+ // Initial default values
26
+ for (const prompt of props.command.prompts) {
27
+ let defaultValue
28
+ if (typeof prompt.defaultValue === 'function') {
29
+ defaultValue = prompt.defaultValue(answers)
30
+ } else {
31
+ defaultValue = prompt.defaultValue
32
+ }
33
+ answers[prompt.field] = defaultValue
34
+ }
35
+
36
+ function submit () {
37
+ const params = props.command.getParams
38
+ ? props.command.getParams({
39
+ ...getCommandContext(),
40
+ answers,
41
+ })
42
+ : answers
43
+ executeCommand(props.command, params)
44
+ emit('close')
45
+ }
46
+
47
+ // Autofocus
48
+
49
+ const promptComps = ref<any[]>([])
50
+
51
+ function focusPrompt (index: number) {
52
+ nextTick(() => {
53
+ promptComps.value[index]?.focus?.()
54
+ })
55
+ }
56
+
57
+ onMounted(() => {
58
+ focusPrompt(0)
59
+ })
60
+ </script>
61
+
62
+ <template>
63
+ <form
64
+ class="histoire-command-prompts htw-flex htw-flex-col"
65
+ @submit.prevent="submit()"
66
+ @keyup.escape="$emit('close')"
67
+ >
68
+ <div class="htw-p-4 htw-opacity-70">
69
+ {{ command.label }}
70
+ </div>
71
+
72
+ <component
73
+ :is="promptTypes[prompt.type]"
74
+ v-for="(prompt, index) of command.prompts"
75
+ :key="prompt.field"
76
+ ref="promptComps"
77
+ v-model="answers[prompt.field]"
78
+ :prompt="prompt"
79
+ :answers="answers"
80
+ :index="index"
81
+ class="hover:htw-bg-gray-500/10 focus-within:htw-bg-gray-500/5"
82
+ @next="focusPrompt(index + 1)"
83
+ />
84
+
85
+ <div class="htw-flex htw-justify-end htw-gap-2 htw-p-2">
86
+ <BaseButton
87
+ type="submit"
88
+ class="htw-px-4 htw-py-2 htw-flex htw-items-start htw-gap-2"
89
+ >
90
+ <BaseKeyboardShortcut
91
+ shortcut="Enter"
92
+ />
93
+ <span>Submit</span>
94
+ </BaseButton>
95
+ </div>
96
+ </form>
97
+ </template>
@@ -0,0 +1,40 @@
1
+ <script lang="ts" setup>
2
+ import { defineAsyncComponent } from 'vue'
3
+ import { useCommandStore } from '../../stores/command.js'
4
+ const CommandPrompts = defineAsyncComponent(() => import('./CommandPrompts.vue'))
5
+
6
+ defineProps({
7
+ shown: {
8
+ type: Boolean,
9
+ default: false,
10
+ },
11
+ })
12
+
13
+ const emit = defineEmits({
14
+ close: () => true,
15
+ })
16
+
17
+ function close () {
18
+ emit('close')
19
+ }
20
+
21
+ const commandStore = useCommandStore()
22
+ </script>
23
+
24
+ <template>
25
+ <div
26
+ v-if="shown"
27
+ class="histoire-command-prompts-modal htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-900/80 htw-z-20"
28
+ >
29
+ <div
30
+ class="htw-absolute htw-inset-0"
31
+ @click="close()"
32
+ />
33
+ <div class="htw-bg-white dark:htw-bg-gray-900 md:htw-mt-16 md:htw-mx-auto htw-w-screen htw-max-w-[512px] htw-max-h-[80vh] htw-overflow-y-auto htw-scroll-smooth htw-shadow-xl htw-border htw-border-gray-200 dark:htw-border-gray-750 htw-rounded-lg htw-relative htw-divide-y htw-divide-gray-200 dark:htw-divide-gray-850">
34
+ <CommandPrompts
35
+ :command="commandStore.selectedCommand"
36
+ @close="close()"
37
+ />
38
+ </div>
39
+ </div>
40
+ </template>
@@ -0,0 +1,140 @@
1
+ <script lang="ts" setup>
2
+ import type { SelectPrompt, SelectPromptOption } from '@histoire/shared'
3
+ import { computed, ref, watchEffect } from 'vue'
4
+ import { Icon } from '@iconify/vue'
5
+ import { useSelection } from '../../util/select.js'
6
+ import BaseKeyboardShortcut from '../base/BaseKeyboardShortcut.vue'
7
+
8
+ const props = defineProps<{
9
+ modelValue?: string
10
+ prompt: SelectPrompt
11
+ answers: Record<string, any>
12
+ }>()
13
+
14
+ const emit = defineEmits<{
15
+ (e: 'update:modelValue', value: string): void
16
+ (e: 'next'): void
17
+ }>()
18
+
19
+ const model = computed({
20
+ get: () => props.modelValue,
21
+ set: (value) => {
22
+ emit('update:modelValue', value)
23
+ emit('next')
24
+ },
25
+ })
26
+
27
+ const input = ref<HTMLInputElement>()
28
+
29
+ function focus () {
30
+ input.value?.focus()
31
+ input.value?.select()
32
+ }
33
+
34
+ defineExpose({
35
+ focus,
36
+ })
37
+
38
+ const search = ref('')
39
+
40
+ const options = ref<SelectPromptOption[]>([])
41
+
42
+ let requestId = 0
43
+ watchEffect(async () => {
44
+ if (typeof props.prompt.options === 'function') {
45
+ const rId = ++requestId
46
+ const result = await props.prompt.options(search.value, props.answers)
47
+ if (rId === requestId) {
48
+ options.value = result
49
+ }
50
+ } else {
51
+ options.value = props.prompt.options
52
+ }
53
+ })
54
+
55
+ const formattedOptions = computed(() => {
56
+ return options.value.map((option) => {
57
+ if (typeof option === 'string') {
58
+ return {
59
+ value: option,
60
+ label: option,
61
+ }
62
+ } else {
63
+ return option
64
+ }
65
+ })
66
+ })
67
+
68
+ // Keyboard navigation
69
+
70
+ const {
71
+ selectedIndex,
72
+ selectNext,
73
+ selectPrevious,
74
+ } = useSelection(formattedOptions)
75
+
76
+ function selectIndex (index: number) {
77
+ const result = formattedOptions.value[index].value
78
+ if (result) {
79
+ model.value = result
80
+ }
81
+ }
82
+ </script>
83
+
84
+ <template>
85
+ <div class="histoire-prompt-select htw-relative htw-group">
86
+ <input
87
+ v-model="model"
88
+ :required="prompt.required"
89
+ tabindex="-1"
90
+ class="htw-absolute htw-inset-0 htw-opacity-0 htw-pointer-events-none"
91
+ >
92
+ <label class="htw-flex htw-flex-col htw-gap-2 htw-p-2">
93
+ <span class="htw-px-2 htw-flex">
94
+ <span>{{ prompt.label }}</span>
95
+ <span
96
+ v-if="prompt.required"
97
+ class="htw-opacity-70"
98
+ >*</span>
99
+
100
+ <span class="htw-opacity-40 htw-text-sm htw-ml-auto htw-invisible group-focus-within:htw-visible">
101
+ Press <BaseKeyboardShortcut shortcut="Space" /> to select
102
+ </span>
103
+ </span>
104
+ <input
105
+ ref="input"
106
+ v-model="search"
107
+ class="htw-bg-transparent htw-w-full htw-p-2 htw-border htw-border-gray-500/50 focus:htw-border-primary-500/50 htw-rounded htw-outline-none"
108
+ @keydown.down.prevent="selectNext()"
109
+ @keydown.up.prevent="selectPrevious()"
110
+ @keydown.space.prevent="selectIndex(selectedIndex)"
111
+ >
112
+ </label>
113
+
114
+ <div class="htw-overflow-auto max-h-[300px] htw-mb-2">
115
+ <button
116
+ v-for="(option, index) of formattedOptions"
117
+ :key="option.value"
118
+ type="button"
119
+ tabindex="-1"
120
+ :class="[
121
+ model === option.value
122
+ ? 'htw-bg-primary-500/20'
123
+ : index === selectedIndex
124
+ ? 'htw-bg-primary-500/10'
125
+ : 'htw-bg-transparent',
126
+ ]"
127
+ class="htw-w-full htw-text-left htw-px-4 htw-py-2 hover:htw-bg-primary-500/10 htw-flex htw-items-center"
128
+ @click="model = option.value"
129
+ >
130
+ <span class="htw-flex-1">{{ option.label }}</span>
131
+
132
+ <Icon
133
+ v-if="model === option.value"
134
+ icon="carbon:checkmark"
135
+ class="htw-w-4 htw-h-4 htw-text-primary-500"
136
+ />
137
+ </button>
138
+ </div>
139
+ </div>
140
+ </template>
@@ -0,0 +1,64 @@
1
+ <script lang="ts" setup>
2
+ import type { TextPrompt } from '@histoire/shared'
3
+ import { computed, ref, watch } from 'vue'
4
+
5
+ const props = defineProps<{
6
+ modelValue?: string
7
+ prompt: TextPrompt
8
+ answers: Record<string, any>
9
+ }>()
10
+
11
+ const emit = defineEmits<{
12
+ (e: 'update:modelValue', value: string): void
13
+ }>()
14
+
15
+ const model = computed({
16
+ get: () => props.modelValue,
17
+ set: (value) => emit('update:modelValue', value),
18
+ })
19
+
20
+ const input = ref<HTMLInputElement>()
21
+
22
+ function focus () {
23
+ input.value?.focus()
24
+ input.value?.select()
25
+ }
26
+
27
+ defineExpose({
28
+ focus,
29
+ })
30
+
31
+ // Default value
32
+
33
+ const defaultValue = computed(() => {
34
+ if (typeof props.prompt.defaultValue === 'function') {
35
+ return props.prompt.defaultValue(props.answers)
36
+ } else {
37
+ return props.prompt.defaultValue
38
+ }
39
+ })
40
+
41
+ watch(defaultValue, (value) => {
42
+ model.value = value
43
+ })
44
+ </script>
45
+
46
+ <template>
47
+ <div class="histoire-prompt-text">
48
+ <label class="htw-flex htw-flex-col htw-gap-2 htw-p-2">
49
+ <span class="htw-px-2">
50
+ <span>{{ prompt.label }}</span>
51
+ <span
52
+ v-if="prompt.required"
53
+ class="htw-opacity-70"
54
+ >*</span>
55
+ </span>
56
+ <input
57
+ ref="input"
58
+ v-model="model"
59
+ class="htw-bg-transparent htw-w-full htw-p-2 htw-border htw-border-gray-500/50 focus:htw-border-primary-500/50 htw-rounded htw-outline-none"
60
+ :required="prompt.required"
61
+ >
62
+ </label>
63
+ </div>
64
+ </template>
@@ -1,9 +1,9 @@
1
1
  <script lang="ts">
2
- import { nextTick, PropType, Ref, ref, toRefs, watch, watchEffect } from 'vue'
2
+ import { nextTick, PropType, Ref, ref, toRefs, watch, watchEffect, computed } from 'vue'
3
3
  import type { Story } from '../../types'
4
- // @ts-expect-error virtual module
5
4
  import { markdownFiles } from 'virtual:$histoire-markdown-files'
6
5
  import { histoireConfig } from '../../util/config.js'
6
+ import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
7
7
 
8
8
  export function useStoryDoc (story: Ref<Story>) {
9
9
  const renderedDoc = ref('')
@@ -56,6 +56,11 @@ const props = defineProps({
56
56
  type: Object as PropType<Story>,
57
57
  required: true,
58
58
  },
59
+
60
+ standalone: {
61
+ type: Boolean,
62
+ default: false,
63
+ },
59
64
  })
60
65
 
61
66
  const emit = defineEmits<{
@@ -148,6 +153,10 @@ watch(renderedDoc, () => {
148
153
  }, {
149
154
  immediate: true,
150
155
  })
156
+
157
+ // Open in editor
158
+
159
+ const filePath = computed(() => story.value.file?.docsFilePath ?? (props.standalone && story.value.file?.filePath))
151
160
  </script>
152
161
 
153
162
  <template>
@@ -155,6 +164,20 @@ watch(renderedDoc, () => {
155
164
  class="histoire-story-docs"
156
165
  @click.capture="onClick"
157
166
  >
167
+ <div
168
+ v-if="__HISTOIRE_DEV__ && renderedDoc && filePath"
169
+ class="htw-flex htw-items-center htw-gap-2 htw-p-2"
170
+ :class="{
171
+ 'htw-pt-4': !standalone,
172
+ }"
173
+ >
174
+ <DevOnlyToolbarOpenInEditor
175
+ v-if="filePath"
176
+ :file="filePath"
177
+ tooltip="Edit docs in editor"
178
+ />
179
+ </div>
180
+
158
181
  <BaseEmpty
159
182
  v-if="!renderedDoc"
160
183
  >
@@ -4,7 +4,6 @@ import { Icon } from '@iconify/vue'
4
4
  import { getHighlighter, Highlighter } from 'shiki-es'
5
5
  import { HstCopyIcon } from '@histoire/controls'
6
6
  import { unindent } from '@histoire/shared'
7
- // @ts-expect-error virtual module
8
7
  import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
9
8
  import type { Variant, Story } from '../../types'
10
9
  import { isDark } from '../../util/dark'
@@ -1,11 +1,12 @@
1
1
  <script lang="ts" setup>
2
2
  import { PropType, ref, toRefs } from 'vue'
3
3
  import { useRouter } from 'vue-router'
4
- import { Icon } from '@iconify/vue'
5
4
  import { SearchResult } from '../../types'
6
5
  import { onKeyboardShortcut } from '../../util/keyboard'
7
- import BaseListItemLink from '../base/BaseListItemLink.vue'
8
6
  import { useScrollOnActive } from '../../util/scroll'
7
+ import BaseListItemLink from '../base/BaseListItemLink.vue'
8
+ import BaseListItem from '../base/BaseListItem.vue'
9
+ import SearchItemContent from './SearchItemContent.vue'
9
10
 
10
11
  const props = defineProps({
11
12
  result: {
@@ -32,18 +33,17 @@ const router = useRouter()
32
33
 
33
34
  onKeyboardShortcut(['enter'], () => {
34
35
  if (!props.selected) return
35
- router.push(props.result.route)
36
- emit('close')
36
+ action()
37
37
  })
38
38
 
39
- const defaultIcons = {
40
- story: 'carbon:cube',
41
- variant: 'carbon:cube',
42
- }
43
-
44
- const kindLabels = {
45
- story: 'Story',
46
- variant: 'Variant',
39
+ function action (fromClick = false) {
40
+ if ('route' in props.result && !fromClick) {
41
+ router.push(props.result.route)
42
+ }
43
+ if ('onActivate' in props.result) {
44
+ props.result.onActivate()
45
+ }
46
+ emit('close')
47
47
  }
48
48
  </script>
49
49
 
@@ -55,52 +55,29 @@ const kindLabels = {
55
55
  :data-selected="selected ? '' : undefined"
56
56
  >
57
57
  <BaseListItemLink
58
+ v-if="'route' in result"
58
59
  :to="result.route"
59
60
  :is-active="selected"
60
61
  class="htw-px-6 htw-py-4 htw-gap-4"
61
- @navigate="$emit('close')"
62
+ @navigate="action(true)"
62
63
  >
63
- <Icon
64
- :icon="result.icon ?? defaultIcons[result.kind]"
65
- class="htw-w-4 htw-h-4"
66
- :class="[
67
- !selected ? [
68
- result.iconColor
69
- ?'bind-icon-color'
70
- : {
71
- 'htw-text-primary-500': result.kind === 'story',
72
- 'htw-text-gray-500': result.kind === 'variant',
73
- }
74
- ] : [],
75
- ]"
64
+ <SearchItemContent
65
+ :result="result"
66
+ :selected="selected"
76
67
  />
77
- <div class="htw-flex-1">
78
- <div class="htw-flex">
79
- {{ result.title }}
80
- <span class="htw-ml-auto htw-opacity-40">
81
- {{ kindLabels[result.kind] }}
82
- </span>
83
- </div>
84
-
85
- <div
86
- v-if="result.path?.length"
87
- class="htw-flex htw-items-center htw-gap-0.5 htw-opacity-60"
88
- >
89
- <div
90
- v-for="(p, index) of result.path"
91
- :key="index"
92
- class="htw-flex htw-items-center htw-gap-0.5"
93
- >
94
- <Icon
95
- v-if="index > 0"
96
- icon="carbon:chevron-right"
97
- class="htw-w-4 htw-h-4 htw-mt-0.5 htw-opacity-50"
98
- />
99
- <span>{{ p }}</span>
100
- </div>
101
- </div>
102
- </div>
103
68
  </BaseListItemLink>
69
+
70
+ <BaseListItem
71
+ v-if="'onActivate' in result"
72
+ :is-active="selected"
73
+ class="htw-px-6 htw-py-4 htw-gap-4"
74
+ @navigate="action(true)"
75
+ >
76
+ <SearchItemContent
77
+ :result="result"
78
+ :selected="selected"
79
+ />
80
+ </BaseListItem>
104
81
  </div>
105
82
  </template>
106
83
 
@@ -0,0 +1,67 @@
1
+ <script lang="ts" setup>
2
+ import { Icon } from '@iconify/vue'
3
+ import BaseIcon from '../base/BaseIcon.vue'
4
+ import type { SearchResult } from '../../types.js'
5
+
6
+ defineProps<{
7
+ result: SearchResult
8
+ selected: boolean
9
+ }>()
10
+
11
+ const defaultIcons = {
12
+ story: 'carbon:cube',
13
+ variant: 'carbon:cube',
14
+ }
15
+
16
+ const kindLabels = {
17
+ story: 'Story',
18
+ variant: 'Variant',
19
+ command: 'Command',
20
+ }
21
+ </script>
22
+
23
+ <template>
24
+ <BaseIcon
25
+ :icon="result.icon ?? defaultIcons[result.kind]"
26
+ class="htw-w-4 htw-h-4"
27
+ :class="[
28
+ !selected ? [
29
+ result.iconColor
30
+ ?'bind-icon-color'
31
+ : {
32
+ 'htw-text-primary-500': result.kind === 'story',
33
+ 'htw-text-gray-500': result.kind === 'variant',
34
+ }
35
+ ] : [],
36
+ {
37
+ 'colorize-black': selected,
38
+ }
39
+ ]"
40
+ />
41
+ <div class="htw-flex-1">
42
+ <div class="htw-flex">
43
+ {{ result.title }}
44
+ <span class="htw-ml-auto htw-opacity-40">
45
+ {{ kindLabels[result.kind] }}
46
+ </span>
47
+ </div>
48
+
49
+ <div
50
+ v-if="result.path?.length"
51
+ class="htw-flex htw-items-center htw-gap-0.5 htw-opacity-60"
52
+ >
53
+ <div
54
+ v-for="(p, index) of result.path"
55
+ :key="index"
56
+ class="htw-flex htw-items-center htw-gap-0.5"
57
+ >
58
+ <Icon
59
+ v-if="index > 0"
60
+ icon="carbon:chevron-right"
61
+ class="htw-w-4 htw-h-4 htw-mt-0.5 htw-opacity-50"
62
+ />
63
+ <span>{{ p }}</span>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </template>
@@ -26,14 +26,14 @@ function close () {
26
26
  <template>
27
27
  <div
28
28
  v-show="shown"
29
- class="histoire-search-modal htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-700/80 htw-z-20"
29
+ class="histoire-search-modal htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-900/80 htw-z-20"
30
30
  data-test-id="search-modal"
31
31
  >
32
32
  <div
33
33
  class="htw-absolute htw-inset-0"
34
34
  @click="close()"
35
35
  />
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">
36
+ <div class="htw-bg-white dark:htw-bg-gray-900 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-750 htw-rounded-lg htw-relative htw-divide-y htw-divide-gray-200 dark:htw-divide-gray-850">
37
37
  <SearchPane
38
38
  :shown="shown"
39
39
  @close="close()"