histoire 0.2.1 → 0.2.4

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 (67) hide show
  1. package/dist/client/app/App.vue +1 -1
  2. package/dist/client/app/codegen/vue3.js +11 -1
  3. package/dist/client/app/codegen/vue3.ts +9 -1
  4. package/dist/client/app/components/app/AppHeader.vue +3 -3
  5. package/dist/client/app/components/base/BaseListItemLink.vue +1 -1
  6. package/dist/client/app/components/base/BaseTab.vue +1 -1
  7. package/dist/client/app/components/exposed/Story.vue +25 -14
  8. package/dist/client/app/components/exposed/Variant.vue +7 -0
  9. package/dist/client/app/components/search/SearchModal.vue +7 -6
  10. package/dist/client/app/components/story/StoryResponsivePreview.vue +72 -77
  11. package/dist/client/app/components/story/StorySidePanel.vue +1 -1
  12. package/dist/client/app/components/story/StorySourceCode.vue +3 -17
  13. package/dist/client/app/components/story/StoryVariantGrid.vue +112 -0
  14. package/dist/client/app/components/story/StoryVariantGridItem.vue +36 -6
  15. package/dist/client/app/components/story/StoryVariantSingleView.vue +10 -11
  16. package/dist/client/app/components/story/StoryViewer.vue +7 -42
  17. package/dist/client/app/components/story/{variant → toolbar}/StoryVariantBackground.vue +4 -4
  18. package/{src/client/app/components/story/variant → dist/client/app/components/story/toolbar}/StoryVariantNewTab.vue +2 -2
  19. package/dist/client/app/components/story/{variant → toolbar}/StoryVariantResponsiveSize.vue +5 -5
  20. package/dist/client/app/components/story/{variant → toolbar}/StoryVariantTitle.vue +0 -0
  21. package/dist/client/app/stores/preview-settings.d.ts +8 -0
  22. package/dist/client/app/stores/preview-settings.js +14 -0
  23. package/dist/client/app/stores/preview-settings.ts +17 -0
  24. package/dist/client/app/stores/story.d.ts +45 -15
  25. package/dist/client/app/style/main.pcss +4 -0
  26. package/dist/client/app/types.d.ts +10 -1
  27. package/dist/client/app/types.ts +11 -1
  28. package/dist/client/app/util/mapping.js +10 -9
  29. package/dist/client/app/util/mapping.ts +10 -5
  30. package/dist/client/app/util/preview-settings.d.ts +1 -8
  31. package/dist/client/app/util/preview-settings.js +0 -10
  32. package/dist/client/app/util/preview-settings.ts +1 -19
  33. package/dist/client/app/util/scroll.d.ts +3 -1
  34. package/dist/client/app/util/scroll.js +3 -0
  35. package/dist/client/app/util/scroll.ts +4 -0
  36. package/dist/node/config.d.ts +2 -2
  37. package/dist/node/plugin.js +14 -6
  38. package/dist/style.css +67 -4
  39. package/package.json +21 -21
  40. package/src/client/app/App.vue +1 -1
  41. package/src/client/app/codegen/vue3.ts +9 -1
  42. package/src/client/app/components/app/AppHeader.vue +3 -3
  43. package/src/client/app/components/base/BaseListItemLink.vue +1 -1
  44. package/src/client/app/components/base/BaseTab.vue +1 -1
  45. package/src/client/app/components/exposed/Story.vue +25 -14
  46. package/src/client/app/components/exposed/Variant.vue +7 -0
  47. package/src/client/app/components/search/SearchModal.vue +7 -6
  48. package/src/client/app/components/story/StoryResponsivePreview.vue +72 -77
  49. package/src/client/app/components/story/StorySidePanel.vue +1 -1
  50. package/src/client/app/components/story/StorySourceCode.vue +3 -17
  51. package/src/client/app/components/story/StoryVariantGrid.vue +112 -0
  52. package/src/client/app/components/story/StoryVariantGridItem.vue +36 -6
  53. package/src/client/app/components/story/StoryVariantSingleView.vue +10 -11
  54. package/src/client/app/components/story/StoryViewer.vue +7 -42
  55. package/src/client/app/components/story/{variant → toolbar}/StoryVariantBackground.vue +4 -4
  56. package/{dist/client/app/components/story/variant → src/client/app/components/story/toolbar}/StoryVariantNewTab.vue +2 -2
  57. package/src/client/app/components/story/{variant → toolbar}/StoryVariantResponsiveSize.vue +5 -5
  58. package/src/client/app/components/story/{variant → toolbar}/StoryVariantTitle.vue +0 -0
  59. package/src/client/app/stores/preview-settings.ts +17 -0
  60. package/src/client/app/style/main.pcss +4 -0
  61. package/src/client/app/types.ts +11 -1
  62. package/src/client/app/util/mapping.ts +10 -5
  63. package/src/client/app/util/preview-settings.ts +1 -19
  64. package/src/client/app/util/scroll.ts +4 -0
  65. package/src/node/config.ts +2 -2
  66. package/src/node/plugin.ts +15 -6
  67. package/tsconfig.json +2 -0
@@ -1,2 +1,4 @@
1
1
  import { Ref } from 'vue';
2
- export declare function useScrollOnActive(active: Ref<boolean>, el: Ref<HTMLElement>): void;
2
+ export declare function useScrollOnActive(active: Ref<boolean>, el: Ref<HTMLElement>): {
3
+ autoScroll: () => void;
4
+ };
@@ -21,4 +21,7 @@ export function useScrollOnActive(active, el) {
21
21
  autoScroll();
22
22
  }
23
23
  });
24
+ return {
25
+ autoScroll,
26
+ };
24
27
  }
@@ -24,4 +24,8 @@ export function useScrollOnActive (active: Ref<boolean>, el: Ref<HTMLElement>) {
24
24
  autoScroll()
25
25
  }
26
26
  })
27
+
28
+ return {
29
+ autoScroll,
30
+ }
27
31
  }
@@ -66,7 +66,7 @@ export interface HistoireConfig {
66
66
  dark?: string;
67
67
  };
68
68
  /**
69
- * Href to the favicon file (**not** processed by Vite). Put the file in the public directory.
69
+ * Href to the favicon file (**not** processed by Vite). Put the file in the `public` directory.
70
70
  *
71
71
  * Example: `'/favicon.ico'`
72
72
  */
@@ -91,7 +91,7 @@ export interface HistoireConfig {
91
91
  logoHref?: string;
92
92
  };
93
93
  /**
94
- * Setup file exposting a default function executed when setting up each story preview.
94
+ * Setup file exporting a default function executed when setting up each story preview.
95
95
  *
96
96
  * Import custom CSS files from this file.
97
97
  *
@@ -137,10 +137,10 @@ if (import.meta.hot) {
137
137
  }
138
138
  },
139
139
  configureServer(server) {
140
- server.middlewares.use((req, res, next) => {
140
+ server.middlewares.use(async (req, res, next) => {
141
141
  if (req.url.startsWith('/__sandbox')) {
142
142
  res.statusCode = 200;
143
- res.end(`
143
+ let html = `
144
144
  <!DOCTYPE html>
145
145
  <html>
146
146
  <head>
@@ -162,17 +162,21 @@ if (import.meta.hot) {
162
162
  </script>
163
163
  <script type="module" src="/@fs/${APP_PATH}/sandbox.js"></script>
164
164
  </body>
165
- </html>`);
165
+ </html>`;
166
+ // Apply Vite HTML transforms. This injects the Vite HMR client, and
167
+ // also applies HTML transforms from Vite plugins
168
+ html = await server.transformIndexHtml(req.url, html);
169
+ res.end(html);
166
170
  return;
167
171
  }
168
172
  next();
169
173
  });
170
174
  // serve our index.html after vite history fallback
171
175
  return () => {
172
- server.middlewares.use((req, res, next) => {
176
+ server.middlewares.use(async (req, res, next) => {
173
177
  if (req.url.endsWith('.html')) {
174
178
  res.statusCode = 200;
175
- res.end(`
179
+ let html = `
176
180
  <!DOCTYPE html>
177
181
  <html>
178
182
  <head>
@@ -187,7 +191,11 @@ if (import.meta.hot) {
187
191
  <div id="app"></div>
188
192
  <script type="module" src="/@fs/${APP_PATH}/index.js"></script>
189
193
  </body>
190
- </html>`);
194
+ </html>`;
195
+ // Apply Vite HTML transforms. This injects the Vite HMR client, and
196
+ // also applies HTML transforms from Vite plugins
197
+ html = await server.transformIndexHtml(req.url, html);
198
+ res.end(html);
191
199
  return;
192
200
  }
193
201
  next();
package/dist/style.css CHANGED
@@ -880,6 +880,11 @@ button {
880
880
  margin:1rem
881
881
  }
882
882
 
883
+ .htw-my-0{
884
+ margin-top:0px;
885
+ margin-bottom:0px
886
+ }
887
+
883
888
  .-htw-my-1{
884
889
  margin-top:-0.25rem;
885
890
  margin-bottom:-0.25rem
@@ -977,6 +982,12 @@ button {
977
982
  height:1rem
978
983
  }
979
984
 
985
+ .htw-h-fit{
986
+ height:-webkit-fit-content;
987
+ height:-moz-fit-content;
988
+ height:fit-content
989
+ }
990
+
980
991
  .htw-h-2{
981
992
  height:0.5rem
982
993
  }
@@ -989,6 +1000,10 @@ button {
989
1000
  height:2.5rem
990
1001
  }
991
1002
 
1003
+ .htw-h-\[100px\]{
1004
+ height:100px
1005
+ }
1006
+
992
1007
  .htw-max-h-full{
993
1008
  max-height:100%
994
1009
  }
@@ -1033,6 +1048,12 @@ button {
1033
1048
  width:1rem
1034
1049
  }
1035
1050
 
1051
+ .htw-w-fit{
1052
+ width:-webkit-fit-content;
1053
+ width:-moz-fit-content;
1054
+ width:fit-content
1055
+ }
1056
+
1036
1057
  .htw-w-px{
1037
1058
  width:1px
1038
1059
  }
@@ -1055,6 +1076,10 @@ button {
1055
1076
  width:7rem
1056
1077
  }
1057
1078
 
1079
+ .htw-w-16{
1080
+ width:4rem
1081
+ }
1082
+
1058
1083
  .htw-min-w-0{
1059
1084
  min-width:0px
1060
1085
  }
@@ -1135,6 +1160,10 @@ button {
1135
1160
  resize:vertical
1136
1161
  }
1137
1162
 
1163
+ .htw-grid-cols-\[repeat\(auto-fill\,minmax\(100px\,1fr\)\)\]{
1164
+ grid-template-columns:repeat(auto-fill,minmax(100px,1fr))
1165
+ }
1166
+
1138
1167
  .htw-flex-col{
1139
1168
  flex-direction:column
1140
1169
  }
@@ -1147,6 +1176,10 @@ button {
1147
1176
  place-content:space-between
1148
1177
  }
1149
1178
 
1179
+ .htw-items-end{
1180
+ align-items:flex-end
1181
+ }
1182
+
1150
1183
  .htw-items-center{
1151
1184
  align-items:center
1152
1185
  }
@@ -1159,14 +1192,14 @@ button {
1159
1192
  justify-content:center
1160
1193
  }
1161
1194
 
1162
- .htw-gap-2{
1163
- gap:0.5rem
1164
- }
1165
-
1166
1195
  .htw-gap-1{
1167
1196
  gap:0.25rem
1168
1197
  }
1169
1198
 
1199
+ .htw-gap-2{
1200
+ gap:0.5rem
1201
+ }
1202
+
1170
1203
  .htw-gap-4{
1171
1204
  gap:1rem
1172
1205
  }
@@ -1269,6 +1302,10 @@ button {
1269
1302
  border-width:8px
1270
1303
  }
1271
1304
 
1305
+ .htw-border-2{
1306
+ border-width:2px
1307
+ }
1308
+
1272
1309
  .htw-border-b-2{
1273
1310
  border-bottom-width:2px
1274
1311
  }
@@ -1529,10 +1566,20 @@ button {
1529
1566
  line-height:1.75rem
1530
1567
  }
1531
1568
 
1569
+ .htw-text-5xl{
1570
+ font-size:3rem;
1571
+ line-height:1
1572
+ }
1573
+
1532
1574
  .htw-text-white\/40{
1533
1575
  color:rgb(255 255 255 / 0.4)
1534
1576
  }
1535
1577
 
1578
+ .htw-text-gray-900{
1579
+ --tw-text-opacity:1;
1580
+ color:rgb(var(--_histoire-color-gray-900) / var(--tw-text-opacity))
1581
+ }
1582
+
1536
1583
  .htw-text-primary-500{
1537
1584
  --tw-text-opacity:1;
1538
1585
  color:rgb(var(--_histoire-color-primary-500) / var(--tw-text-opacity))
@@ -1676,6 +1723,10 @@ body,
1676
1723
  font-family: 'Lato', sans-serif;
1677
1724
  }
1678
1725
 
1726
+ html {
1727
+ font-size: 16px;
1728
+ }
1729
+
1679
1730
  body {
1680
1731
  font-size: 18px;
1681
1732
  }
@@ -1732,6 +1783,10 @@ body {
1732
1783
  color:rgb(var(--_histoire-color-primary-500) / var(--tw-text-opacity))
1733
1784
  }
1734
1785
 
1786
+ .hover\:htw-opacity-100:hover{
1787
+ opacity:1
1788
+ }
1789
+
1735
1790
  .focus\:htw-border-primary-500:focus{
1736
1791
  --tw-border-opacity:1;
1737
1792
  border-color:rgb(var(--_histoire-color-primary-500) / var(--tw-border-opacity))
@@ -1746,10 +1801,18 @@ body {
1746
1801
  border-color:rgb(var(--_histoire-color-primary-500) / var(--tw-border-opacity))
1747
1802
  }
1748
1803
 
1804
+ .htw-group:hover .group-hover\:htw-block{
1805
+ display:block
1806
+ }
1807
+
1749
1808
  .htw-group:hover .group-hover\:htw-opacity-90{
1750
1809
  opacity:0.9
1751
1810
  }
1752
1811
 
1812
+ .htw-group:hover .group-hover\:htw-opacity-100{
1813
+ opacity:1
1814
+ }
1815
+
1753
1816
  .htw-group:active .group-active\:htw-bg-gray-500\/20{
1754
1817
  background-color:rgb(var(--_histoire-color-gray-500) / 0.2)
1755
1818
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.2.1",
3
+ "version": "0.2.4",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,38 +33,38 @@
33
33
  "histoire": "./bin.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@iconify/vue": "^3.1.3",
37
- "@histoire/controls": "^0.2.1",
38
- "@vitejs/plugin-vue": "^2.2.0",
39
- "@vueuse/core": "^8.1.1",
40
- "birpc": "^0.1.0",
36
+ "@histoire/controls": "^0.2.4",
37
+ "@iconify/vue": "^3.2.1",
38
+ "@vitejs/plugin-vue": "^2.3.1",
39
+ "@vueuse/core": "^8.2.5",
40
+ "birpc": "^0.1.1",
41
41
  "case": "^1.6.3",
42
42
  "chokidar": "^3.5.3",
43
43
  "connect": "^3.7.0",
44
44
  "defu": "^5.0.1",
45
45
  "diacritics": "^1.3.0",
46
- "floating-vue": "^2.0.0-beta.6",
47
- "fs-extra": "^10.0.0",
46
+ "floating-vue": "^2.0.0-beta.14",
47
+ "fs-extra": "^10.0.1",
48
48
  "globby": "^13.1.1",
49
- "happy-dom": "^2.33.1",
49
+ "happy-dom": "^2.55.0",
50
50
  "markdown-it": "^12.3.2",
51
- "markdown-it-anchor": "^8.4.1",
51
+ "markdown-it-anchor": "^8.6.2",
52
52
  "markdown-it-attrs": "^4.1.3",
53
53
  "markdown-it-emoji": "^2.0.0",
54
54
  "mrmime": "^1.0.0",
55
55
  "pathe": "^0.2.0",
56
56
  "picocolors": "^1.0.0",
57
- "pinia": "^2.0.11",
57
+ "pinia": "^2.0.13",
58
58
  "sade": "^1.8.1",
59
59
  "scroll-into-view-if-needed": "^2.2.29",
60
60
  "shiki": "^0.10.1",
61
61
  "sirv": "^2.0.2",
62
62
  "tinypool": "^0.1.2",
63
- "vite-node": "=0.7.6",
64
- "vue-router": "^4.0.12"
63
+ "vite-node": "0.7.6",
64
+ "vue-router": "^4.0.14"
65
65
  },
66
66
  "peerDependencies": {
67
- "vite": "^2.8.3",
67
+ "vite": "^2.9.0",
68
68
  "vue": "^3.2.31"
69
69
  },
70
70
  "devDependencies": {
@@ -72,14 +72,14 @@
72
72
  "@tailwindcss/typography": "^0.5.2",
73
73
  "@types/fs-extra": "^9.0.13",
74
74
  "@types/markdown-it": "^12.2.3",
75
- "@types/node": "^17.0.18",
76
- "autoprefixer": "^10.4.2",
77
- "concurrently": "^7.0.0",
78
- "postcss": "^8.4.6",
79
- "postcss-import": "^14.0.2",
75
+ "@types/node": "^17.0.23",
76
+ "autoprefixer": "^10.4.4",
77
+ "concurrently": "^7.1.0",
78
+ "postcss": "^8.4.12",
79
+ "postcss-import": "^14.1.0",
80
80
  "tailwindcss": "^3.0.23",
81
- "typescript": "^4.5.5",
82
- "vite": "^2.8.3",
81
+ "typescript": "^4.6.3",
82
+ "vite": "^2.9.1",
83
83
  "vue": "^3.2.31"
84
84
  },
85
85
  "scripts": {
@@ -102,7 +102,7 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
102
102
  class="htw-h-full"
103
103
  >
104
104
  <template #first>
105
- <div class="htw-flex htw-flex-col htw-h-full htw-gap-2">
105
+ <div class="htw-flex htw-flex-col htw-h-full">
106
106
  <AppHeader
107
107
  class="htw-flex-none"
108
108
  @search="isSearchOpen = true"
@@ -33,7 +33,9 @@ async function printVNode (vnode: VNode): Promise<string[]> {
33
33
 
34
34
  const attrs: string[][] = []
35
35
  let multilineAttrs = false
36
- const skipProps: string[] = []
36
+ const skipProps: string[] = [
37
+ 'key',
38
+ ]
37
39
 
38
40
  // Directives
39
41
  function genDirective (dirName: string, dir, valueCode: string = null) {
@@ -138,6 +140,8 @@ async function printVNode (vnode: VNode): Promise<string[]> {
138
140
  if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
139
141
  // It was formatted from auto building object (slot props)
140
142
  serialized = [value.substring(2, value.length - 2).trim()]
143
+ } else if (typeof value === 'function') {
144
+ serialized = [value.toString()]
141
145
  } else {
142
146
  serialized = serializeAndCleanJs(value)
143
147
  }
@@ -230,6 +234,10 @@ async function printVNode (vnode: VNode): Promise<string[]> {
230
234
  } else {
231
235
  lines.push(`${tag[0]} />`)
232
236
  }
237
+ } else if (vnode?.shapeFlag & 1 << 4) {
238
+ for (const child of vnode.children) {
239
+ lines.push(...await printVNode(child))
240
+ }
233
241
  }
234
242
 
235
243
  return lines
@@ -29,7 +29,7 @@ onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
29
29
  <a
30
30
  :href="histoireConfig.theme?.logoHref"
31
31
  target="_blank"
32
- class="htw-block htw-w-full htw-h-full"
32
+ class="htw-w-full htw-h-full htw-flex htw-items-center"
33
33
  >
34
34
  <AppLogo
35
35
  class="htw-max-w-full htw-max-h-full"
@@ -39,7 +39,7 @@ onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
39
39
  <div class="htw-ml-auto htw-flex-none htw-flex">
40
40
  <a
41
41
  v-tooltip="makeTooltip('Search', ({ isMac }) => isMac ? 'meta+k' : 'ctrl+k')"
42
- class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
42
+ class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-text-gray-900 dark:htw-text-gray-100"
43
43
  data-test-id="search-btn"
44
44
  @click="$emit('search')"
45
45
  >
@@ -51,7 +51,7 @@ onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
51
51
 
52
52
  <a
53
53
  v-tooltip="makeTooltip('Toggle dark mode', ({ isMac }) => isMac ? 'meta+shift+d' : 'ctrl+shift+d')"
54
- class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
54
+ class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-text-gray-900 dark:htw-text-gray-100"
55
55
  @click="toggleDark()"
56
56
  >
57
57
  <Icon
@@ -36,7 +36,7 @@ export default defineComponent({
36
36
  >
37
37
  <a
38
38
  :href="href"
39
- class="htw-flex htw-items-center htw-gap-2"
39
+ class="htw-flex htw-items-center htw-gap-2 htw-text-gray-900 dark:htw-text-gray-100"
40
40
  :class="[
41
41
  $attrs.class,
42
42
  (isActive != null ? isActive : linkIsActive)
@@ -27,7 +27,7 @@ export default defineComponent({
27
27
  <a
28
28
  v-bind="$attrs"
29
29
  :href="href"
30
- class="htw-px-4 htw-h-full htw-inline-flex htw-items-center hover:htw-bg-primary-50 dark:hover:htw-bg-primary-900 htw-relative"
30
+ class="htw-px-4 htw-h-full htw-inline-flex htw-items-center hover:htw-bg-primary-50 dark:hover:htw-bg-primary-900 htw-relative htw-text-gray-900 dark:htw-text-gray-100"
31
31
  :class="{
32
32
  'htw-text-primary-500 dark:htw-text-primary-400': matched != null ? matched : (exact && isExactActive) || (!exact && isActive),
33
33
  }"
@@ -40,22 +40,33 @@ export default defineComponent({
40
40
  }, this.$slots)
41
41
  }
42
42
 
43
- // Apply variant as attribute to each child vnode (should be `<Variant>` components)
44
- const vnodes: VNode[] = this.$slots.default()
45
- // @ts-expect-error custom option
46
- .filter(vnode => vnode.type?.__histoireType === 'variant')
47
- // Same number of vnodes as variants
48
- .slice(0, this.story.variants.length)
49
- for (const index in vnodes) {
50
- const vnode = vnodes[index]
51
- if (!vnode.props) {
52
- vnode.props = {}
53
- }
54
- vnode.props.variant = this.story.variants[index]
55
- if (!vnode.props.initState && !vnode.props['init-state']) {
56
- vnode.props.initState = this.initState
43
+ let index = 0
44
+ const applyAttrs = (vnodes: VNode[]) => {
45
+ for (const vnode of vnodes) {
46
+ // @ts-expect-error custom option
47
+ if (vnode.type?.__histoireType === 'variant') {
48
+ if (!vnode.props) {
49
+ vnode.props = {}
50
+ }
51
+ vnode.props.variant = this.story.variants[index]
52
+ if (!vnode.props.initState && !vnode.props['init-state']) {
53
+ vnode.props.initState = this.initState
54
+ }
55
+ for (const attr in this.$attrs) {
56
+ if (typeof vnode.props[attr] === 'undefined') {
57
+ vnode.props[attr] = this.$attrs[attr]
58
+ }
59
+ }
60
+ index++
61
+ } else if (vnode.children?.length) {
62
+ applyAttrs(vnode.children as VNode[])
63
+ }
57
64
  }
58
65
  }
66
+
67
+ // Apply variant as attribute to each child vnode (should be `<Variant>` components)
68
+ const vnodes: VNode[] = this.$slots.default()
69
+ applyAttrs(vnodes)
59
70
  return vnodes
60
71
  },
61
72
  })
@@ -17,6 +17,11 @@ export default defineComponent({
17
17
  type: String,
18
18
  default: null,
19
19
  },
20
+
21
+ responsiveDisabled: {
22
+ type: Boolean,
23
+ default: false,
24
+ },
20
25
  },
21
26
 
22
27
  setup (props) {
@@ -35,6 +40,8 @@ export default defineComponent({
35
40
  },
36
41
  slots: () => vm.proxy.$slots,
37
42
  source: props.source,
43
+ responsiveDisabled: props.responsiveDisabled,
44
+ configReady: true,
38
45
  })
39
46
  }
40
47
  updateVariant()
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { useFocus } from '@vueuse/core'
2
+ import { useFocus, useDebounce } from '@vueuse/core'
3
3
  import { computed, ref, watch } from 'vue'
4
4
  import { Icon } from '@iconify/vue'
5
5
  import { useStoryStore } from '../../stores/story'
@@ -40,7 +40,8 @@ watch(() => props.shown, value => {
40
40
 
41
41
  // Search
42
42
 
43
- const search = ref('')
43
+ const searchInputText = ref('')
44
+ const rateLimitedSearch = useDebounce(searchInputText, 300)
44
45
 
45
46
  const storyStore = useStoryStore()
46
47
 
@@ -85,8 +86,8 @@ function variantResultFactory (story: Story, variant: Variant, rank: number): Se
85
86
 
86
87
  const results = computed(() => {
87
88
  const list: SearchResult[] = []
88
- if (search.value) {
89
- const s = search.value.toLowerCase()
89
+ if (rateLimitedSearch.value) {
90
+ const s = rateLimitedSearch.value.toLowerCase()
90
91
  for (const story of storyStore.stories) {
91
92
  const storyMatched = story.title.toLowerCase().includes(s)
92
93
  let storyPathMatched = false
@@ -149,7 +150,7 @@ function selectPrevious () {
149
150
 
150
151
  <input
151
152
  ref="input"
152
- v-model="search"
153
+ v-model="searchInputText"
153
154
  placeholder="Search for stories, variants..."
154
155
  class="htw-bg-transparent htw-w-full htw-flex-1 htw-pl-0 htw-pr-6 htw-py-4 htw-outline-none"
155
156
  @keydown.down.prevent="selectNext()"
@@ -158,7 +159,7 @@ function selectPrevious () {
158
159
  >
159
160
  </div>
160
161
 
161
- <BaseEmpty v-if="search && !results.length">
162
+ <BaseEmpty v-if="rateLimitedSearch && !results.length">
162
163
  No results
163
164
  </BaseEmpty>
164
165