@ohos-ports/histoire-app 1.0.0-beta.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 (309) hide show
  1. package/LICENSE +21 -0
  2. package/dist/app/assets/histoire-text-dark.svg +89 -0
  3. package/dist/app/assets/histoire-text.svg +89 -0
  4. package/dist/app/assets/histoire.svg +51 -0
  5. package/dist/app/style/floating.pcss +34 -0
  6. package/dist/app/style/main.pcss +100 -0
  7. package/dist/app/style/sandbox.css +24 -0
  8. package/dist/app/style/transitions.pcss +51 -0
  9. package/dist/bundle-index.js +3 -0
  10. package/dist/bundle-main-dev.js +4 -0
  11. package/dist/bundle-main.js +5 -0
  12. package/dist/bundle-sandbox-dev.js +2 -0
  13. package/dist/bundle-sandbox.js +2 -0
  14. package/dist/bundled/App.vue.js +5 -0
  15. package/dist/bundled/App.vue2.js +167 -0
  16. package/dist/bundled/_virtual/_node-dom-env.js +188 -0
  17. package/dist/bundled/_virtual/_node-dom-polyfill.js +152 -0
  18. package/dist/bundled/_virtual/_plugin-vue_export-helper.js +10 -0
  19. package/dist/bundled/_virtual/histoire-commands.js +8 -0
  20. package/dist/bundled/_virtual/histoire-config.js +42 -0
  21. package/dist/bundled/_virtual/histoire-markdown-files.js +8 -0
  22. package/dist/bundled/_virtual/histoire-search-docs-data.js +11 -0
  23. package/dist/bundled/_virtual/histoire-search-title-data.js +11 -0
  24. package/dist/bundled/_virtual/histoire-stories.js +17 -0
  25. package/dist/bundled/_virtual/histoire-support-plugins-client.js +8 -0
  26. package/dist/bundled/_virtual/histoire-theme.js +8 -0
  27. package/dist/bundled/api.js +12 -0
  28. package/dist/bundled/app.css +116 -0
  29. package/dist/bundled/assets/histoire-text-dark.svg.js +4 -0
  30. package/dist/bundled/assets/histoire-text.svg.js +4 -0
  31. package/dist/bundled/assets/histoire.svg.js +4 -0
  32. package/dist/bundled/components/HomeView.vue.js +5 -0
  33. package/dist/bundled/components/HomeView.vue2.js +66 -0
  34. package/dist/bundled/components/app/AppHeader.vue.js +5 -0
  35. package/dist/bundled/components/app/AppHeader.vue2.js +71 -0
  36. package/dist/bundled/components/app/AppLogo.vue.js +5 -0
  37. package/dist/bundled/components/app/AppLogo.vue2.js +29 -0
  38. package/dist/bundled/components/app/Breadcrumb.vue.js +8 -0
  39. package/dist/bundled/components/app/Breadcrumb.vue2.js +91 -0
  40. package/dist/bundled/components/app/HomeCounter.vue.js +5 -0
  41. package/dist/bundled/components/app/HomeCounter.vue2.js +42 -0
  42. package/dist/bundled/components/app/InitialLoading.vue.js +5 -0
  43. package/dist/bundled/components/app/InitialLoading.vue2.js +51 -0
  44. package/dist/bundled/components/app/MobileOverlay.vue.js +5 -0
  45. package/dist/bundled/components/app/MobileOverlay.vue2.js +45 -0
  46. package/dist/bundled/components/base/BaseButton.vue.js +5 -0
  47. package/dist/bundled/components/base/BaseButton.vue2.js +39 -0
  48. package/dist/bundled/components/base/BaseCheckbox.vue.js +5 -0
  49. package/dist/bundled/components/base/BaseCheckbox.vue2.js +78 -0
  50. package/dist/bundled/components/base/BaseEmpty.vue.js +14 -0
  51. package/dist/bundled/components/base/BaseIcon.vue.js +8 -0
  52. package/dist/bundled/components/base/BaseIcon.vue2.js +29 -0
  53. package/dist/bundled/components/base/BaseKeyboardShortcut.vue.js +5 -0
  54. package/dist/bundled/components/base/BaseKeyboardShortcut.vue2.js +20 -0
  55. package/dist/bundled/components/base/BaseListItem.vue.js +5 -0
  56. package/dist/bundled/components/base/BaseListItem.vue2.js +33 -0
  57. package/dist/bundled/components/base/BaseListItemLink.vue.js +33 -0
  58. package/dist/bundled/components/base/BaseListItemLink.vue2.js +26 -0
  59. package/dist/bundled/components/base/BaseOverflowMenu.vue.js +5 -0
  60. package/dist/bundled/components/base/BaseOverflowMenu.vue2.js +100 -0
  61. package/dist/bundled/components/base/BaseOverflowTab.vue.js +36 -0
  62. package/dist/bundled/components/base/BaseOverflowTab.vue2.js +18 -0
  63. package/dist/bundled/components/base/BaseSelect.vue.js +5 -0
  64. package/dist/bundled/components/base/BaseSelect.vue2.js +77 -0
  65. package/dist/bundled/components/base/BaseSplitPane.vue.js +8 -0
  66. package/dist/bundled/components/base/BaseSplitPane.vue2.js +183 -0
  67. package/dist/bundled/components/base/BaseTab.vue.js +36 -0
  68. package/dist/bundled/components/base/BaseTab.vue2.js +18 -0
  69. package/dist/bundled/components/base/BaseTag.vue.js +13 -0
  70. package/dist/bundled/components/command/CommandPrompts.vue.js +5 -0
  71. package/dist/bundled/components/command/CommandPrompts.vue2.js +91 -0
  72. package/dist/bundled/components/command/CommandPromptsModal.vue.js +5 -0
  73. package/dist/bundled/components/command/CommandPromptsModal.vue2.js +45 -0
  74. package/dist/bundled/components/command/PromptSelect.vue.js +5 -0
  75. package/dist/bundled/components/command/PromptSelect.vue2.js +142 -0
  76. package/dist/bundled/components/command/PromptText.vue.js +5 -0
  77. package/dist/bundled/components/command/PromptText.vue2.js +67 -0
  78. package/dist/bundled/components/misc/CheckerboardPattern.vue.js +40 -0
  79. package/dist/bundled/components/misc/HatchedPattern.vue.js +12 -0
  80. package/dist/bundled/components/panel/ControlsComponentPropItem.vue.js +5 -0
  81. package/dist/bundled/components/panel/ControlsComponentPropItem.vue2.js +72 -0
  82. package/dist/bundled/components/panel/ControlsComponentProps.vue.js +5 -0
  83. package/dist/bundled/components/panel/ControlsComponentProps.vue2.js +45 -0
  84. package/dist/bundled/components/panel/ControlsComponentState.vue.js +5 -0
  85. package/dist/bundled/components/panel/ControlsComponentState.vue2.js +41 -0
  86. package/dist/bundled/components/panel/ControlsComponentStateItem.vue.js +5 -0
  87. package/dist/bundled/components/panel/ControlsComponentStateItem.vue2.js +46 -0
  88. package/dist/bundled/components/panel/PaneTabs.vue.js +5 -0
  89. package/dist/bundled/components/panel/PaneTabs.vue2.js +114 -0
  90. package/dist/bundled/components/panel/StatePresets.vue.js +5 -0
  91. package/dist/bundled/components/panel/StatePresets.vue2.js +193 -0
  92. package/dist/bundled/components/panel/StoryControls.vue.js +5 -0
  93. package/dist/bundled/components/panel/StoryControls.vue2.js +87 -0
  94. package/dist/bundled/components/panel/StoryDocs.vue.js +7 -0
  95. package/dist/bundled/components/panel/StoryDocs.vue2.js +161 -0
  96. package/dist/bundled/components/panel/StoryEvent.vue.js +5 -0
  97. package/dist/bundled/components/panel/StoryEvent.vue2.js +59 -0
  98. package/dist/bundled/components/panel/StoryEvents.vue.js +5 -0
  99. package/dist/bundled/components/panel/StoryEvents.vue2.js +53 -0
  100. package/dist/bundled/components/panel/StorySidePanel.vue.js +5 -0
  101. package/dist/bundled/components/panel/StorySidePanel.vue2.js +83 -0
  102. package/dist/bundled/components/panel/StorySourceCode.vue.js +8 -0
  103. package/dist/bundled/components/panel/StorySourceCode.vue2.js +204 -0
  104. package/dist/bundled/components/search/SearchItem.vue.js +8 -0
  105. package/dist/bundled/components/search/SearchItem.vue2.js +93 -0
  106. package/dist/bundled/components/search/SearchItemContent.vue.js +5 -0
  107. package/dist/bundled/components/search/SearchItemContent.vue2.js +71 -0
  108. package/dist/bundled/components/search/SearchLoading.vue.js +5 -0
  109. package/dist/bundled/components/search/SearchLoading.vue2.js +21 -0
  110. package/dist/bundled/components/search/SearchModal.vue.js +5 -0
  111. package/dist/bundled/components/search/SearchModal.vue2.js +51 -0
  112. package/dist/bundled/components/search/SearchPane.vue.js +5 -0
  113. package/dist/bundled/components/search/SearchPane.vue2.js +272 -0
  114. package/dist/bundled/components/search/search-docs-data.js +11 -0
  115. package/dist/bundled/components/search/search-title-data.js +11 -0
  116. package/dist/bundled/components/story/GenericMountStory.vue.js +5 -0
  117. package/dist/bundled/components/story/GenericMountStory.vue2.js +34 -0
  118. package/dist/bundled/components/story/GenericRenderStory.vue.js +5 -0
  119. package/dist/bundled/components/story/GenericRenderStory.vue2.js +39 -0
  120. package/dist/bundled/components/story/StoryResponsivePreview.vue.js +8 -0
  121. package/dist/bundled/components/story/StoryResponsivePreview.vue2.js +207 -0
  122. package/dist/bundled/components/story/StoryVariantGrid.vue.js +5 -0
  123. package/dist/bundled/components/story/StoryVariantGrid.vue2.js +146 -0
  124. package/dist/bundled/components/story/StoryVariantGridItem.vue.js +8 -0
  125. package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +153 -0
  126. package/dist/bundled/components/story/StoryVariantListItem.vue.js +8 -0
  127. package/dist/bundled/components/story/StoryVariantListItem.vue2.js +55 -0
  128. package/dist/bundled/components/story/StoryVariantSingle.vue.js +8 -0
  129. package/dist/bundled/components/story/StoryVariantSingle.vue2.js +107 -0
  130. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue.js +5 -0
  131. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +70 -0
  132. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue.js +5 -0
  133. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue2.js +128 -0
  134. package/dist/bundled/components/story/StoryVariantSingleView.vue.js +5 -0
  135. package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +66 -0
  136. package/dist/bundled/components/story/StoryView.vue.js +5 -0
  137. package/dist/bundled/components/story/StoryView.vue2.js +104 -0
  138. package/dist/bundled/components/story/StoryViewer.vue.js +8 -0
  139. package/dist/bundled/components/story/StoryViewer.vue2.js +55 -0
  140. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue.js +5 -0
  141. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue2.js +31 -0
  142. package/dist/bundled/components/toolbar/ToolbarBackground.vue.js +8 -0
  143. package/dist/bundled/components/toolbar/ToolbarBackground.vue2.js +98 -0
  144. package/dist/bundled/components/toolbar/ToolbarNewTab.vue.js +5 -0
  145. package/dist/bundled/components/toolbar/ToolbarNewTab.vue2.js +36 -0
  146. package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue.js +5 -0
  147. package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue2.js +127 -0
  148. package/dist/bundled/components/toolbar/ToolbarTextDirection.vue.js +5 -0
  149. package/dist/bundled/components/toolbar/ToolbarTextDirection.vue2.js +27 -0
  150. package/dist/bundled/components/toolbar/ToolbarTitle.vue.js +5 -0
  151. package/dist/bundled/components/toolbar/ToolbarTitle.vue2.js +26 -0
  152. package/dist/bundled/components/tree/StoryGroup.vue.js +5 -0
  153. package/dist/bundled/components/tree/StoryGroup.vue2.js +74 -0
  154. package/dist/bundled/components/tree/StoryList.vue.js +5 -0
  155. package/dist/bundled/components/tree/StoryList.vue2.js +41 -0
  156. package/dist/bundled/components/tree/StoryListFolder.vue.js +8 -0
  157. package/dist/bundled/components/tree/StoryListFolder.vue2.js +86 -0
  158. package/dist/bundled/components/tree/StoryListItem.vue.js +8 -0
  159. package/dist/bundled/components/tree/StoryListItem.vue2.js +69 -0
  160. package/dist/bundled/index.js +36 -0
  161. package/dist/bundled/plugin.js +49 -0
  162. package/dist/bundled/router.js +32 -0
  163. package/dist/bundled/sandbox.js +87 -0
  164. package/dist/bundled/stores/command.js +25 -0
  165. package/dist/bundled/stores/events.js +29 -0
  166. package/dist/bundled/stores/folder.js +54 -0
  167. package/dist/bundled/stores/preview-settings.js +19 -0
  168. package/dist/bundled/stores/story.js +43 -0
  169. package/dist/bundled/util/commands.js +57 -0
  170. package/dist/bundled/util/config.js +8 -0
  171. package/dist/bundled/util/const.js +10 -0
  172. package/dist/bundled/util/dark.js +28 -0
  173. package/dist/bundled/util/docs.js +26 -0
  174. package/dist/bundled/util/env.js +4 -0
  175. package/dist/bundled/util/events.js +33 -0
  176. package/dist/bundled/util/keyboard.js +90 -0
  177. package/dist/bundled/util/mapping.js +70 -0
  178. package/dist/bundled/util/open-in-editor.js +7 -0
  179. package/dist/bundled/util/preview-settings.js +21 -0
  180. package/dist/bundled/util/responsive.js +6 -0
  181. package/dist/bundled/util/sandbox.js +11 -0
  182. package/dist/bundled/util/scroll.js +31 -0
  183. package/dist/bundled/util/select.js +28 -0
  184. package/dist/bundled/util/state.js +41 -0
  185. package/dist/bundled/util/tooltip.js +15 -0
  186. package/dist/bundled/util/variant.js +21 -0
  187. package/dist/style.css +2853 -0
  188. package/package.json +62 -0
  189. package/postcss-scope-wrapper.cjs +35 -0
  190. package/postcss.config.cjs +9 -0
  191. package/scripts/copy.mjs +12 -0
  192. package/scripts/watchAndCopy.mjs +15 -0
  193. package/src/app/App.vue +172 -0
  194. package/src/app/api.ts +9 -0
  195. package/src/app/assets/histoire-text-dark.svg +89 -0
  196. package/src/app/assets/histoire-text.svg +89 -0
  197. package/src/app/assets/histoire.svg +51 -0
  198. package/src/app/components/HomeView.vue +61 -0
  199. package/src/app/components/app/AppHeader.vue +65 -0
  200. package/src/app/components/app/AppLogo.vue +25 -0
  201. package/src/app/components/app/Breadcrumb.vue +98 -0
  202. package/src/app/components/app/HomeCounter.vue +39 -0
  203. package/src/app/components/app/InitialLoading.vue +44 -0
  204. package/src/app/components/app/MobileOverlay.vue +33 -0
  205. package/src/app/components/base/BaseButton.vue +33 -0
  206. package/src/app/components/base/BaseCheckbox.vue +76 -0
  207. package/src/app/components/base/BaseCopyIcon.vue +34 -0
  208. package/src/app/components/base/BaseEmpty.vue +21 -0
  209. package/src/app/components/base/BaseIcon.vue +31 -0
  210. package/src/app/components/base/BaseKeyboardShortcut.vue +16 -0
  211. package/src/app/components/base/BaseListItem.vue +30 -0
  212. package/src/app/components/base/BaseListItemLink.vue +56 -0
  213. package/src/app/components/base/BaseOverflowMenu.vue +119 -0
  214. package/src/app/components/base/BaseOverflowTab.vue +47 -0
  215. package/src/app/components/base/BaseSelect.vue +75 -0
  216. package/src/app/components/base/BaseSplitPane.vue +244 -0
  217. package/src/app/components/base/BaseTab.vue +47 -0
  218. package/src/app/components/base/BaseTag.vue +5 -0
  219. package/src/app/components/command/CommandPrompts.vue +95 -0
  220. package/src/app/components/command/CommandPromptsModal.vue +41 -0
  221. package/src/app/components/command/PromptSelect.vue +142 -0
  222. package/src/app/components/command/PromptText.vue +65 -0
  223. package/src/app/components/misc/CheckerboardPattern.vue +32 -0
  224. package/src/app/components/misc/HatchedPattern.vue +13 -0
  225. package/src/app/components/panel/ControlsComponentPropItem.vue +73 -0
  226. package/src/app/components/panel/ControlsComponentProps.vue +34 -0
  227. package/src/app/components/panel/ControlsComponentState.vue +38 -0
  228. package/src/app/components/panel/ControlsComponentStateItem.vue +44 -0
  229. package/src/app/components/panel/PaneTabs.vue +84 -0
  230. package/src/app/components/panel/StatePresets.vue +199 -0
  231. package/src/app/components/panel/StoryControls.vue +97 -0
  232. package/src/app/components/panel/StoryDocs.vue +202 -0
  233. package/src/app/components/panel/StoryEvent.vue +54 -0
  234. package/src/app/components/panel/StoryEvents.vue +48 -0
  235. package/src/app/components/panel/StorySidePanel.vue +76 -0
  236. package/src/app/components/panel/StorySourceCode.vue +248 -0
  237. package/src/app/components/search/SearchItem.vue +89 -0
  238. package/src/app/components/search/SearchItemContent.vue +67 -0
  239. package/src/app/components/search/SearchLoading.vue +16 -0
  240. package/src/app/components/search/SearchModal.vue +44 -0
  241. package/src/app/components/search/SearchPane.vue +319 -0
  242. package/src/app/components/search/search-docs-data.ts +9 -0
  243. package/src/app/components/search/search-title-data.ts +9 -0
  244. package/src/app/components/search/types.ts +4 -0
  245. package/src/app/components/story/GenericMountStory.vue +35 -0
  246. package/src/app/components/story/GenericRenderStory.vue +41 -0
  247. package/src/app/components/story/StoryResponsivePreview.vue +216 -0
  248. package/src/app/components/story/StoryVariantGrid.vue +169 -0
  249. package/src/app/components/story/StoryVariantGridItem.vue +163 -0
  250. package/src/app/components/story/StoryVariantListItem.vue +52 -0
  251. package/src/app/components/story/StoryVariantSingle.vue +105 -0
  252. package/src/app/components/story/StoryVariantSinglePreviewNative.vue +66 -0
  253. package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +143 -0
  254. package/src/app/components/story/StoryVariantSingleView.vue +61 -0
  255. package/src/app/components/story/StoryView.vue +110 -0
  256. package/src/app/components/story/StoryViewer.vue +52 -0
  257. package/src/app/components/toolbar/DevOnlyToolbarOpenInEditor.vue +23 -0
  258. package/src/app/components/toolbar/ToolbarBackground.vue +81 -0
  259. package/src/app/components/toolbar/ToolbarNewTab.vue +29 -0
  260. package/src/app/components/toolbar/ToolbarResponsiveSize.vue +82 -0
  261. package/src/app/components/toolbar/ToolbarTextDirection.vue +19 -0
  262. package/src/app/components/toolbar/ToolbarTitle.vue +21 -0
  263. package/src/app/components/tree/StoryGroup.vue +73 -0
  264. package/src/app/components/tree/StoryList.vue +35 -0
  265. package/src/app/components/tree/StoryListFolder.vue +88 -0
  266. package/src/app/components/tree/StoryListItem.vue +72 -0
  267. package/src/app/index.ts +33 -0
  268. package/src/app/plugin.ts +59 -0
  269. package/src/app/router.ts +29 -0
  270. package/src/app/sandbox.ts +101 -0
  271. package/src/app/stores/command.ts +26 -0
  272. package/src/app/stores/events.ts +36 -0
  273. package/src/app/stores/folder.ts +63 -0
  274. package/src/app/stores/preview-settings.ts +18 -0
  275. package/src/app/stores/story.ts +47 -0
  276. package/src/app/style/floating.pcss +34 -0
  277. package/src/app/style/main.pcss +100 -0
  278. package/src/app/style/sandbox.css +24 -0
  279. package/src/app/style/transitions.pcss +51 -0
  280. package/src/app/types.ts +72 -0
  281. package/src/app/util/commands.ts +57 -0
  282. package/src/app/util/config.ts +5 -0
  283. package/src/app/util/const.ts +4 -0
  284. package/src/app/util/dark.ts +27 -0
  285. package/src/app/util/docs.ts +27 -0
  286. package/src/app/util/env.ts +1 -0
  287. package/src/app/util/events.ts +31 -0
  288. package/src/app/util/keyboard.ts +103 -0
  289. package/src/app/util/mapping.ts +80 -0
  290. package/src/app/util/open-in-editor.ts +3 -0
  291. package/src/app/util/preview-settings.ts +23 -0
  292. package/src/app/util/responsive.ts +3 -0
  293. package/src/app/util/sandbox.ts +9 -0
  294. package/src/app/util/scroll.ts +32 -0
  295. package/src/app/util/select.ts +30 -0
  296. package/src/app/util/state.ts +45 -0
  297. package/src/app/util/tooltip.ts +13 -0
  298. package/src/app/util/variant.ts +21 -0
  299. package/src/bundle-index.js +1 -0
  300. package/src/bundle-main-dev.js +4 -0
  301. package/src/bundle-main.js +5 -0
  302. package/src/bundle-sandbox-dev.js +2 -0
  303. package/src/bundle-sandbox.js +2 -0
  304. package/src/index.ts +1 -0
  305. package/src/shim.d.ts +10 -0
  306. package/src/virtual.d.ts +7 -0
  307. package/tailwind.config.cjs +137 -0
  308. package/tsconfig.json +53 -0
  309. package/vite.config.ts +88 -0
@@ -0,0 +1,72 @@
1
+ <script lang="ts" setup>
2
+ import type { Story } from '../../types'
3
+ import { Icon } from '@iconify/vue'
4
+ import { computed, ref } from 'vue'
5
+ import { useRoute } from 'vue-router'
6
+ import { useScrollOnActive } from '../../util/scroll'
7
+ import BaseListItemLink from '../base/BaseListItemLink.vue'
8
+
9
+ const props = withDefaults(defineProps<{
10
+ story: Story
11
+ depth?: number
12
+ }>(), {
13
+ depth: 0,
14
+ })
15
+
16
+ const filePadding = computed(() => {
17
+ return `${props.depth * 12}px`
18
+ })
19
+
20
+ const route = useRoute()
21
+ const isActive = computed(() => route.params.storyId === props.story.id)
22
+ const el = ref<HTMLDivElement>()
23
+ useScrollOnActive(isActive, el)
24
+ </script>
25
+
26
+ <template>
27
+ <div
28
+ ref="el"
29
+ data-test-id="story-list-item"
30
+ class="histoire-story-list-item"
31
+ >
32
+ <BaseListItemLink
33
+ v-slot="{ active }"
34
+ :to="{
35
+ name: 'story',
36
+ params: {
37
+ storyId: story.id,
38
+ },
39
+ }"
40
+ class="htw-pl-0.5 htw-pr-2 htw-py-2 md:htw-py-1.5 htw-mx-1 htw-rounded-sm"
41
+ >
42
+ <span class="bind-tree-margin htw-flex htw-items-center htw-gap-2 htw-pl-4 htw-min-w-0">
43
+ <Icon
44
+ :icon="story.icon ?? 'carbon:cube'"
45
+ class="htw-w-5 htw-h-5 sm:htw-w-4 sm:htw-h-4 htw-flex-none"
46
+ :class="{
47
+ 'htw-text-primary-500': !active && !story.iconColor,
48
+ 'bind-icon-color': !active && story.iconColor,
49
+ }"
50
+ />
51
+ <span class="htw-truncate">{{ story.title }}</span>
52
+ </span>
53
+
54
+ <span
55
+ v-if="!story.docsOnly"
56
+ class="htw-opacity-40 htw-text-sm"
57
+ >
58
+ {{ story.variants.length }}
59
+ </span>
60
+ </BaseListItemLink>
61
+ </div>
62
+ </template>
63
+
64
+ <style scoped>
65
+ .bind-tree-margin {
66
+ margin-left: v-bind(filePadding);
67
+ }
68
+
69
+ .bind-icon-color {
70
+ color: v-bind('story.iconColor');
71
+ }
72
+ </style>
@@ -0,0 +1,33 @@
1
+ import FloatingVue from 'floating-vue'
2
+ import { createPinia } from 'pinia'
3
+ import { createApp } from 'vue'
4
+ import App from './App.vue'
5
+ import { setupPluginApi } from './plugin.js'
6
+ import { router } from './router'
7
+ import 'virtual:$histoire-theme'
8
+
9
+ export async function mountMainApp() {
10
+ const app = createApp(App)
11
+ app.use(createPinia())
12
+ app.use(FloatingVue, {
13
+ overflowPadding: 4,
14
+ arrowPadding: 8,
15
+ themes: {
16
+ tooltip: {
17
+ distance: 8,
18
+ },
19
+ dropdown: {
20
+ computeTransformOrigin: true,
21
+ distance: 8,
22
+ },
23
+ },
24
+ })
25
+ app.use(router)
26
+ app.mount('#app')
27
+
28
+ if (import.meta.hot) {
29
+ import.meta.hot.send('histoire:mount', {})
30
+
31
+ /* #__PURE__ */ setupPluginApi()
32
+ }
33
+ }
@@ -0,0 +1,59 @@
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
+ }
46
+ else {
47
+ const off = addDevEventListener(event, (result: any) => {
48
+ off()
49
+ resolve(result)
50
+ })
51
+ }
52
+ })
53
+ },
54
+
55
+ openStory: (storyId: string) => {
56
+ router.push({ name: 'story', params: { storyId } })
57
+ },
58
+ }
59
+ }
@@ -0,0 +1,29 @@
1
+ import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
2
+ import { histoireConfig } from './util/config'
3
+
4
+ export const base = import.meta.env.BASE_URL as string
5
+
6
+ function createRouterHistory() {
7
+ switch (histoireConfig.routerMode) {
8
+ case 'hash': return createWebHashHistory(base)
9
+ case 'history':
10
+ default:
11
+ return createWebHistory(base)
12
+ }
13
+ }
14
+
15
+ export const router = createRouter({
16
+ history: createRouterHistory(),
17
+ routes: [
18
+ {
19
+ path: '/',
20
+ name: 'home',
21
+ component: () => import('./components/HomeView.vue'),
22
+ },
23
+ {
24
+ path: '/story/:storyId',
25
+ name: 'story',
26
+ component: () => import('./components/story/StoryView.vue'),
27
+ },
28
+ ],
29
+ })
@@ -0,0 +1,101 @@
1
+ import type { StoryFile } from './types'
2
+ import { applyState } from '@histoire/shared'
3
+ import { createPinia } from 'pinia'
4
+ import { files } from 'virtual:$histoire-stories'
5
+ import { computed, createApp, h, onMounted, ref, watch } from 'vue'
6
+ import { parseQuery } from 'vue-router'
7
+ import GenericMountStory from './components/story/GenericMountStory.vue'
8
+ import GenericRenderStory from './components/story/GenericRenderStory.vue'
9
+ import { setupPluginApi } from './plugin.js'
10
+ import { histoireConfig } from './util/config.js'
11
+ import { PREVIEW_SETTINGS_SYNC, SANDBOX_READY, STATE_SYNC } from './util/const.js'
12
+ import { isDark } from './util/dark.js'
13
+ import { mapFile } from './util/mapping'
14
+ import { applyPreviewSettings } from './util/preview-settings.js'
15
+ import { toRawDeep } from './util/state.js'
16
+
17
+ const query = parseQuery(window.location.search)
18
+ const file = ref<StoryFile>(mapFile(files.find(f => f.id === query.storyId)))
19
+
20
+ const app = createApp({
21
+ name: 'SandboxApp',
22
+
23
+ setup() {
24
+ const story = computed(() => file.value.story)
25
+ const variant = computed(() => story.value?.variants.find(v => v.id === query.variantId))
26
+
27
+ let synced = false
28
+ let mounted = false
29
+
30
+ window.addEventListener('message', (event) => {
31
+ // console.log('[sandbox] received message', event.data)
32
+ if (event.data?.type === STATE_SYNC) {
33
+ if (!mounted) return
34
+ synced = true
35
+ applyState(variant.value.state, event.data.state)
36
+ }
37
+ else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
38
+ applyPreviewSettings(event.data.settings)
39
+ }
40
+ })
41
+
42
+ watch(() => variant.value.state, (value) => {
43
+ if (synced && mounted) {
44
+ synced = false
45
+ return
46
+ }
47
+ window.parent?.postMessage({
48
+ type: STATE_SYNC,
49
+ state: toRawDeep(value, true),
50
+ })
51
+ }, {
52
+ deep: true,
53
+ })
54
+
55
+ onMounted(() => {
56
+ mounted = true
57
+ })
58
+
59
+ return {
60
+ story,
61
+ variant,
62
+ }
63
+ },
64
+
65
+ render() {
66
+ return [
67
+ h('div', { class: 'htw-sandbox-hidden' }, [
68
+ h(GenericMountStory, {
69
+ key: file.value.story.id,
70
+ story: file.value.story,
71
+ }),
72
+ ]),
73
+ this.story && this.variant
74
+ ? h(GenericRenderStory, { story: this.story, variant: this.variant, onReady: () => {
75
+ window.parent?.postMessage({
76
+ type: SANDBOX_READY,
77
+ })
78
+ } })
79
+ : null,
80
+ ]
81
+ },
82
+ })
83
+ app.use(createPinia())
84
+ app.mount('#app')
85
+
86
+ watch(isDark, (value) => {
87
+ if (value) {
88
+ document.documentElement.classList.add(histoireConfig.sandboxDarkClass) // @TODO remove
89
+ document.documentElement.classList.add(histoireConfig.theme.darkClass)
90
+ }
91
+ else {
92
+ document.documentElement.classList.remove(histoireConfig.sandboxDarkClass) // @TODO remove
93
+ document.documentElement.classList.remove(histoireConfig.theme.darkClass)
94
+ }
95
+ }, {
96
+ immediate: true,
97
+ })
98
+
99
+ if (import.meta.hot) {
100
+ /* #__PURE__ */ setupPluginApi()
101
+ }
@@ -0,0 +1,26 @@
1
+ import type { 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
+ }
15
+ else {
16
+ const params = command.getParams?.(getCommandContext()) ?? {}
17
+ executeCommand(command, params)
18
+ }
19
+ }
20
+
21
+ return {
22
+ selectedCommand,
23
+ showPromptsModal,
24
+ activateCommand,
25
+ }
26
+ })
@@ -0,0 +1,36 @@
1
+ import { defineStore } from 'pinia'
2
+ import { reactive, ref, watch } from 'vue'
3
+ import { useStoryStore } from './story.js'
4
+
5
+ export interface HstEvent {
6
+ name: string
7
+ argument: unknown
8
+ }
9
+
10
+ export const useEventsStore = defineStore('events', () => {
11
+ const storyStore = useStoryStore()
12
+
13
+ const events = reactive<Array<HstEvent>>([])
14
+ const unseen = ref(0)
15
+
16
+ function addEvent(event: HstEvent) {
17
+ events.push(event)
18
+ unseen.value++
19
+ }
20
+
21
+ function reset() {
22
+ events.length = 0
23
+ unseen.value = 0
24
+ }
25
+
26
+ watch(() => storyStore.currentVariant?.id, () => {
27
+ reset()
28
+ })
29
+
30
+ return {
31
+ addEvent,
32
+ reset,
33
+ events,
34
+ unseen,
35
+ }
36
+ })
@@ -0,0 +1,63 @@
1
+ import { useStorage } from '@vueuse/core'
2
+ import { defineStore } from 'pinia'
3
+ import { watch } from 'vue'
4
+ import { useStoryStore } from './story'
5
+
6
+ export const useFolderStore = defineStore('folder', () => {
7
+ const openedFolders = useStorage<Map<string, boolean>>(
8
+ '_histoire-tree-state',
9
+ new Map(),
10
+ )
11
+
12
+ function getStringPath(path: Array<string>) {
13
+ return path.join('␜')
14
+ }
15
+
16
+ function toggleFolder(path: Array<string>, defaultToggleValue = true) {
17
+ const stringPath = getStringPath(path)
18
+
19
+ const currentValue = openedFolders.value.get(stringPath)
20
+
21
+ if (currentValue == null) {
22
+ setFolderOpen(stringPath, defaultToggleValue)
23
+ }
24
+ else if (currentValue) {
25
+ setFolderOpen(stringPath, false)
26
+ }
27
+ else {
28
+ setFolderOpen(stringPath, true)
29
+ }
30
+ }
31
+
32
+ function setFolderOpen(path: Array<string> | string, value: boolean) {
33
+ const stringPath = typeof path === 'string' ? path : getStringPath(path)
34
+ openedFolders.value.set(stringPath, value)
35
+ }
36
+
37
+ function isFolderOpened(path: Array<string>, defaultValue = false) {
38
+ const value = openedFolders.value.get(getStringPath(path))
39
+ if (value == null) {
40
+ return defaultValue
41
+ }
42
+ return value
43
+ }
44
+
45
+ function openFileFolders(path: Array<string>) {
46
+ for (let pathLength = 1; pathLength < path.length; pathLength++) {
47
+ setFolderOpen(path.slice(0, pathLength), true)
48
+ }
49
+ }
50
+
51
+ const storyStore = useStoryStore()
52
+
53
+ watch(() => storyStore.currentStory, (story) => {
54
+ if (story) {
55
+ openFileFolders(story.file.path)
56
+ }
57
+ })
58
+
59
+ return {
60
+ isFolderOpened,
61
+ toggleFolder,
62
+ }
63
+ })
@@ -0,0 +1,18 @@
1
+ import type { PreviewSettings } from '../types'
2
+ import { useStorage } from '@vueuse/core'
3
+ import { defineStore } from 'pinia'
4
+
5
+ export const usePreviewSettingsStore = defineStore('preview-settings', () => {
6
+ const currentSettings = useStorage<PreviewSettings>('_histoire-sandbox-settings-v3', {
7
+ responsiveWidth: 720,
8
+ responsiveHeight: null,
9
+ rotate: false,
10
+ backgroundColor: 'transparent',
11
+ checkerboard: false,
12
+ textDirection: 'ltr',
13
+ })
14
+
15
+ return {
16
+ currentSettings,
17
+ }
18
+ })
@@ -0,0 +1,47 @@
1
+ import type { Story, Variant } from '../types'
2
+ import { defineStore } from 'pinia'
3
+ import { computed, ref } from 'vue'
4
+ import { router } from '../router'
5
+
6
+ export const useStoryStore = defineStore('story', () => {
7
+ const stories = ref<Story[]>([])
8
+ function setStories(value: Story[]) {
9
+ stories.value = value
10
+ }
11
+
12
+ const currentStory = computed(() => stories.value.find(s => s.id === router.currentRoute.value.params.storyId))
13
+
14
+ const currentVariant = computed(() => currentStory.value?.variants.find(v => v.id === router.currentRoute.value.query.variantId))
15
+
16
+ const maps = computed(() => {
17
+ const storyMap = new Map<string, Story>()
18
+ const variantMap = new Map<string, Variant>()
19
+ for (const story of stories.value) {
20
+ storyMap.set(story.id, story)
21
+ for (const variant of story.variants) {
22
+ variantMap.set(`${story.id}:${variant.id}`, variant)
23
+ }
24
+ }
25
+ return {
26
+ stories: storyMap,
27
+ variants: variantMap,
28
+ }
29
+ })
30
+
31
+ function getStoryById(id: string) {
32
+ return maps.value.stories.get(id)
33
+ }
34
+
35
+ function getVariantById(idWithStoryId: string) {
36
+ return maps.value.variants.get(idWithStoryId)
37
+ }
38
+
39
+ return {
40
+ stories,
41
+ setStories,
42
+ currentStory,
43
+ currentVariant,
44
+ getStoryById,
45
+ getVariantById,
46
+ }
47
+ })
@@ -0,0 +1,34 @@
1
+ /* @TODO custom themes */
2
+
3
+ .v-popper {
4
+ line-height: 0;
5
+ }
6
+
7
+ .v-popper--theme-dropdown {
8
+ .htw-dark & {
9
+ .v-popper__inner {
10
+ @apply htw-bg-gray-700 htw-border-gray-850 htw-text-gray-100;
11
+ }
12
+
13
+ .v-popper__arrow-inner {
14
+ @apply htw-border-gray-700;
15
+ }
16
+
17
+ .v-popper__arrow-outer {
18
+ @apply htw-border-gray-850;
19
+ }
20
+ }
21
+
22
+ &.v-popper__popper--show-from .v-popper__wrapper {
23
+ transform: scale(.75);
24
+ }
25
+
26
+ &.v-popper__popper--show-to .v-popper__wrapper {
27
+ transform: none;
28
+ transition: transform .15s cubic-bezier(0, 1, .5, 1);
29
+ }
30
+ }
31
+
32
+ .v-popper__popper:focus-visible {
33
+ outline: none;
34
+ }
@@ -0,0 +1,100 @@
1
+ @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Display&display=swap');
2
+ @import 'floating-vue/dist/style.css';
3
+ @import '@histoire/controls/dist/index.es.css';
4
+
5
+ @import 'floating.pcss';
6
+ @import 'transitions.pcss';
7
+
8
+ *,
9
+ ::before,
10
+ ::after {
11
+ box-sizing: border-box;
12
+ border-width: 0;
13
+ border-style: solid;
14
+ border-color: #e5e7eb;
15
+ }
16
+
17
+ a,
18
+ input,
19
+ button {
20
+ color: inherit;
21
+ }
22
+
23
+ a {
24
+ text-decoration: inherit;
25
+ }
26
+
27
+ input, button {
28
+ font-family: inherit;
29
+ }
30
+
31
+ a,
32
+ button {
33
+ user-select: none;
34
+ }
35
+
36
+ @tailwind base;
37
+ @tailwind components;
38
+ @tailwind utilities;
39
+
40
+ @layer base {
41
+ body,
42
+ pre {
43
+ margin: 0;
44
+ }
45
+
46
+ html,
47
+ body,
48
+ #app {
49
+ height: 100%;
50
+ }
51
+
52
+ html {
53
+ font-family: 'Noto Sans Display', system-ui, sans-serif;
54
+ font-size: 1rem;
55
+ }
56
+
57
+ body {
58
+ font-size: 1.125rem;
59
+ }
60
+
61
+ @media (min-width: 640px) {
62
+ body {
63
+ font-size: .875rem;
64
+ }
65
+ }
66
+
67
+ .__histoire-render-story:not(.__histoire-render-custom-controls) {
68
+ overflow: auto;
69
+ min-height: 100%;
70
+ }
71
+
72
+ .__histoire-code .shiki {
73
+ background: transparent !important;
74
+ }
75
+
76
+ .htw-prose {
77
+ h1, h2, h3, h4 {
78
+ &:not(:hover) {
79
+ .header-anchor[aria-hidden="true"] {
80
+ visibility: hidden;
81
+ }
82
+ }
83
+ }
84
+
85
+ hr {
86
+ margin: 1rem 0;
87
+ }
88
+ }
89
+
90
+ .__histoire-pane-shadow-from-right {
91
+ background-image: linear-gradient(to left, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0));
92
+ background-size: 24px;
93
+ background-repeat: no-repeat;
94
+ background-position: right;
95
+
96
+ .htw-dark & {
97
+ background-image: linear-gradient(to left, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0));
98
+ }
99
+ }
100
+ }
@@ -0,0 +1,24 @@
1
+ @import '@histoire/controls/dist/index.es.css';
2
+
3
+ html,
4
+ body {
5
+ background: transparent !important;
6
+ }
7
+
8
+ body {
9
+ margin: 0;
10
+ }
11
+
12
+ html {
13
+ font-size: 1rem;
14
+ font-family: 'Noto Sans Display', system-ui, sans-serif;
15
+ }
16
+
17
+ .htw-sandbox-hidden {
18
+ display: none;
19
+ }
20
+
21
+ .__histoire-render-story:not(.__histoire-render-custom-controls) {
22
+ overflow: auto;
23
+ min-height: 100%;
24
+ }
@@ -0,0 +1,51 @@
1
+ .__histoire-scale-x {
2
+ &-enter-active,
3
+ &-leave-active {
4
+ transition: transform .15s, opacity .15s;
5
+ }
6
+
7
+ &-enter-from,
8
+ &-leave-to {
9
+ transform: scaleX(0);
10
+ opacity: 0;
11
+ }
12
+ }
13
+
14
+ .__histoire-scale-y {
15
+ &-enter-active,
16
+ &-leave-active {
17
+ transition: transform .15s, opacity .15s;
18
+ }
19
+
20
+ &-enter-from,
21
+ &-leave-to {
22
+ transform: scaleY(0);
23
+ opacity: 0;
24
+ }
25
+ }
26
+
27
+ .__histoire-fade {
28
+ &-enter-active,
29
+ &-leave-active {
30
+ transition: opacity .15s;
31
+ }
32
+
33
+ &-enter-from,
34
+ &-leave-to {
35
+ opacity: 0;
36
+ }
37
+ }
38
+
39
+ .__histoire-fade-bottom {
40
+ &-enter-active,
41
+ &-leave-active {
42
+ transition: transform .15s, opacity .15s;
43
+ transform: translateY(0px);
44
+ }
45
+
46
+ &-enter-from,
47
+ &-leave-to {
48
+ transform: translateY(32px);
49
+ opacity: 0;
50
+ }
51
+ }