histoire 0.1.4 → 0.2.1

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 (73) hide show
  1. package/dist/client/app/App.vue +1 -1
  2. package/dist/client/app/components/app/AppHeader.vue +1 -0
  3. package/dist/client/app/components/base/BaseCheckbox.vue +76 -0
  4. package/dist/client/app/components/sandbox/lib.d.ts +2 -0
  5. package/dist/client/app/components/sandbox/lib.js +6 -0
  6. package/dist/client/app/components/sandbox/lib.ts +8 -0
  7. package/dist/client/app/components/search/SearchItem.vue +4 -1
  8. package/dist/client/app/components/search/SearchModal.vue +4 -4
  9. package/dist/client/app/components/story/StoryControls.vue +1 -1
  10. package/dist/client/app/components/story/StoryDocs.vue +1 -0
  11. package/dist/client/app/components/story/StoryListFolder.vue +1 -1
  12. package/dist/client/app/components/story/StoryListItem.vue +4 -1
  13. package/dist/client/app/components/story/StoryResponsivePreview.vue +3 -4
  14. package/dist/client/app/components/story/StorySidePanel.vue +1 -0
  15. package/dist/client/app/components/story/StorySourceCode.vue +4 -1
  16. package/dist/client/app/components/story/StoryVariantListItem.vue +4 -1
  17. package/dist/client/app/components/story/StoryVariantSingleView.vue +20 -160
  18. package/dist/client/app/components/story/StoryViewer.vue +19 -1
  19. package/dist/client/app/components/story/variant/StoryVariantBackground.vue +67 -0
  20. package/dist/client/app/components/story/variant/StoryVariantNewTab.vue +29 -0
  21. package/dist/client/app/components/story/variant/StoryVariantResponsiveSize.vue +82 -0
  22. package/dist/client/app/components/story/variant/StoryVariantTitle.vue +21 -0
  23. package/dist/client/app/stores/story.d.ts +6 -6
  24. package/dist/client/app/stores/story.js +2 -1
  25. package/dist/client/app/stores/story.ts +5 -1
  26. package/dist/client/app/style/main.pcss +5 -5
  27. package/dist/client/app/types.d.ts +1 -1
  28. package/dist/client/app/types.ts +1 -1
  29. package/dist/node/bin.js +7 -0
  30. package/dist/node/build.js +1 -1
  31. package/dist/node/{collect.d.ts → collect/index.d.ts} +2 -2
  32. package/dist/node/{collect.js → collect/index.js} +37 -27
  33. package/dist/node/collect/worker.d.ts +14 -0
  34. package/dist/node/collect/worker.js +36 -0
  35. package/dist/node/commands/preview.d.ts +4 -0
  36. package/dist/node/commands/preview.js +36 -0
  37. package/dist/node/server.js +1 -1
  38. package/dist/node/tree.js +24 -4
  39. package/dist/node/types.d.ts +1 -1
  40. package/dist/style.css +97 -53
  41. package/package.json +7 -3
  42. package/src/client/app/App.vue +1 -1
  43. package/src/client/app/components/app/AppHeader.vue +1 -0
  44. package/src/client/app/components/base/BaseCheckbox.vue +76 -0
  45. package/src/client/app/components/sandbox/lib.ts +8 -0
  46. package/src/client/app/components/search/SearchItem.vue +4 -1
  47. package/src/client/app/components/search/SearchModal.vue +4 -4
  48. package/src/client/app/components/story/StoryControls.vue +1 -1
  49. package/src/client/app/components/story/StoryDocs.vue +1 -0
  50. package/src/client/app/components/story/StoryListFolder.vue +1 -1
  51. package/src/client/app/components/story/StoryListItem.vue +4 -1
  52. package/src/client/app/components/story/StoryResponsivePreview.vue +3 -4
  53. package/src/client/app/components/story/StorySidePanel.vue +1 -0
  54. package/src/client/app/components/story/StorySourceCode.vue +4 -1
  55. package/src/client/app/components/story/StoryVariantListItem.vue +4 -1
  56. package/src/client/app/components/story/StoryVariantSingleView.vue +20 -160
  57. package/src/client/app/components/story/StoryViewer.vue +19 -1
  58. package/src/client/app/components/story/variant/StoryVariantBackground.vue +67 -0
  59. package/src/client/app/components/story/variant/StoryVariantNewTab.vue +29 -0
  60. package/src/client/app/components/story/variant/StoryVariantResponsiveSize.vue +82 -0
  61. package/src/client/app/components/story/variant/StoryVariantTitle.vue +21 -0
  62. package/src/client/app/stores/story.ts +5 -1
  63. package/src/client/app/style/main.pcss +5 -5
  64. package/src/client/app/types.ts +1 -1
  65. package/src/node/bin.ts +8 -0
  66. package/src/node/build.ts +1 -1
  67. package/src/node/{collect.ts → collect/index.ts} +48 -30
  68. package/src/node/collect/worker.ts +61 -0
  69. package/src/node/commands/preview.ts +50 -0
  70. package/src/node/server.ts +1 -1
  71. package/src/node/tree.spec.ts +61 -0
  72. package/src/node/tree.ts +29 -5
  73. 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))
@@ -1292,18 +1330,17 @@ button {
1292
1330
  border-color:rgb(var(--_histoire-color-primary-200) / var(--tw-border-opacity))
1293
1331
  }
1294
1332
 
1295
- .htw-border-black\/20{
1296
- border-color:rgb(0 0 0 / 0.2)
1333
+ .htw-border-black\/50{
1334
+ border-color:rgb(0 0 0 / 0.5)
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))
1337
+ .htw-border-black\/20{
1338
+ border-color:rgb(0 0 0 / 0.2)
1302
1339
  }
1303
1340
 
1304
- .htw-border-gray-300{
1305
- --tw-border-opacity:1;
1306
- border-color:rgb(var(--_histoire-color-gray-300) / var(--tw-border-opacity))
1341
+ .htw-bg-white{
1342
+ --tw-bg-opacity:1;
1343
+ background-color:rgb(255 255 255 / var(--tw-bg-opacity))
1307
1344
  }
1308
1345
 
1309
1346
  .htw-bg-gray-500{
@@ -1311,11 +1348,6 @@ button {
1311
1348
  background-color:rgb(var(--_histoire-color-gray-500) / var(--tw-bg-opacity))
1312
1349
  }
1313
1350
 
1314
- .htw-bg-white{
1315
- --tw-bg-opacity:1;
1316
- background-color:rgb(255 255 255 / var(--tw-bg-opacity))
1317
- }
1318
-
1319
1351
  .htw-bg-primary-500{
1320
1352
  --tw-bg-opacity:1;
1321
1353
  background-color:rgb(var(--_histoire-color-primary-500) / var(--tw-bg-opacity))
@@ -1437,6 +1469,11 @@ button {
1437
1469
  padding-bottom:0px
1438
1470
  }
1439
1471
 
1472
+ .htw-py-1{
1473
+ padding-top:0.25rem;
1474
+ padding-bottom:0.25rem
1475
+ }
1476
+
1440
1477
  .htw-pr-2{
1441
1478
  padding-right:0.5rem
1442
1479
  }
@@ -1461,6 +1498,10 @@ button {
1461
1498
  padding-left:1.25rem
1462
1499
  }
1463
1500
 
1501
+ .htw-pl-2{
1502
+ padding-left:0.5rem
1503
+ }
1504
+
1464
1505
  .htw-text-left{
1465
1506
  text-align:left
1466
1507
  }
@@ -1502,14 +1543,14 @@ button {
1502
1543
  color:rgb(var(--_histoire-color-gray-500) / var(--tw-text-opacity))
1503
1544
  }
1504
1545
 
1505
- .htw-text-gray-400{
1546
+ .htw-text-white{
1506
1547
  --tw-text-opacity:1;
1507
- color:rgb(var(--_histoire-color-gray-400) / var(--tw-text-opacity))
1548
+ color:rgb(255 255 255 / var(--tw-text-opacity))
1508
1549
  }
1509
1550
 
1510
- .htw-text-white{
1551
+ .htw-text-gray-400{
1511
1552
  --tw-text-opacity:1;
1512
- color:rgb(255 255 255 / var(--tw-text-opacity))
1553
+ color:rgb(var(--_histoire-color-gray-400) / var(--tw-text-opacity))
1513
1554
  }
1514
1555
 
1515
1556
  .htw-text-black\/\[2\%\]{
@@ -1573,20 +1614,6 @@ button {
1573
1614
  outline-offset:2px
1574
1615
  }
1575
1616
 
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
1617
  .htw-transition-border{
1591
1618
  transition-property:border;
1592
1619
  transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
@@ -1603,6 +1630,20 @@ button {
1603
1630
  transition-property:none
1604
1631
  }
1605
1632
 
1633
+ .htw-transition-colors{
1634
+ transition-property:color, background-color, border-color, fill, stroke, -webkit-text-decoration-color;
1635
+ transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;
1636
+ transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, -webkit-text-decoration-color;
1637
+ transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
1638
+ transition-duration:150ms
1639
+ }
1640
+
1641
+ .htw-transition-transform{
1642
+ transition-property:transform;
1643
+ transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
1644
+ transition-duration:150ms
1645
+ }
1646
+
1606
1647
  .htw-delay-150{
1607
1648
  transition-delay:150ms
1608
1649
  }
@@ -1635,12 +1676,12 @@ body,
1635
1676
  font-family: 'Lato', sans-serif;
1636
1677
  }
1637
1678
 
1638
- #app {
1679
+ body {
1639
1680
  font-size: 18px;
1640
1681
  }
1641
1682
 
1642
1683
  @media (min-width: 640px) {
1643
- #app {
1684
+ body {
1644
1685
  font-size: 14px;
1645
1686
  }
1646
1687
  }
@@ -1657,14 +1698,14 @@ body,
1657
1698
  visibility: hidden;
1658
1699
  }
1659
1700
 
1660
- .hover\:htw-bg-primary-600:hover{
1701
+ .hover\:htw-bg-primary-100:hover{
1661
1702
  --tw-bg-opacity:1;
1662
- background-color:rgb(var(--_histoire-color-primary-600) / var(--tw-bg-opacity))
1703
+ background-color:rgb(var(--_histoire-color-primary-100) / var(--tw-bg-opacity))
1663
1704
  }
1664
1705
 
1665
- .hover\:htw-bg-primary-100:hover{
1706
+ .hover\:htw-bg-primary-600:hover{
1666
1707
  --tw-bg-opacity:1;
1667
- background-color:rgb(var(--_histoire-color-primary-100) / var(--tw-bg-opacity))
1708
+ background-color:rgb(var(--_histoire-color-primary-600) / var(--tw-bg-opacity))
1668
1709
  }
1669
1710
 
1670
1711
  .hover\:htw-bg-primary-500\/50:hover{
@@ -1747,6 +1788,10 @@ body,
1747
1788
  border-color:rgb(var(--_histoire-color-gray-800) / var(--tw-border-opacity))
1748
1789
  }
1749
1790
 
1791
+ .htw-dark .dark\:htw-border-white\/25{
1792
+ border-color:rgb(255 255 255 / 0.25)
1793
+ }
1794
+
1750
1795
  .htw-dark .dark\:htw-border-gray-850{
1751
1796
  --tw-border-opacity:1;
1752
1797
  border-color:rgb(var(--_histoire-color-gray-850) / var(--tw-border-opacity))
@@ -1766,13 +1811,12 @@ body,
1766
1811
  border-color:rgb(var(--_histoire-color-primary-900) / var(--tw-border-opacity))
1767
1812
  }
1768
1813
 
1769
- .htw-dark .dark\:htw-border-white\/20{
1770
- border-color:rgb(255 255 255 / 0.2)
1814
+ .htw-dark .dark\:htw-border-white\/50{
1815
+ border-color:rgb(255 255 255 / 0.5)
1771
1816
  }
1772
1817
 
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))
1818
+ .htw-dark .dark\:htw-border-white\/20{
1819
+ border-color:rgb(255 255 255 / 0.2)
1776
1820
  }
1777
1821
 
1778
1822
  .htw-dark .dark\:htw-bg-gray-700{
@@ -1833,6 +1877,11 @@ body,
1833
1877
  color:rgb(var(--_histoire-color-primary-200) / var(--tw-text-opacity))
1834
1878
  }
1835
1879
 
1880
+ .htw-dark .dark\:hover\:htw-bg-primary-700:hover{
1881
+ --tw-bg-opacity:1;
1882
+ background-color:rgb(var(--_histoire-color-primary-700) / var(--tw-bg-opacity))
1883
+ }
1884
+
1836
1885
  .htw-dark .dark\:hover\:htw-bg-primary-900:hover{
1837
1886
  --tw-bg-opacity:1;
1838
1887
  background-color:rgb(var(--_histoire-color-primary-900) / var(--tw-bg-opacity))
@@ -1848,11 +1897,6 @@ body,
1848
1897
  background-color:rgb(var(--_histoire-color-gray-800) / var(--tw-bg-opacity))
1849
1898
  }
1850
1899
 
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
1900
  .htw-dark .dark\:hover\:htw-text-primary-400:hover{
1857
1901
  --tw-text-opacity:1;
1858
1902
  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.4",
3
+ "version": "0.2.1",
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.4",
37
+ "@histoire/controls": "^0.2.1",
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": {
@@ -80,7 +80,7 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
80
80
  />
81
81
  </div>
82
82
 
83
- <div class="htw-h-screen dark:htw-bg-gray-700 dark:htw-text-gray-100">
83
+ <div class="htw-h-screen htw-bg-white dark:htw-bg-gray-700 dark:htw-text-gray-100">
84
84
  <div
85
85
  v-if="isMobile"
86
86
  class="htw-h-full htw-flex htw-flex-col htw-divide-y htw-divide-gray-100 dark:htw-divide-gray-800"
@@ -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>
@@ -0,0 +1,8 @@
1
+ import { Story, Variant } from '../../types'
2
+
3
+ export function getSandboxUrl (story: Story, variant: Variant) {
4
+ const url = new URLSearchParams()
5
+ url.append('storyId', story.id)
6
+ url.append('variantId', variant.id)
7
+ return '/__sandbox?' + url.toString()
8
+ }
@@ -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="{
@@ -9,6 +9,7 @@ import HatchedPattern from '../misc/HatchedPattern.vue'
9
9
  import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
10
10
  import { toRawDeep } from '../../util/reactivity'
11
11
  import { Settings } from 'http2'
12
+ import { getSandboxUrl } from '../sandbox/lib'
12
13
 
13
14
  const props = defineProps<{
14
15
  story: Story
@@ -61,10 +62,7 @@ useEventListener(window, 'message', (event) => {
61
62
  })
62
63
 
63
64
  const sandboxUrl = computed(() => {
64
- const url = new URLSearchParams()
65
- url.append('storyId', props.story.id)
66
- url.append('variantId', props.variant.id)
67
- return '/__sandbox?' + url.toString()
65
+ return getSandboxUrl(props.story, props.variant)
68
66
  })
69
67
 
70
68
  const isIframeLoaded = ref(false)
@@ -255,6 +253,7 @@ const finalHeight = computed(() => props.settings.rotate ? props.settings.respon
255
253
  'htw-invisible': !isIframeLoaded,
256
254
  'htw-pointer-events-none': resizing,
257
255
  }"
256
+ data-test-id="preview-iframe"
258
257
  @load="onIframeLoad()"
259
258
  />
260
259
  </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"