@histoire/app 0.15.1 → 0.15.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.
@@ -2,7 +2,7 @@ import _sfc_main from "./StoryVariantGridItem.vue2.js";
2
2
  import "./StoryVariantGridItem.vue3.js";
3
3
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
4
  "use strict";
5
- const StoryVariantGridItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c1d28b37"]]);
5
+ const StoryVariantGridItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-cf76cd68"]]);
6
6
  export {
7
7
  StoryVariantGridItem as default
8
8
  };
@@ -2,19 +2,21 @@ import { defineComponent, useCssVars, unref, toRefs, ref, computed, resolveCompo
2
2
  import { Icon } from "@histoire/vendors/iconify";
3
3
  import { useRouter } from "@histoire/vendors/vue-router";
4
4
  import { useResizeObserver } from "@histoire/vendors/vue-use";
5
+ import { HstCopyIcon } from "@histoire/controls";
5
6
  import { useCurrentVariantRoute } from "../../util/variant.js";
6
7
  import { useScrollOnActive } from "../../util/scroll.js";
7
8
  import { usePreviewSettingsStore } from "../../stores/preview-settings.js";
8
9
  import { getContrastColor } from "../../util/preview-settings.js";
9
10
  import { histoireConfig } from "../../util/config.js";
10
11
  import { isDark } from "../../util/dark.js";
12
+ import { getSourceCode } from "../../util/docs.js";
11
13
  import "./GenericRenderStory.vue.js";
12
14
  import "../toolbar/ToolbarNewTab.vue.js";
13
15
  import CheckerboardPattern from "../misc/CheckerboardPattern.vue.js";
14
16
  import _sfc_main$1 from "../toolbar/ToolbarNewTab.vue2.js";
15
17
  import _sfc_main$2 from "./GenericRenderStory.vue2.js";
16
18
  "use strict";
17
- const _withScopeId = (n) => (pushScopeId("data-v-c1d28b37"), n = n(), popScopeId(), n);
19
+ const _withScopeId = (n) => (pushScopeId("data-v-cf76cd68"), n = n(), popScopeId(), n);
18
20
  const _hoisted_1 = { class: "htw-flex-none htw-flex htw-items-center" };
19
21
  const _hoisted_2 = { class: "htw-truncate htw-flex-1" };
20
22
  const _hoisted_3 = { class: "htw-flex-none htw-ml-auto htw-hidden group-hover:htw-flex htw-items-center" };
@@ -41,8 +43,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
41
43
  setup(__props, { emit }) {
42
44
  const props = __props;
43
45
  useCssVars((_ctx) => ({
44
- "d647bf7e": unref(variant).iconColor,
45
- "772419ec": unref(settings).backgroundColor
46
+ "29d8c174": unref(variant).iconColor,
47
+ "0eff7465": unref(settings).backgroundColor
46
48
  }));
47
49
  const { variant } = toRefs(props);
48
50
  const { isActive, targetRoute } = useCurrentVariantRoute(variant);
@@ -102,6 +104,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
102
104
  [_directive_tooltip, unref(variant).title]
103
105
  ]),
104
106
  createElementVNode("div", _hoisted_3, [
107
+ createVNode(unref(HstCopyIcon), {
108
+ content: () => unref(getSourceCode)(__props.story, unref(variant))
109
+ }, null, 8, ["content"]),
105
110
  createVNode(_sfc_main$1, {
106
111
  variant: unref(variant),
107
112
  story: __props.story
@@ -1,4 +1,4 @@
1
- const StoryVariantGridItem_vue_vue_type_style_index_0_scoped_c1d28b37_lang = "";
1
+ const StoryVariantGridItem_vue_vue_type_style_index_0_scoped_cf76cd68_lang = "";
2
2
  export {
3
- StoryVariantGridItem_vue_vue_type_style_index_0_scoped_c1d28b37_lang as default
3
+ StoryVariantGridItem_vue_vue_type_style_index_0_scoped_cf76cd68_lang as default
4
4
  };
@@ -44,6 +44,10 @@
44
44
  color: var(--663732b6);
45
45
  }
46
46
 
47
+ .bind-tree-padding[data-v-2d2e4786] {
48
+ padding-left: var(--6851b0a7);
49
+ }
50
+
47
51
  .bind-tree-margin[data-v-19810958] {
48
52
  margin-left: var(--444efc12);
49
53
  }
@@ -51,47 +55,43 @@
51
55
  color: var(--ae892164);
52
56
  }
53
57
 
54
- .bind-tree-padding[data-v-2d2e4786] {
55
- padding-left: var(--6851b0a7);
56
- }
57
-
58
58
  .__histoire-code-placeholder[data-v-1bdf9905] {
59
59
  color: inherit;
60
60
  font-size: inherit;
61
61
  }
62
62
 
63
+ .bind-icon-color[data-v-ab890d9c] {
64
+ color: var(--89126aaa);
65
+ }
66
+
63
67
  .bind-icon-color[data-v-ddfc5b4f] {
64
68
  color: var(--4d25d048);
65
69
  }
66
70
 
67
- .bind-icon-color[data-v-ab890d9c] {
68
- color: var(--89126aaa);
71
+ .bind-preview-bg[data-v-c48fb2b2] {
72
+ background-color: var(--627bec82);
73
+ color: var(--35068428);
69
74
  }
70
75
 
71
- .bind-icon-color[data-v-c1d28b37] {
72
- color: var(--d647bf7e);
76
+ .bind-icon-color[data-v-cf76cd68] {
77
+ color: var(--29d8c174);
73
78
  }
74
- .bind-preview-bg[data-v-c1d28b37] {
75
- background-color: var(--772419ec);
79
+ .bind-preview-bg[data-v-cf76cd68] {
80
+ background-color: var(--0eff7465);
76
81
  }
77
82
 
78
83
  .bind-icon-color[data-v-6c8e9661] {
79
84
  color: var(--a8c1277e);
80
85
  }
81
86
 
82
- .bind-preview-bg[data-v-c48fb2b2] {
83
- background-color: var(--627bec82);
84
- color: var(--35068428);
87
+ img.colorize-black[data-v-74182813] {
88
+ filter: grayscale(100) brightness(0);
85
89
  }
86
90
 
87
91
  .bind-preview-bg[data-v-a83b1911] {
88
92
  background-color: var(--03d1950e);
89
93
  }
90
94
 
91
- img.colorize-black[data-v-74182813] {
92
- filter: grayscale(100) brightness(0);
93
- }
94
-
95
95
  .__histoire-hatched-pattern[data-v-91561117] {
96
96
  background: repeating-linear-gradient(135deg,
97
97
  transparent 0px,
@@ -0,0 +1,27 @@
1
+ import { unindent } from "@histoire/shared";
2
+ import { clientSupportPlugins } from "virtual:$histoire-support-plugins-client";
3
+ "use strict";
4
+ async function getSourceCode(story, variant) {
5
+ var _a, _b, _c, _d;
6
+ if (variant.source) {
7
+ return variant.source;
8
+ } else if ((_a = variant.slots) == null ? void 0 : _a.call(variant).source) {
9
+ const source = (_b = variant.slots) == null ? void 0 : _b.call(variant).source()[0].children;
10
+ if (source) {
11
+ return unindent(source);
12
+ }
13
+ } else {
14
+ const clientPlugin = clientSupportPlugins[(_c = story.file) == null ? void 0 : _c.supportPluginId];
15
+ if (clientPlugin) {
16
+ const pluginModule = await clientPlugin();
17
+ return pluginModule.generateSourceCode(variant);
18
+ }
19
+ }
20
+ const sourceLoader = (_d = story.file) == null ? void 0 : _d.source;
21
+ if (sourceLoader) {
22
+ return (await sourceLoader()).default;
23
+ }
24
+ }
25
+ export {
26
+ getSourceCode
27
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@histoire/app",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "description": "Pre-bundled UI for Histoire",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,9 +24,9 @@
24
24
  },
25
25
  "types": "./src/index.ts",
26
26
  "dependencies": {
27
- "@histoire/controls": "^0.15.1",
28
- "@histoire/shared": "^0.15.1",
29
- "@histoire/vendors": "^0.15.1",
27
+ "@histoire/controls": "^0.15.2",
28
+ "@histoire/shared": "^0.15.2",
29
+ "@histoire/vendors": "^0.15.2",
30
30
  "@types/flexsearch": "^0.7.3",
31
31
  "flexsearch": "0.7.21",
32
32
  "shiki-es": "^0.2.0"
@@ -3,6 +3,7 @@ import { computed, PropType, ref, toRefs } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
4
  import { useRouter } from 'vue-router'
5
5
  import { useResizeObserver } from '@vueuse/core'
6
+ import { HstCopyIcon } from '@histoire/controls'
6
7
  import { useCurrentVariantRoute } from '../../util/variant'
7
8
  import type { Story, Variant } from '../../types'
8
9
  import { useScrollOnActive } from '../../util/scroll'
@@ -10,6 +11,7 @@ import { usePreviewSettingsStore } from '../../stores/preview-settings'
10
11
  import { getContrastColor } from '../../util/preview-settings'
11
12
  import { histoireConfig } from '../../util/config'
12
13
  import { isDark } from '../../util/dark'
14
+ import { getSourceCode } from '../../util/docs'
13
15
  import GenericRenderStory from './GenericRenderStory.vue'
14
16
  import ToolbarNewTab from '../toolbar/ToolbarNewTab.vue'
15
17
  import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
@@ -97,6 +99,9 @@ const autoApplyContrastColor = computed(() => !!histoireConfig.autoApplyContrast
97
99
 
98
100
  <!-- Toolbar -->
99
101
  <div class="htw-flex-none htw-ml-auto htw-hidden group-hover:htw-flex htw-items-center">
102
+ <HstCopyIcon
103
+ :content="() => getSourceCode(story, variant)"
104
+ />
100
105
  <ToolbarNewTab
101
106
  :variant="variant"
102
107
  :story="story"
@@ -0,0 +1,25 @@
1
+ import { unindent } from '@histoire/shared'
2
+ import { clientSupportPlugins } from 'virtual:$histoire-support-plugins-client'
3
+ import type { Variant, Story } from '../types'
4
+
5
+ export async function getSourceCode (story: Story, variant: Variant) {
6
+ if (variant.source) {
7
+ return variant.source
8
+ } else if (variant.slots?.().source) {
9
+ const source = variant.slots?.().source()[0].children
10
+ if (source) {
11
+ return unindent(source)
12
+ }
13
+ } else {
14
+ const clientPlugin = clientSupportPlugins[story.file?.supportPluginId]
15
+ if (clientPlugin) {
16
+ const pluginModule = await clientPlugin()
17
+ return pluginModule.generateSourceCode(variant)
18
+ }
19
+ }
20
+
21
+ const sourceLoader = story.file?.source
22
+ if (sourceLoader) {
23
+ return (await sourceLoader()).default
24
+ }
25
+ }