histoire 0.1.5 → 0.2.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 (53) hide show
  1. package/dist/client/app/components/app/AppHeader.vue +1 -0
  2. package/dist/client/app/components/base/BaseCheckbox.vue +76 -0
  3. package/dist/client/app/components/search/SearchItem.vue +4 -1
  4. package/dist/client/app/components/search/SearchModal.vue +4 -4
  5. package/dist/client/app/components/story/StoryControls.vue +1 -1
  6. package/dist/client/app/components/story/StoryDocs.vue +1 -0
  7. package/dist/client/app/components/story/StoryListFolder.vue +1 -1
  8. package/dist/client/app/components/story/StoryListItem.vue +4 -1
  9. package/dist/client/app/components/story/StoryResponsivePreview.vue +1 -0
  10. package/dist/client/app/components/story/StorySidePanel.vue +1 -0
  11. package/dist/client/app/components/story/StorySourceCode.vue +4 -1
  12. package/dist/client/app/components/story/StoryVariantListItem.vue +4 -1
  13. package/dist/client/app/components/story/StoryVariantSingleView.vue +9 -9
  14. package/dist/client/app/components/story/StoryViewer.vue +19 -1
  15. package/dist/client/app/stores/story.d.ts +6 -6
  16. package/dist/client/app/style/main.pcss +5 -5
  17. package/dist/client/app/types.d.ts +1 -1
  18. package/dist/client/app/types.ts +1 -1
  19. package/dist/node/bin.js +7 -0
  20. package/dist/node/build.js +1 -1
  21. package/dist/node/{collect.d.ts → collect/index.d.ts} +2 -2
  22. package/dist/node/{collect.js → collect/index.js} +37 -27
  23. package/dist/node/collect/worker.d.ts +14 -0
  24. package/dist/node/collect/worker.js +36 -0
  25. package/dist/node/commands/preview.d.ts +4 -0
  26. package/dist/node/commands/preview.js +36 -0
  27. package/dist/node/server.js +1 -1
  28. package/dist/node/types.d.ts +1 -1
  29. package/dist/style.css +86 -50
  30. package/package.json +7 -3
  31. package/src/client/app/components/app/AppHeader.vue +1 -0
  32. package/src/client/app/components/base/BaseCheckbox.vue +76 -0
  33. package/src/client/app/components/search/SearchItem.vue +4 -1
  34. package/src/client/app/components/search/SearchModal.vue +4 -4
  35. package/src/client/app/components/story/StoryControls.vue +1 -1
  36. package/src/client/app/components/story/StoryDocs.vue +1 -0
  37. package/src/client/app/components/story/StoryListFolder.vue +1 -1
  38. package/src/client/app/components/story/StoryListItem.vue +4 -1
  39. package/src/client/app/components/story/StoryResponsivePreview.vue +1 -0
  40. package/src/client/app/components/story/StorySidePanel.vue +1 -0
  41. package/src/client/app/components/story/StorySourceCode.vue +4 -1
  42. package/src/client/app/components/story/StoryVariantListItem.vue +4 -1
  43. package/src/client/app/components/story/StoryVariantSingleView.vue +9 -9
  44. package/src/client/app/components/story/StoryViewer.vue +19 -1
  45. package/src/client/app/style/main.pcss +5 -5
  46. package/src/client/app/types.ts +1 -1
  47. package/src/node/bin.ts +8 -0
  48. package/src/node/build.ts +1 -1
  49. package/src/node/{collect.ts → collect/index.ts} +48 -30
  50. package/src/node/collect/worker.ts +61 -0
  51. package/src/node/commands/preview.ts +50 -0
  52. package/src/node/server.ts +1 -1
  53. package/src/node/types.ts +1 -1
package/dist/style.css CHANGED
@@ -880,6 +880,11 @@ button {
880
880
  margin:1rem
881
881
  }
882
882
 
883
+ .-htw-my-1{
884
+ margin-top:-0.25rem;
885
+ margin-bottom:-0.25rem
886
+ }
887
+
883
888
  .htw-mt-2{
884
889
  margin-top:0.5rem
885
890
  }
@@ -960,6 +965,10 @@ button {
960
965
  height:2rem
961
966
  }
962
967
 
968
+ .htw-h-\[16px\]{
969
+ height:16px
970
+ }
971
+
963
972
  .htw-h-\[2px\]{
964
973
  height:2px
965
974
  }
@@ -980,10 +989,6 @@ button {
980
989
  height:2.5rem
981
990
  }
982
991
 
983
- .htw-h-\[16px\]{
984
- height:16px
985
- }
986
-
987
992
  .htw-max-h-full{
988
993
  max-height:100%
989
994
  }
@@ -992,6 +997,10 @@ button {
992
997
  max-height:400px
993
998
  }
994
999
 
1000
+ .htw-min-h-\[26px\]{
1001
+ min-height:26px
1002
+ }
1003
+
995
1004
  .htw-w-64{
996
1005
  width:16rem
997
1006
  }
@@ -1016,6 +1025,10 @@ button {
1016
1025
  width:2rem
1017
1026
  }
1018
1027
 
1028
+ .htw-w-\[16px\]{
1029
+ width:16px
1030
+ }
1031
+
1019
1032
  .htw-w-4{
1020
1033
  width:1rem
1021
1034
  }
@@ -1038,8 +1051,8 @@ button {
1038
1051
  width:5rem
1039
1052
  }
1040
1053
 
1041
- .htw-w-\[16px\]{
1042
- width:16px
1054
+ .htw-w-28{
1055
+ width:7rem
1043
1056
  }
1044
1057
 
1045
1058
  .htw-min-w-0{
@@ -1118,6 +1131,10 @@ button {
1118
1131
  resize:none
1119
1132
  }
1120
1133
 
1134
+ .htw-resize-y{
1135
+ resize:vertical
1136
+ }
1137
+
1121
1138
  .htw-flex-col{
1122
1139
  flex-direction:column
1123
1140
  }
@@ -1210,6 +1227,14 @@ button {
1210
1227
  white-space:nowrap
1211
1228
  }
1212
1229
 
1230
+ .htw-text-ellipsis{
1231
+ text-overflow:ellipsis
1232
+ }
1233
+
1234
+ .htw-whitespace-nowrap{
1235
+ white-space:nowrap
1236
+ }
1237
+
1213
1238
  .htw-rounded-sm{
1214
1239
  border-radius:0.25rem
1215
1240
  }
@@ -1264,6 +1289,10 @@ button {
1264
1289
  border-left-width:2px
1265
1290
  }
1266
1291
 
1292
+ .htw-border-solid{
1293
+ border-style:solid
1294
+ }
1295
+
1267
1296
  .htw-border-gray-600{
1268
1297
  --tw-border-opacity:1;
1269
1298
  border-color:rgb(var(--_histoire-color-gray-600) / var(--tw-border-opacity))
@@ -1274,6 +1303,15 @@ button {
1274
1303
  border-color:rgb(var(--_histoire-color-gray-100) / var(--tw-border-opacity))
1275
1304
  }
1276
1305
 
1306
+ .htw-border-primary-500{
1307
+ --tw-border-opacity:1;
1308
+ border-color:rgb(var(--_histoire-color-primary-500) / var(--tw-border-opacity))
1309
+ }
1310
+
1311
+ .htw-border-black\/25{
1312
+ border-color:rgb(0 0 0 / 0.25)
1313
+ }
1314
+
1277
1315
  .htw-border-gray-200{
1278
1316
  --tw-border-opacity:1;
1279
1317
  border-color:rgb(var(--_histoire-color-gray-200) / var(--tw-border-opacity))
@@ -1296,16 +1334,6 @@ button {
1296
1334
  border-color:rgb(0 0 0 / 0.2)
1297
1335
  }
1298
1336
 
1299
- .htw-border-primary-500{
1300
- --tw-border-opacity:1;
1301
- border-color:rgb(var(--_histoire-color-primary-500) / var(--tw-border-opacity))
1302
- }
1303
-
1304
- .htw-border-gray-300{
1305
- --tw-border-opacity:1;
1306
- border-color:rgb(var(--_histoire-color-gray-300) / var(--tw-border-opacity))
1307
- }
1308
-
1309
1337
  .htw-bg-white{
1310
1338
  --tw-bg-opacity:1;
1311
1339
  background-color:rgb(255 255 255 / var(--tw-bg-opacity))
@@ -1437,6 +1465,11 @@ button {
1437
1465
  padding-bottom:0px
1438
1466
  }
1439
1467
 
1468
+ .htw-py-1{
1469
+ padding-top:0.25rem;
1470
+ padding-bottom:0.25rem
1471
+ }
1472
+
1440
1473
  .htw-pr-2{
1441
1474
  padding-right:0.5rem
1442
1475
  }
@@ -1461,6 +1494,10 @@ button {
1461
1494
  padding-left:1.25rem
1462
1495
  }
1463
1496
 
1497
+ .htw-pl-2{
1498
+ padding-left:0.5rem
1499
+ }
1500
+
1464
1501
  .htw-text-left{
1465
1502
  text-align:left
1466
1503
  }
@@ -1502,14 +1539,14 @@ button {
1502
1539
  color:rgb(var(--_histoire-color-gray-500) / var(--tw-text-opacity))
1503
1540
  }
1504
1541
 
1505
- .htw-text-gray-400{
1542
+ .htw-text-white{
1506
1543
  --tw-text-opacity:1;
1507
- color:rgb(var(--_histoire-color-gray-400) / var(--tw-text-opacity))
1544
+ color:rgb(255 255 255 / var(--tw-text-opacity))
1508
1545
  }
1509
1546
 
1510
- .htw-text-white{
1547
+ .htw-text-gray-400{
1511
1548
  --tw-text-opacity:1;
1512
- color:rgb(255 255 255 / var(--tw-text-opacity))
1549
+ color:rgb(var(--_histoire-color-gray-400) / var(--tw-text-opacity))
1513
1550
  }
1514
1551
 
1515
1552
  .htw-text-black\/\[2\%\]{
@@ -1573,20 +1610,6 @@ button {
1573
1610
  outline-offset:2px
1574
1611
  }
1575
1612
 
1576
- .htw-transition-colors{
1577
- transition-property:color, background-color, border-color, fill, stroke, -webkit-text-decoration-color;
1578
- transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;
1579
- transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, -webkit-text-decoration-color;
1580
- transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
1581
- transition-duration:150ms
1582
- }
1583
-
1584
- .htw-transition-transform{
1585
- transition-property:transform;
1586
- transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
1587
- transition-duration:150ms
1588
- }
1589
-
1590
1613
  .htw-transition-border{
1591
1614
  transition-property:border;
1592
1615
  transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
@@ -1603,6 +1626,20 @@ button {
1603
1626
  transition-property:none
1604
1627
  }
1605
1628
 
1629
+ .htw-transition-colors{
1630
+ transition-property:color, background-color, border-color, fill, stroke, -webkit-text-decoration-color;
1631
+ transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;
1632
+ transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, -webkit-text-decoration-color;
1633
+ transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
1634
+ transition-duration:150ms
1635
+ }
1636
+
1637
+ .htw-transition-transform{
1638
+ transition-property:transform;
1639
+ transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
1640
+ transition-duration:150ms
1641
+ }
1642
+
1606
1643
  .htw-delay-150{
1607
1644
  transition-delay:150ms
1608
1645
  }
@@ -1635,12 +1672,12 @@ body,
1635
1672
  font-family: 'Lato', sans-serif;
1636
1673
  }
1637
1674
 
1638
- #app {
1675
+ body {
1639
1676
  font-size: 18px;
1640
1677
  }
1641
1678
 
1642
1679
  @media (min-width: 640px) {
1643
- #app {
1680
+ body {
1644
1681
  font-size: 14px;
1645
1682
  }
1646
1683
  }
@@ -1657,14 +1694,14 @@ body,
1657
1694
  visibility: hidden;
1658
1695
  }
1659
1696
 
1660
- .hover\:htw-bg-primary-600:hover{
1697
+ .hover\:htw-bg-primary-100:hover{
1661
1698
  --tw-bg-opacity:1;
1662
- background-color:rgb(var(--_histoire-color-primary-600) / var(--tw-bg-opacity))
1699
+ background-color:rgb(var(--_histoire-color-primary-100) / var(--tw-bg-opacity))
1663
1700
  }
1664
1701
 
1665
- .hover\:htw-bg-primary-100:hover{
1702
+ .hover\:htw-bg-primary-600:hover{
1666
1703
  --tw-bg-opacity:1;
1667
- background-color:rgb(var(--_histoire-color-primary-100) / var(--tw-bg-opacity))
1704
+ background-color:rgb(var(--_histoire-color-primary-600) / var(--tw-bg-opacity))
1668
1705
  }
1669
1706
 
1670
1707
  .hover\:htw-bg-primary-500\/50:hover{
@@ -1747,6 +1784,10 @@ body,
1747
1784
  border-color:rgb(var(--_histoire-color-gray-800) / var(--tw-border-opacity))
1748
1785
  }
1749
1786
 
1787
+ .htw-dark .dark\:htw-border-white\/25{
1788
+ border-color:rgb(255 255 255 / 0.25)
1789
+ }
1790
+
1750
1791
  .htw-dark .dark\:htw-border-gray-850{
1751
1792
  --tw-border-opacity:1;
1752
1793
  border-color:rgb(var(--_histoire-color-gray-850) / var(--tw-border-opacity))
@@ -1770,11 +1811,6 @@ body,
1770
1811
  border-color:rgb(255 255 255 / 0.2)
1771
1812
  }
1772
1813
 
1773
- .htw-dark .dark\:htw-border-gray-500{
1774
- --tw-border-opacity:1;
1775
- border-color:rgb(var(--_histoire-color-gray-500) / var(--tw-border-opacity))
1776
- }
1777
-
1778
1814
  .htw-dark .dark\:htw-bg-gray-700{
1779
1815
  --tw-bg-opacity:1;
1780
1816
  background-color:rgb(var(--_histoire-color-gray-700) / var(--tw-bg-opacity))
@@ -1833,6 +1869,11 @@ body,
1833
1869
  color:rgb(var(--_histoire-color-primary-200) / var(--tw-text-opacity))
1834
1870
  }
1835
1871
 
1872
+ .htw-dark .dark\:hover\:htw-bg-primary-700:hover{
1873
+ --tw-bg-opacity:1;
1874
+ background-color:rgb(var(--_histoire-color-primary-700) / var(--tw-bg-opacity))
1875
+ }
1876
+
1836
1877
  .htw-dark .dark\:hover\:htw-bg-primary-900:hover{
1837
1878
  --tw-bg-opacity:1;
1838
1879
  background-color:rgb(var(--_histoire-color-primary-900) / var(--tw-bg-opacity))
@@ -1848,11 +1889,6 @@ body,
1848
1889
  background-color:rgb(var(--_histoire-color-gray-800) / var(--tw-bg-opacity))
1849
1890
  }
1850
1891
 
1851
- .htw-dark .dark\:hover\:htw-bg-primary-700:hover{
1852
- --tw-bg-opacity:1;
1853
- background-color:rgb(var(--_histoire-color-primary-700) / var(--tw-bg-opacity))
1854
- }
1855
-
1856
1892
  .htw-dark .dark\:hover\:htw-text-primary-400:hover{
1857
1893
  --tw-text-opacity:1;
1858
1894
  color:rgb(var(--_histoire-color-primary-400) / var(--tw-text-opacity))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -34,11 +34,13 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@iconify/vue": "^3.1.3",
37
- "@histoire/controls": "^0.1.5",
37
+ "@histoire/controls": "^0.2.0",
38
38
  "@vitejs/plugin-vue": "^2.2.0",
39
39
  "@vueuse/core": "^8.1.1",
40
+ "birpc": "^0.1.0",
40
41
  "case": "^1.6.3",
41
42
  "chokidar": "^3.5.3",
43
+ "connect": "^3.7.0",
42
44
  "defu": "^5.0.1",
43
45
  "diacritics": "^1.3.0",
44
46
  "floating-vue": "^2.0.0-beta.6",
@@ -56,7 +58,9 @@
56
58
  "sade": "^1.8.1",
57
59
  "scroll-into-view-if-needed": "^2.2.29",
58
60
  "shiki": "^0.10.1",
59
- "vite-node": "=0.6.1",
61
+ "sirv": "^2.0.2",
62
+ "tinypool": "^0.1.2",
63
+ "vite-node": "=0.7.6",
60
64
  "vue-router": "^4.0.12"
61
65
  },
62
66
  "peerDependencies": {
@@ -40,6 +40,7 @@ onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
40
40
  <a
41
41
  v-tooltip="makeTooltip('Search', ({ isMac }) => isMac ? 'meta+k' : 'ctrl+k')"
42
42
  class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
43
+ data-test-id="search-btn"
43
44
  @click="$emit('search')"
44
45
  >
45
46
  <Icon
@@ -0,0 +1,76 @@
1
+ <script lang="ts" setup>
2
+ import { computed, ref, watch } from 'vue'
3
+
4
+ const props = defineProps({
5
+ modelValue: {
6
+ type: Boolean,
7
+ default: false,
8
+ },
9
+ })
10
+
11
+ const emit = defineEmits({
12
+ 'update:modelValue': (newValue: boolean) => true,
13
+ })
14
+
15
+ function toggle () {
16
+ emit('update:modelValue', !props.modelValue)
17
+ animationEnabled.value = true
18
+ }
19
+
20
+ // SVG check
21
+
22
+ const path = ref<SVGPathElement>()
23
+ const dasharray = ref(0)
24
+ const progress = computed(() => props.modelValue ? 1 : 0)
25
+ const dashoffset = computed(() => (1 - progress.value) * dasharray.value)
26
+ const animationEnabled = ref(false)
27
+
28
+ watch(path, value => {
29
+ dasharray.value = path.value.getTotalLength?.() ?? 21.21
30
+ })
31
+ </script>
32
+
33
+ <template>
34
+ <div
35
+ role="checkbox"
36
+ tabindex="0"
37
+ class="htw-flex htw-items-center htw-gap-2 htw-select-none htw-px-4 htw-py-3 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700"
38
+ @click="toggle()"
39
+ @keydown.enter.prevent="toggle()"
40
+ @keydown.space.prevent="toggle()"
41
+ >
42
+ <div class="htw-text-white htw-w-[16px] htw-h-[16px] htw-relative">
43
+ <div
44
+ class="htw-border group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out"
45
+ :class="[
46
+ modelValue
47
+ ? 'htw-border-primary-500 htw-border-8'
48
+ : 'htw-border-black/25 dark:htw-border-white/25 htw-delay-150',
49
+ ]"
50
+ />
51
+ <svg
52
+ width="16"
53
+ height="16"
54
+ viewBox="0 0 24 24"
55
+ class="htw-relative htw-z-10"
56
+ >
57
+ <path
58
+ ref="path"
59
+ d="m 4 12 l 5 5 l 10 -10"
60
+ fill="none"
61
+ class="htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out"
62
+ :class="[
63
+ animationEnabled ? 'htw-transition-all' : 'htw-transition-none',
64
+ {
65
+ 'htw-delay-150': modelValue,
66
+ },
67
+ ]"
68
+ :stroke-dasharray="dasharray"
69
+ :stroke-dashoffset="dashoffset"
70
+ />
71
+ </svg>
72
+ </div>
73
+
74
+ <slot />
75
+ </div>
76
+ </template>
@@ -48,7 +48,10 @@ const kindLabels = {
48
48
  </script>
49
49
 
50
50
  <template>
51
- <div ref="el">
51
+ <div
52
+ ref="el"
53
+ data-test-id="search-item"
54
+ >
52
55
  <BaseListItemLink
53
56
  :to="result.route"
54
57
  :is-active="selected"
@@ -25,8 +25,7 @@ function close () {
25
25
  // Autofocus
26
26
 
27
27
  const input = ref<HTMLInputElement>()
28
- const { focused } = useFocus({
29
- target: input,
28
+ const { focused } = useFocus(input, {
30
29
  initialValue: true,
31
30
  })
32
31
 
@@ -132,6 +131,7 @@ function selectPrevious () {
132
131
  <div
133
132
  v-show="shown"
134
133
  class="htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-700/80 htw-z-20"
134
+ data-test-id="search-modal"
135
135
  >
136
136
  <div
137
137
  class="htw-absolute htw-inset-0"
@@ -152,8 +152,8 @@ function selectPrevious () {
152
152
  v-model="search"
153
153
  placeholder="Search for stories, variants..."
154
154
  class="htw-bg-transparent htw-w-full htw-flex-1 htw-pl-0 htw-pr-6 htw-py-4 htw-outline-none"
155
- @keydown.down="selectNext()"
156
- @keydown.up="selectPrevious()"
155
+ @keydown.down.prevent="selectNext()"
156
+ @keydown.up.prevent="selectPrevious()"
157
157
  @keydown.escape="close()"
158
158
  >
159
159
  </div>
@@ -18,7 +18,7 @@ defineProps({
18
18
  </script>
19
19
 
20
20
  <template>
21
- <div>
21
+ <div data-test-id="story-controls">
22
22
  <!-- Custom controls -->
23
23
  <SandboxVue3
24
24
  v-if="variant.slots().controls"
@@ -32,6 +32,7 @@ watchEffect(async () => {
32
32
  <div
33
33
  v-else
34
34
  class="htw-prose dark:htw-prose-invert htw-p-4 htw-max-w-none"
35
+ data-test-id="story-docs"
35
36
  v-html="renderedDoc"
36
37
  />
37
38
  </template>
@@ -30,7 +30,7 @@ const folderPadding = computed(() => {
30
30
  </script>
31
31
 
32
32
  <template>
33
- <div class="toast">
33
+ <div data-test-id="story-list-folder">
34
34
  <div
35
35
  role="button"
36
36
  tabindex="0"
@@ -24,7 +24,10 @@ useScrollOnActive(active, el)
24
24
  </script>
25
25
 
26
26
  <template>
27
- <div ref="el">
27
+ <div
28
+ ref="el"
29
+ data-test-id="story-list-item"
30
+ >
28
31
  <BaseListItemLink
29
32
  v-slot="{ active }"
30
33
  :to="{
@@ -255,6 +255,7 @@ const finalHeight = computed(() => props.settings.rotate ? props.settings.respon
255
255
  'htw-invisible': !isIframeLoaded,
256
256
  'htw-pointer-events-none': resizing,
257
257
  }"
258
+ data-test-id="preview-iframe"
258
259
  @load="onIframeLoad()"
259
260
  />
260
261
  </div>
@@ -29,6 +29,7 @@ const route = useRoute()
29
29
  save-id="story-sidepane"
30
30
  orientation="portrait"
31
31
  class="htw-h-full"
32
+ data-test-id="story-side-panel"
32
33
  >
33
34
  <template #first>
34
35
  <div class="htw-flex htw-flex-col htw-h-full">
@@ -67,7 +67,10 @@ const copySourceCode = () => copy(sourceCode.value)
67
67
  </script>
68
68
 
69
69
  <template>
70
- <div class="htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-relative">
70
+ <div
71
+ class="htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-relative"
72
+ data-test-id="story-source-code"
73
+ >
71
74
  <div
72
75
  v-if="error"
73
76
  class="htw-text-red-500 htw-h-full htw-p-2 htw-overflow-auto htw-font-mono htw-text-sm"
@@ -20,7 +20,10 @@ useScrollOnActive(isActive, el)
20
20
  </script>
21
21
 
22
22
  <template>
23
- <div ref="el">
23
+ <div
24
+ ref="el"
25
+ data-test-id="story-variant-list-item"
26
+ >
24
27
  <BaseListItemLink
25
28
  v-slot="{ active }"
26
29
  :to="targetRoute"
@@ -5,6 +5,7 @@ import type { Story, Variant } from '../../types'
5
5
  import { histoireConfig } from '../../util/config'
6
6
  import { usePreviewSettings } from '../../util/preview-settings'
7
7
  import StoryResponsivePreview from './StoryResponsivePreview.vue'
8
+ import BaseCheckbox from '../base/BaseCheckbox.vue'
8
9
  import { isMobile } from '../../util/responsive'
9
10
 
10
11
  defineProps({
@@ -23,7 +24,10 @@ const settings = usePreviewSettings()
23
24
  </script>
24
25
 
25
26
  <template>
26
- <div class="htw-h-full htw-flex htw-flex-col">
27
+ <div
28
+ class="htw-h-full htw-flex htw-flex-col"
29
+ data-test-id="story-variant-single-view"
30
+ >
27
31
  <!-- Toolbar -->
28
32
  <div
29
33
  v-if="!isMobile"
@@ -67,11 +71,9 @@ const settings = usePreviewSettings()
67
71
 
68
72
  <template #popper="{ hide }">
69
73
  <div class="htw-flex htw-flex-col htw-items-stretch">
70
- <HstCheckbox
71
- v-model="settings.rotate"
72
- >
74
+ <BaseCheckbox v-model="settings.rotate">
73
75
  Rotate
74
- </HstCheckbox>
76
+ </BaseCheckbox>
75
77
 
76
78
  <div class="htw-flex htw-gap-2 htw-px-4 htw-py-3">
77
79
  <input
@@ -137,11 +139,9 @@ const settings = usePreviewSettings()
137
139
 
138
140
  <template #popper="{ hide }">
139
141
  <div class="htw-flex htw-flex-col htw-items-stretch">
140
- <HstCheckbox
141
- v-model="settings.checkerboard"
142
- >
142
+ <BaseCheckbox v-model="settings.checkerboard">
143
143
  Checkerboard
144
- </HstCheckbox>
144
+ </BaseCheckbox>
145
145
 
146
146
  <button
147
147
  v-for="(option, index) in histoireConfig.backgroundPresets"
@@ -33,6 +33,24 @@ function closeMenu () {
33
33
  watch(variant, () => {
34
34
  isMenuOpened.value = false
35
35
  })
36
+
37
+ const templateWidth = computed(() => {
38
+ if (storyStore.currentStory.layout.type !== 'grid') {
39
+ return
40
+ }
41
+
42
+ const layoutWidth = storyStore.currentStory.layout.width
43
+
44
+ if (!layoutWidth) {
45
+ return '200px'
46
+ }
47
+
48
+ if (typeof layoutWidth === 'number') {
49
+ return layoutWidth + 'px'
50
+ }
51
+
52
+ return layoutWidth
53
+ })
36
54
  </script>
37
55
 
38
56
  <template>
@@ -44,7 +62,7 @@ watch(variant, () => {
44
62
  <div
45
63
  class="htw-grid htw-gap-4 htw-m-4"
46
64
  :style="{
47
- gridTemplateColumns: `repeat(auto-fill, ${storyStore.currentStory.layout.width ?? 200}px)`,
65
+ gridTemplateColumns: `repeat(auto-fill, ${templateWidth})`,
48
66
  }"
49
67
  >
50
68
  <StoryVariantGridItem
@@ -48,14 +48,14 @@ body,
48
48
  font-family: 'Lato', sans-serif;
49
49
  }
50
50
 
51
- #app {
52
- font-size: 18px;
51
+ body {
52
+ font-size: 18px;
53
53
  }
54
54
 
55
55
  @media (min-width: 640px) {
56
- #app {
57
- font-size: 14px;
58
- }
56
+ body {
57
+ font-size: 14px;
58
+ }
59
59
  }
60
60
 
61
61
  .__histoire-sandbox {
@@ -16,7 +16,7 @@ export interface Story {
16
16
  type: 'single'
17
17
  } | {
18
18
  type: 'grid'
19
- width: number
19
+ width?: number | string
20
20
  }
21
21
  icon?: string
22
22
  iconColor?: string
package/src/node/bin.ts CHANGED
@@ -25,4 +25,12 @@ program.command('build')
25
25
  return buildCommand()
26
26
  })
27
27
 
28
+ program.command('preview')
29
+ .describe('preview the built directory')
30
+ .option('-p, --port <port>', 'Listening port of the server')
31
+ .action(async (options) => {
32
+ const { previewCommand } = await import('./commands/preview.js')
33
+ return previewCommand(options)
34
+ })
35
+
28
36
  program.parse(process.argv)
package/src/node/build.ts CHANGED
@@ -9,7 +9,7 @@ import { Context } from './context.js'
9
9
  import { createVitePlugins } from './plugin.js'
10
10
  import { findAllStories } from './stories.js'
11
11
  import type { RollupOutput } from 'rollup'
12
- import { useCollectStories } from './collect.js'
12
+ import { useCollectStories } from './collect/index.js'
13
13
 
14
14
  const PRELOAD_MODULES = [
15
15
  'vendor',