@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
@@ -5,12 +5,17 @@ import { Icon } from '@iconify/vue'
5
5
  import * as flexsearch from 'flexsearch'
6
6
  import charset from 'flexsearch/dist/module/lang/latin/advanced.js'
7
7
  import language from 'flexsearch/dist/module/lang/en.js'
8
+ import type { ClientCommand } from '@histoire/shared'
9
+ import { registeredCommands } from 'virtual:$histoire-commands'
8
10
  import { useStoryStore } from '../../stores/story'
9
11
  import BaseEmpty from '../base/BaseEmpty.vue'
10
12
  import type { SearchResult, SearchResultType, Story, Variant } from '../../types'
11
13
  import SearchItem from './SearchItem.vue'
12
14
  import { searchData, onUpdate } from './search-title-data'
13
15
  import type { SearchData } from './types'
16
+ import { builtinCommands, getCommandContext } from '../../util/commands.js'
17
+ import { useCommandStore } from '../../stores/command.js'
18
+ import { useSelection } from '../../util/select.js'
14
19
 
15
20
  const DocSearchData = () => import('./search-docs-data')
16
21
 
@@ -194,7 +199,6 @@ function storyResultFactory (story: Story, rank: number, type: SearchResultType
194
199
  path: story.file.path.slice(0, -1),
195
200
  icon: story.icon,
196
201
  iconColor: story.iconColor,
197
- type,
198
202
  }
199
203
  }
200
204
 
@@ -219,12 +223,50 @@ function variantResultFactory (story: Story, variant: Variant, rank: number, typ
219
223
  path: [...story.file.path ?? [], story.title],
220
224
  icon: variant.icon,
221
225
  iconColor: variant.iconColor,
222
- type,
223
226
  }
224
227
  }
225
228
 
229
+ // Commands
230
+
231
+ const allCommands = [
232
+ ...builtinCommands,
233
+ ...registeredCommands,
234
+ ]
235
+
236
+ const commandResults = computed(() => {
237
+ if (__HISTOIRE_DEV__) {
238
+ const commandCtx = getCommandContext()
239
+ const searchText = searchInputText.value.toLowerCase()
240
+ return allCommands
241
+ .filter(command => !command.showIf || command.showIf(commandCtx))
242
+ .filter(command => command.label.toLowerCase().includes(searchText) || command.searchText?.toLowerCase().includes(searchText))
243
+ .map((command) => commandResultFactory(command, 0))
244
+ }
245
+ return []
246
+ })
247
+
248
+ const commandStore = useCommandStore()
249
+
250
+ function commandResultFactory (command: ClientCommand, rank: number): SearchResult {
251
+ return {
252
+ kind: 'command',
253
+ rank,
254
+ id: `_command:${command.id}`,
255
+ title: command.label,
256
+ icon: command.icon ?? 'carbon:chevron-right',
257
+ onActivate: () => {
258
+ commandStore.activateCommand(command)
259
+ },
260
+ }
261
+ }
262
+
263
+ // Results
264
+
226
265
  const results = computed(() => {
227
- const list = [...titleResults.value]
266
+ const list = [
267
+ ...commandResults.value,
268
+ ...titleResults.value,
269
+ ]
228
270
  const seen = {}
229
271
  for (const r of titleResults.value) {
230
272
  seen[r.id] = true
@@ -239,25 +281,11 @@ const results = computed(() => {
239
281
 
240
282
  // Selection
241
283
 
242
- const selectedIndex = ref(0)
243
-
244
- watch(results, () => {
245
- selectedIndex.value = 0
246
- })
247
-
248
- function selectNext () {
249
- selectedIndex.value++
250
- if (selectedIndex.value > results.value.length - 1) {
251
- selectedIndex.value = 0
252
- }
253
- }
254
-
255
- function selectPrevious () {
256
- selectedIndex.value--
257
- if (selectedIndex.value < 0) {
258
- selectedIndex.value = results.value.length - 1
259
- }
260
- }
284
+ const {
285
+ selectedIndex,
286
+ selectNext,
287
+ selectPrevious,
288
+ } = useSelection(results)
261
289
  </script>
262
290
 
263
291
  <template>
@@ -1,5 +1,4 @@
1
1
  import { markRaw } from 'vue'
2
- // @ts-expect-error virtual module
3
2
  import { searchData as _searchData, onUpdate as _onUpdate } from 'virtual:$histoire-search-docs-data'
4
3
  import type { SearchData } from './types.js'
5
4
 
@@ -1,5 +1,4 @@
1
1
  import { markRaw } from 'vue'
2
- // @ts-expect-error virtual module
3
2
  import { searchData as _searchData, onUpdate as _onUpdate } from 'virtual:$histoire-search-title-data'
4
3
  import type { SearchData } from './types.js'
5
4
 
@@ -5,7 +5,6 @@ export default {
5
5
  </script>
6
6
 
7
7
  <script lang="ts" setup>
8
- // @ts-expect-error virtual module
9
8
  import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
10
9
  import { ref, watchEffect, markRaw } from 'vue'
11
10
  import type { Story } from '../../types'
@@ -5,7 +5,6 @@ export default {
5
5
  </script>
6
6
 
7
7
  <script lang="ts" setup>
8
- // @ts-expect-error virtual module
9
8
  import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
10
9
  import { ref, watchEffect, markRaw } from 'vue'
11
10
  import type { Story } from '../../types'
@@ -6,6 +6,7 @@ import { isMobile } from '../../util/responsive'
6
6
  import StoryVariantGridItem from './StoryVariantGridItem.vue'
7
7
  import ToolbarBackground from '../toolbar/ToolbarBackground.vue'
8
8
  import ToolbarTextDirection from '../toolbar/ToolbarTextDirection.vue'
9
+ import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
9
10
 
10
11
  const storyStore = useStoryStore()
11
12
 
@@ -125,6 +126,12 @@ const columnCount = computed(() => Math.min(storyStore.currentStory.variants.len
125
126
  >
126
127
  <ToolbarBackground />
127
128
  <ToolbarTextDirection />
129
+
130
+ <DevOnlyToolbarOpenInEditor
131
+ v-if="__HISTOIRE_DEV__"
132
+ :file="storyStore.currentStory.file?.filePath"
133
+ tooltip="Edit story in editor"
134
+ />
128
135
  </div>
129
136
 
130
137
  <div
@@ -6,6 +6,7 @@ import ToolbarResponsiveSize from '../toolbar/ToolbarResponsiveSize.vue'
6
6
  import ToolbarBackground from '../toolbar/ToolbarBackground.vue'
7
7
  import ToolbarTextDirection from '../toolbar/ToolbarTextDirection.vue'
8
8
  import ToolbarNewTab from '../toolbar/ToolbarNewTab.vue'
9
+ import DevOnlyToolbarOpenInEditor from '../toolbar/DevOnlyToolbarOpenInEditor.vue'
9
10
  import StoryVariantSinglePreviewNative from './StoryVariantSinglePreviewNative.vue'
10
11
  import StoryVariantSinglePreviewRemote from './StoryVariantSinglePreviewRemote.vue'
11
12
 
@@ -37,6 +38,12 @@ defineProps<{
37
38
  :variant="variant"
38
39
  :story="story"
39
40
  />
41
+
42
+ <DevOnlyToolbarOpenInEditor
43
+ v-if="__HISTOIRE_DEV__"
44
+ :file="story.file?.filePath"
45
+ tooltip="Edit story in editor"
46
+ />
40
47
  </div>
41
48
 
42
49
  <!-- Preview -->
@@ -82,6 +82,7 @@ function scrollDocsToTop () {
82
82
  >
83
83
  <StoryDocs
84
84
  :story="storyStore.currentStory"
85
+ standalone
85
86
  class="md:htw-p-12 htw-w-full md:htw-max-w-[600px] lg:htw-max-w-[800px] xl:htw-max-w-[900px]"
86
87
  @scroll-top="scrollDocsToTop()"
87
88
  />
@@ -0,0 +1,23 @@
1
+ <script lang="ts" setup>
2
+ import { Icon } from '@iconify/vue'
3
+ import { openInEditor } from '../../util/open-in-editor.js'
4
+
5
+ defineProps<{
6
+ file: string
7
+ tooltip: string
8
+ }>()
9
+ </script>
10
+
11
+ <template>
12
+ <a
13
+ v-tooltip="tooltip"
14
+ target="_blank"
15
+ class="histoire-toolbar-open-in-editor htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100"
16
+ @click="openInEditor(file)"
17
+ >
18
+ <Icon
19
+ icon="carbon:script-reference"
20
+ class="htw-w-4 htw-h-4"
21
+ />
22
+ </a>
23
+ </template>
package/src/app/index.ts CHANGED
@@ -4,8 +4,9 @@ import { createPinia } from 'pinia'
4
4
  import FloatingVue from 'floating-vue'
5
5
  import App from './App.vue'
6
6
  import { router } from './router'
7
+ import { setupPluginApi } from './plugin.js'
7
8
 
8
- export function mountMainApp () {
9
+ export async function mountMainApp () {
9
10
  const app = createApp(App)
10
11
  app.use(createPinia())
11
12
  app.use(FloatingVue, {
@@ -26,5 +27,8 @@ export function mountMainApp () {
26
27
 
27
28
  if (import.meta.hot) {
28
29
  import.meta.hot.send('histoire:mount', {})
30
+
31
+ // eslint-disable-next-line spaced-comment
32
+ /*#__PURE__*/ setupPluginApi()
29
33
  }
30
34
  }
@@ -0,0 +1,58 @@
1
+ import { router } from './router.js'
2
+
3
+ export function setupPluginApi () {
4
+ if (!import.meta.hot) return
5
+
6
+ const listeners: Record<string, Set<(result: any) => unknown>> = {}
7
+
8
+ import.meta.hot.on('histoire:dev-event-result', ({ event, result }) => {
9
+ const set = listeners[event]
10
+ if (set) {
11
+ for (const listener of set) {
12
+ listener(result)
13
+ }
14
+ }
15
+ })
16
+
17
+ function addDevEventListener (event: string, listener: (result: any) => unknown) {
18
+ let set = listeners[event]
19
+ if (!set) {
20
+ set = new Set()
21
+ listeners[event] = set
22
+ }
23
+ set.add(listener)
24
+ return () => {
25
+ set.delete(listener)
26
+ }
27
+ }
28
+
29
+ // function removeDevEventListener (event: string, listener: (result: any) => unknown) {
30
+ // const set = listeners[event]
31
+ // if (set) {
32
+ // set.delete(listener)
33
+ // }
34
+ // }
35
+
36
+ window.__HST_PLUGIN_API__ = {
37
+ sendEvent: (event: string, payload?: any) => {
38
+ return new Promise((resolve) => {
39
+ import.meta.hot.send(`histoire:dev-event`, {
40
+ event,
41
+ payload,
42
+ })
43
+ if (event.startsWith('on')) {
44
+ resolve(undefined)
45
+ } else {
46
+ const off = addDevEventListener(event, (result: any) => {
47
+ off()
48
+ resolve(result)
49
+ })
50
+ }
51
+ })
52
+ },
53
+
54
+ openStory: (storyId: string) => {
55
+ router.push({ name: 'story', params: { storyId } })
56
+ },
57
+ }
58
+ }
@@ -6,13 +6,13 @@ import GenericMountStory from './components/story/GenericMountStory.vue'
6
6
  import GenericRenderStory from './components/story/GenericRenderStory.vue'
7
7
  import type { StoryFile } from './types'
8
8
  import { mapFile } from './util/mapping'
9
- // @ts-expect-error virtual module
10
9
  import { files } from 'virtual:$histoire-stories'
11
10
  import { PREVIEW_SETTINGS_SYNC, STATE_SYNC, SANDBOX_READY } from './util/const.js'
12
11
  import { applyPreviewSettings } from './util/preview-settings.js'
13
12
  import { isDark } from './util/dark.js'
14
13
  import { histoireConfig } from './util/config.js'
15
14
  import { toRawDeep } from './util/state.js'
15
+ import { setupPluginApi } from './plugin.js'
16
16
 
17
17
  const query = parseQuery(window.location.search)
18
18
  const file = ref<StoryFile>(mapFile(files.find(f => f.id === query.storyId)))
@@ -95,3 +95,8 @@ watch(isDark, value => {
95
95
  }, {
96
96
  immediate: true,
97
97
  })
98
+
99
+ if (import.meta.hot) {
100
+ // eslint-disable-next-line spaced-comment
101
+ /*#__PURE__*/ setupPluginApi()
102
+ }
@@ -0,0 +1,25 @@
1
+ import { ClientCommand } from '@histoire/shared'
2
+ import { defineStore } from 'pinia'
3
+ import { ref } from 'vue'
4
+ import { executeCommand, getCommandContext } from '../util/commands.js'
5
+
6
+ export const useCommandStore = defineStore('command', () => {
7
+ const selectedCommand = ref<ClientCommand | null>(null)
8
+ const showPromptsModal = ref(false)
9
+
10
+ function activateCommand (command: ClientCommand) {
11
+ selectedCommand.value = command
12
+ if (command.prompts?.length) {
13
+ showPromptsModal.value = true
14
+ } else {
15
+ const params = command.getParams?.(getCommandContext()) ?? {}
16
+ executeCommand(command, params)
17
+ }
18
+ }
19
+
20
+ return {
21
+ selectedCommand,
22
+ showPromptsModal,
23
+ activateCommand,
24
+ }
25
+ })
package/src/app/types.ts CHANGED
@@ -28,18 +28,23 @@ export type Tree = (TreeGroup | TreeFolder | TreeLeaf)[]
28
28
 
29
29
  export type SearchResultType = 'title' | 'docs'
30
30
 
31
- export interface SearchResult {
32
- kind: 'story' | 'variant'
31
+ export interface SearchResultBase {
32
+ kind: 'story' | 'variant' | 'command'
33
33
  rank: number
34
34
  id: string
35
35
  title: string
36
- route: RouteLocationRaw
37
- type: SearchResultType
38
36
  path?: string[]
39
37
  icon?: string
40
38
  iconColor?: string
39
+ type?: SearchResultType
41
40
  }
42
41
 
42
+ export type SearchResult = SearchResultBase & ({
43
+ route: RouteLocationRaw
44
+ } | {
45
+ onActivate: () => unknown
46
+ })
47
+
43
48
  export interface PreviewSettings {
44
49
  responsiveWidth: number
45
50
  responsiveHeight: number
@@ -48,3 +53,20 @@ export interface PreviewSettings {
48
53
  checkerboard: boolean
49
54
  textDirection: 'ltr' | 'rtl'
50
55
  }
56
+
57
+ declare module 'vue' {
58
+ interface ComponentCustomProperties {
59
+ __HISTOIRE_DEV__: boolean
60
+ }
61
+ }
62
+
63
+ declare global {
64
+ const __HISTOIRE_DEV__: boolean
65
+
66
+ interface Window {
67
+ __HST_PLUGIN_API__: {
68
+ sendEvent: (event: string, payload: any) => Promise<any>
69
+ openStory: (storyId: string) => void
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,56 @@
1
+ import type { ClientCommand, ClientCommandContext } from '@histoire/shared'
2
+ import { router } from '../router.js'
3
+ import { openInEditor } from './open-in-editor.js'
4
+ import { useStoryStore } from '../stores/story.js'
5
+
6
+ export const builtinCommands: ClientCommand[] = [
7
+ {
8
+ id: 'builtin:open-in-editor',
9
+ label: 'Open file in editor',
10
+ icon: 'carbon:script-reference',
11
+ showIf: ({ route }) => route.name === 'story' && !!useStoryStore().currentStory,
12
+ getParams: () => {
13
+ const story = useStoryStore().currentStory
14
+ let file: string
15
+ if (story.docsOnly) {
16
+ file = story.file?.docsFilePath ?? story.file?.filePath
17
+ } else {
18
+ file = story.file?.filePath
19
+ }
20
+ return {
21
+ file,
22
+ }
23
+ },
24
+ clientAction: ({ file }) => {
25
+ openInEditor(file)
26
+ },
27
+ },
28
+ {
29
+ id: 'builtin:histoire-docs',
30
+ label: 'Open Histoire Documentation',
31
+ icon: 'carbon:help',
32
+ clientAction: () => {
33
+ window.open('https://histoire.dev/guide/getting-started.html', '_blank')
34
+ },
35
+ },
36
+ ]
37
+
38
+ export function executeCommand (command: ClientCommand, params: Record<string, any>) {
39
+ if (import.meta.hot) {
40
+ import.meta.hot.send('histoire:dev-command', {
41
+ id: command.id,
42
+ params,
43
+ })
44
+
45
+ command.clientAction?.(params, getCommandContext())
46
+ }
47
+ }
48
+
49
+ export function getCommandContext (): ClientCommandContext {
50
+ const storyStore = useStoryStore()
51
+ return {
52
+ route: router.currentRoute.value,
53
+ currentStory: storyStore.currentStory,
54
+ currentVariant: storyStore.currentVariant,
55
+ }
56
+ }
@@ -1,5 +1,4 @@
1
1
  import type { HistoireConfig } from '@histoire/shared'
2
- // @ts-expect-error virtual module
3
2
  import { config as configRaw, logos as logosRaw } from 'virtual:$histoire-config'
4
3
 
5
4
  export const histoireConfig: HistoireConfig = configRaw
@@ -95,5 +95,8 @@ export function formatKey (key: string) {
95
95
  if (key === 'meta') {
96
96
  return '⌘'
97
97
  }
98
+ if (key === 'enter') {
99
+ return '⏎'
100
+ }
98
101
  return key.charAt(0).toUpperCase() + key.substring(1).toLowerCase()
99
102
  }
@@ -0,0 +1,3 @@
1
+ export function openInEditor (file: string) {
2
+ return fetch(`${import.meta.env.BASE_URL}__open-in-editor?file=${encodeURIComponent(file)}`)
3
+ }
@@ -0,0 +1,29 @@
1
+ import { Ref, ref, watch, computed } from 'vue'
2
+
3
+ export function useSelection (list: Ref<any[]>) {
4
+ const selectedIndex = ref(0)
5
+
6
+ watch(list, () => {
7
+ selectedIndex.value = 0
8
+ })
9
+
10
+ function selectNext () {
11
+ selectedIndex.value++
12
+ if (selectedIndex.value > list.value.length - 1) {
13
+ selectedIndex.value = 0
14
+ }
15
+ }
16
+
17
+ function selectPrevious () {
18
+ selectedIndex.value--
19
+ if (selectedIndex.value < 0) {
20
+ selectedIndex.value = list.value.length - 1
21
+ }
22
+ }
23
+
24
+ return {
25
+ selectedIndex: computed(() => selectedIndex.value),
26
+ selectNext,
27
+ selectPrevious,
28
+ }
29
+ }
@@ -9,5 +9,5 @@ export function makeTooltip (descriptionHtml: string, keyboardShortcut: ({ isMac
9
9
  }
10
10
 
11
11
  function genKeyboardShortcutHtml (shortcut: string) {
12
- return shortcut.split('+').map(k => k.trim()).map(key => `<span class="htw-bg-gray-500 htw-border-b-2 htw-border-gray-600 htw-px-1 htw-rounded-sm">${formatKey(key)}</span>`).join('')
12
+ return `<span class="htw-border htw-border-gray-600 htw-px-1 htw-rounded-sm htw-text-gray-400">${shortcut.split('+').map(k => formatKey(k.trim())).join(' ')}</span>`
13
13
  }
@@ -0,0 +1,6 @@
1
+ declare module 'virtual:$histoire-commands' {
2
+ import type { ClientCommand } from '@histoire/shared'
3
+ export const registeredCommands: ClientCommand[]
4
+ }
5
+
6
+ declare module 'virtual:*';