histoire 0.2.4 → 0.3.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 (178) hide show
  1. package/dist/client/app/App.vue +9 -4
  2. package/dist/client/app/codegen/const.d.ts +1 -0
  3. package/dist/client/app/codegen/const.js +3 -0
  4. package/dist/client/app/codegen/vue3.js +82 -21
  5. package/dist/client/app/components/app/Breadcrumb.vue +1 -1
  6. package/dist/client/app/components/base/BaseEmpty.vue +17 -1
  7. package/dist/client/app/components/exposed/Story.vue +22 -1
  8. package/dist/client/app/components/exposed/Variant.vue +13 -1
  9. package/dist/client/app/components/sandbox/SandboxVue3.vue +6 -4
  10. package/dist/client/app/components/sandbox/lib.js +2 -1
  11. package/dist/client/app/components/search/SearchItem.vue +1 -0
  12. package/dist/client/app/components/search/SearchLoading.vue +16 -0
  13. package/dist/client/app/components/search/SearchModal.vue +12 -149
  14. package/dist/client/app/components/search/SearchPane.vue +210 -0
  15. package/dist/client/app/components/search/search-data.d.ts +2 -0
  16. package/dist/client/app/components/search/search-data.js +7 -0
  17. package/dist/client/app/components/story/StoryControls.vue +5 -0
  18. package/dist/client/app/components/story/StoryDocs.vue +18 -11
  19. package/dist/client/app/components/story/StoryEvent.vue +53 -0
  20. package/dist/client/app/components/story/StoryEvents.vue +45 -0
  21. package/dist/client/app/components/story/StoryResponsivePreview.vue +41 -8
  22. package/dist/client/app/components/story/StorySidePanel.vue +28 -3
  23. package/dist/client/app/components/story/StorySourceCode.vue +24 -14
  24. package/dist/client/app/components/story/StoryView.vue +16 -2
  25. package/dist/client/app/components/tree/StoryGroup.vue +75 -0
  26. package/dist/client/app/components/{story → tree}/StoryList.vue +8 -2
  27. package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListFolder.vue +10 -8
  28. package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListItem.vue +7 -4
  29. package/dist/client/app/router.d.ts +1 -0
  30. package/dist/client/app/router.js +3 -1
  31. package/dist/client/app/sandbox.js +11 -1
  32. package/dist/client/app/stores/events.d.ts +29 -0
  33. package/dist/client/app/stores/events.js +25 -0
  34. package/dist/client/app/stores/folder.d.ts +10 -0
  35. package/dist/client/app/stores/folder.js +47 -0
  36. package/dist/client/app/stores/story.d.ts +20 -8
  37. package/dist/client/app/stores/story.js +20 -28
  38. package/dist/client/app/style/floating-vue.pcss +3 -1
  39. package/dist/client/app/style/main.pcss +5 -0
  40. package/dist/client/app/style/sandbox.css +2 -0
  41. package/dist/client/app/types.d.ts +9 -1
  42. package/dist/client/app/util/const.d.ts +1 -0
  43. package/dist/client/app/util/const.js +1 -0
  44. package/dist/client/app/util/events.d.ts +1 -0
  45. package/dist/client/app/util/events.js +31 -0
  46. package/dist/client/app/util/mapping.js +2 -2
  47. package/dist/client/index.d.ts +4 -3
  48. package/dist/client/index.js +2 -1
  49. package/dist/client/server/index.d.ts +7 -2
  50. package/dist/client/server/index.js +8 -26
  51. package/{src/client/server/Story.server.vue → dist/client/server/vue3/Story.vue} +21 -4
  52. package/dist/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
  53. package/dist/client/server/vue3/run.d.ts +2 -0
  54. package/dist/client/server/vue3/run.js +32 -0
  55. package/dist/node/alias.d.ts +2 -1
  56. package/dist/node/alias.js +3 -2
  57. package/dist/node/build.js +74 -21
  58. package/dist/node/builtin-plugins/tailwind-tokens.d.ts +5 -0
  59. package/dist/node/builtin-plugins/tailwind-tokens.js +510 -0
  60. package/dist/node/collect/index.js +5 -3
  61. package/dist/node/collect/worker.js +6 -2
  62. package/dist/node/commands/preview.js +4 -25
  63. package/dist/node/config.d.ts +111 -5
  64. package/dist/node/config.js +40 -23
  65. package/dist/node/context.d.ts +3 -3
  66. package/dist/node/context.js +1 -1
  67. package/dist/node/index.d.ts +1 -0
  68. package/dist/node/index.js +1 -0
  69. package/dist/node/load.d.ts +12 -0
  70. package/dist/node/load.js +42 -0
  71. package/dist/node/plugin.d.ts +67 -11
  72. package/dist/node/plugin.js +42 -245
  73. package/dist/node/preview.d.ts +8 -0
  74. package/dist/node/preview.js +41 -0
  75. package/dist/node/search.d.ts +2 -0
  76. package/dist/node/search.js +68 -0
  77. package/dist/node/server.js +43 -21
  78. package/dist/node/stories.d.ts +2 -0
  79. package/dist/node/stories.js +9 -4
  80. package/dist/node/tree.d.ts +16 -12
  81. package/dist/node/tree.js +45 -5
  82. package/dist/node/types.d.ts +11 -0
  83. package/dist/node/util/find-up.d.ts +1 -0
  84. package/dist/node/util/find-up.js +20 -0
  85. package/dist/node/vite.d.ts +13 -0
  86. package/dist/node/vite.js +278 -0
  87. package/dist/style.css +174 -36
  88. package/package.json +7 -6
  89. package/scripts/copy.mjs +2 -1
  90. package/src/client/app/App.vue +9 -4
  91. package/src/client/app/codegen/const.ts +3 -0
  92. package/src/client/app/codegen/vue3.ts +80 -22
  93. package/src/client/app/components/app/Breadcrumb.vue +1 -1
  94. package/src/client/app/components/base/BaseEmpty.vue +17 -1
  95. package/src/client/app/components/exposed/Story.vue +22 -1
  96. package/src/client/app/components/exposed/Variant.vue +13 -1
  97. package/src/client/app/components/sandbox/SandboxVue3.vue +6 -4
  98. package/src/client/app/components/sandbox/lib.ts +3 -1
  99. package/src/client/app/components/search/SearchItem.vue +1 -0
  100. package/src/client/app/components/search/SearchLoading.vue +16 -0
  101. package/src/client/app/components/search/SearchModal.vue +12 -149
  102. package/src/client/app/components/search/SearchPane.vue +210 -0
  103. package/src/client/app/components/search/search-data.ts +9 -0
  104. package/src/client/app/components/story/StoryControls.vue +5 -0
  105. package/src/client/app/components/story/StoryDocs.vue +18 -11
  106. package/src/client/app/components/story/StoryEvent.vue +53 -0
  107. package/src/client/app/components/story/StoryEvents.vue +45 -0
  108. package/src/client/app/components/story/StoryResponsivePreview.vue +41 -8
  109. package/src/client/app/components/story/StorySidePanel.vue +28 -3
  110. package/src/client/app/components/story/StorySourceCode.vue +24 -14
  111. package/src/client/app/components/story/StoryView.vue +16 -2
  112. package/src/client/app/components/tree/StoryGroup.vue +75 -0
  113. package/src/client/app/components/{story → tree}/StoryList.vue +8 -2
  114. package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListFolder.vue +10 -8
  115. package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListItem.vue +7 -4
  116. package/src/client/app/router.ts +4 -1
  117. package/src/client/app/sandbox.ts +12 -2
  118. package/src/client/app/stores/events.ts +36 -0
  119. package/src/client/app/stores/folder.ts +59 -0
  120. package/src/client/app/stores/story.ts +20 -35
  121. package/src/client/app/style/floating-vue.pcss +3 -1
  122. package/src/client/app/style/main.pcss +5 -0
  123. package/src/client/app/style/sandbox.css +2 -0
  124. package/src/client/app/types.ts +10 -1
  125. package/src/client/app/util/const.ts +1 -0
  126. package/src/client/app/util/events.ts +30 -0
  127. package/src/client/app/util/mapping.ts +2 -2
  128. package/src/client/index.ts +4 -3
  129. package/src/client/server/index.ts +14 -27
  130. package/{dist/client/server/Story.server.vue → src/client/server/vue3/Story.vue} +21 -4
  131. package/src/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
  132. package/{dist/client/server/index.ts → src/client/server/vue3/run.ts} +10 -4
  133. package/src/node/alias.ts +4 -2
  134. package/src/node/build.ts +86 -21
  135. package/src/node/builtin-plugins/tailwind-tokens.ts +521 -0
  136. package/src/node/collect/index.ts +6 -4
  137. package/src/node/collect/worker.ts +7 -2
  138. package/src/node/commands/preview.ts +4 -33
  139. package/src/node/config.ts +62 -29
  140. package/src/node/context.ts +3 -3
  141. package/src/node/index.ts +1 -0
  142. package/src/node/load.ts +63 -0
  143. package/src/node/plugin.ts +75 -252
  144. package/src/node/preview.ts +56 -0
  145. package/src/node/search.ts +75 -0
  146. package/src/node/server.ts +49 -23
  147. package/src/node/stories.ts +9 -4
  148. package/src/node/tree.spec.ts +35 -17
  149. package/src/node/tree.ts +64 -10
  150. package/src/node/types.ts +12 -0
  151. package/src/node/util/find-up.ts +24 -0
  152. package/src/node/vite.ts +296 -0
  153. package/tailwind.config.cjs +1 -0
  154. package/dist/client/app/codegen/serialize-js.ts +0 -119
  155. package/dist/client/app/codegen/util.ts +0 -79
  156. package/dist/client/app/codegen/vue3.ts +0 -276
  157. package/dist/client/app/components/sandbox/lib.ts +0 -8
  158. package/dist/client/app/global-components.ts +0 -13
  159. package/dist/client/app/index.ts +0 -28
  160. package/dist/client/app/router.ts +0 -17
  161. package/dist/client/app/sandbox.ts +0 -94
  162. package/dist/client/app/stores/preview-settings.ts +0 -17
  163. package/dist/client/app/stores/story.ts +0 -62
  164. package/dist/client/app/types.ts +0 -70
  165. package/dist/client/app/util/config.ts +0 -6
  166. package/dist/client/app/util/const.ts +0 -3
  167. package/dist/client/app/util/dark.ts +0 -4
  168. package/dist/client/app/util/env.ts +0 -1
  169. package/dist/client/app/util/keyboard.ts +0 -99
  170. package/dist/client/app/util/mapping.ts +0 -48
  171. package/dist/client/app/util/preview-settings.ts +0 -8
  172. package/dist/client/app/util/reactivity.ts +0 -22
  173. package/dist/client/app/util/responsive.ts +0 -3
  174. package/dist/client/app/util/scroll.ts +0 -31
  175. package/dist/client/app/util/tooltip.ts +0 -13
  176. package/dist/client/app/util/variant.ts +0 -20
  177. package/dist/client/index.ts +0 -12
  178. package/dist/client/shim.d.ts +0 -5
package/dist/style.css CHANGED
@@ -204,6 +204,10 @@
204
204
  border-color:#000c
205
205
  }
206
206
 
207
+ .htw-bind-col-size{
208
+ grid-template-columns:repeat(auto-fill,minmax(var(--histoire-col-size),1fr))
209
+ }
210
+
207
211
  /* @TODO custom themes */
208
212
 
209
213
  .v-popper {
@@ -238,6 +242,10 @@
238
242
  transition: transform .15s cubic-bezier(0, 1, .5, 1);
239
243
  }
240
244
 
245
+ .v-popper__popper:focus-visible {
246
+ outline: none;
247
+ }
248
+
241
249
  .__histoire-scale-x-enter-active,
242
250
  .__histoire-scale-x-leave-active {
243
251
  transition: transform .15s, opacity .15s;
@@ -645,7 +653,7 @@ button {
645
653
  --tw-prose-invert-bold:#fff;
646
654
  --tw-prose-invert-counters:#9ca3af;
647
655
  --tw-prose-invert-bullets:rgb(var(--_histoire-color-gray-500));
648
- --tw-prose-invert-hr:#374151;
656
+ --tw-prose-invert-hr:rgb(var(--_histoire-color-gray-800));
649
657
  --tw-prose-invert-quotes:#f3f4f6;
650
658
  --tw-prose-invert-quote-borders:rgb(var(--_histoire-color-gray-800));
651
659
  --tw-prose-invert-captions:#9ca3af;
@@ -848,14 +856,6 @@ button {
848
856
  right:0.25rem
849
857
  }
850
858
 
851
- .htw-top-2{
852
- top:0.5rem
853
- }
854
-
855
- .htw-right-6{
856
- right:1.5rem
857
- }
858
-
859
859
  .htw-isolate{
860
860
  isolation:isolate
861
861
  }
@@ -868,10 +868,6 @@ button {
868
868
  z-index:20
869
869
  }
870
870
 
871
- .htw-m-1{
872
- margin:0.25rem
873
- }
874
-
875
871
  .htw-m-0{
876
872
  margin:0px
877
873
  }
@@ -880,11 +876,40 @@ button {
880
876
  margin:1rem
881
877
  }
882
878
 
879
+ .htw-m-1{
880
+ margin:0.25rem
881
+ }
882
+
883
+ .htw-mx-1{
884
+ margin-left:0.25rem;
885
+ margin-right:0.25rem
886
+ }
887
+
888
+ .htw-my-2{
889
+ margin-top:0.5rem;
890
+ margin-bottom:0.5rem
891
+ }
892
+
893
+ .htw-mx-2{
894
+ margin-left:0.5rem;
895
+ margin-right:0.5rem
896
+ }
897
+
883
898
  .htw-my-0{
884
899
  margin-top:0px;
885
900
  margin-bottom:0px
886
901
  }
887
902
 
903
+ .htw-my-8{
904
+ margin-top:2rem;
905
+ margin-bottom:2rem
906
+ }
907
+
908
+ .htw-mx-4{
909
+ margin-left:1rem;
910
+ margin-right:1rem
911
+ }
912
+
888
913
  .-htw-my-1{
889
914
  margin-top:-0.25rem;
890
915
  margin-bottom:-0.25rem
@@ -906,6 +931,10 @@ button {
906
931
  margin-top:0px
907
932
  }
908
933
 
934
+ .htw-mb-6{
935
+ margin-bottom:1.5rem
936
+ }
937
+
909
938
  .-htw-mt-1{
910
939
  margin-top:-0.25rem
911
940
  }
@@ -914,6 +943,10 @@ button {
914
943
  margin-right:auto
915
944
  }
916
945
 
946
+ .htw-mb-2{
947
+ margin-bottom:0.5rem
948
+ }
949
+
917
950
  .htw-box-border{
918
951
  box-sizing:border-box
919
952
  }
@@ -982,6 +1015,10 @@ button {
982
1015
  height:1rem
983
1016
  }
984
1017
 
1018
+ .htw-h-\[51px\]{
1019
+ height:51px
1020
+ }
1021
+
985
1022
  .htw-h-fit{
986
1023
  height:-webkit-fit-content;
987
1024
  height:-moz-fit-content;
@@ -1000,10 +1037,22 @@ button {
1000
1037
  height:2.5rem
1001
1038
  }
1002
1039
 
1040
+ .htw-h-\[1px\]{
1041
+ height:1px
1042
+ }
1043
+
1003
1044
  .htw-h-\[100px\]{
1004
1045
  height:100px
1005
1046
  }
1006
1047
 
1048
+ .htw-h-32{
1049
+ height:8rem
1050
+ }
1051
+
1052
+ .htw-h-20{
1053
+ height:5rem
1054
+ }
1055
+
1007
1056
  .htw-max-h-full{
1008
1057
  max-height:100%
1009
1058
  }
@@ -1068,6 +1117,10 @@ button {
1068
1117
  width:max-content
1069
1118
  }
1070
1119
 
1120
+ .htw-w-16{
1121
+ width:4rem
1122
+ }
1123
+
1071
1124
  .htw-w-20{
1072
1125
  width:5rem
1073
1126
  }
@@ -1076,18 +1129,22 @@ button {
1076
1129
  width:7rem
1077
1130
  }
1078
1131
 
1079
- .htw-w-16{
1080
- width:4rem
1132
+ .htw-w-32{
1133
+ width:8rem
1081
1134
  }
1082
1135
 
1083
- .htw-min-w-0{
1084
- min-width:0px
1136
+ .htw-min-w-4{
1137
+ min-width:1rem
1085
1138
  }
1086
1139
 
1087
1140
  .htw-min-w-16{
1088
1141
  min-width:4rem
1089
1142
  }
1090
1143
 
1144
+ .htw-min-w-0{
1145
+ min-width:0px
1146
+ }
1147
+
1091
1148
  .htw-max-w-full{
1092
1149
  max-width:100%
1093
1150
  }
@@ -1100,6 +1157,10 @@ button {
1100
1157
  max-width:none
1101
1158
  }
1102
1159
 
1160
+ .htw-max-w-\[400px\]{
1161
+ max-width:400px
1162
+ }
1163
+
1103
1164
  .htw-flex-none{
1104
1165
  flex:none
1105
1166
  }
@@ -1112,6 +1173,10 @@ button {
1112
1173
  flex-shrink:0
1113
1174
  }
1114
1175
 
1176
+ .htw-shrink{
1177
+ flex-shrink:1
1178
+ }
1179
+
1115
1180
  .htw-grow{
1116
1181
  flex-grow:1
1117
1182
  }
@@ -1160,8 +1225,8 @@ button {
1160
1225
  resize:vertical
1161
1226
  }
1162
1227
 
1163
- .htw-grid-cols-\[repeat\(auto-fill\,minmax\(100px\,1fr\)\)\]{
1164
- grid-template-columns:repeat(auto-fill,minmax(100px,1fr))
1228
+ .htw-grid-cols-\[repeat\(auto-fill\,minmax\(200px\,1fr\)\)\]{
1229
+ grid-template-columns:repeat(auto-fill,minmax(200px,1fr))
1165
1230
  }
1166
1231
 
1167
1232
  .htw-flex-col{
@@ -1184,6 +1249,10 @@ button {
1184
1249
  align-items:center
1185
1250
  }
1186
1251
 
1252
+ .htw-items-baseline{
1253
+ align-items:baseline
1254
+ }
1255
+
1187
1256
  .htw-items-stretch{
1188
1257
  align-items:stretch
1189
1258
  }
@@ -1276,14 +1345,14 @@ button {
1276
1345
  border-radius:0.75rem
1277
1346
  }
1278
1347
 
1279
- .htw-rounded{
1280
- border-radius:0.375rem
1281
- }
1282
-
1283
1348
  .htw-rounded-full{
1284
1349
  border-radius:9999px
1285
1350
  }
1286
1351
 
1352
+ .htw-rounded{
1353
+ border-radius:0.375rem
1354
+ }
1355
+
1287
1356
  .htw-rounded-b-lg{
1288
1357
  border-bottom-right-radius:0.75rem;
1289
1358
  border-bottom-left-radius:0.75rem
@@ -1402,6 +1471,11 @@ button {
1402
1471
  background-color:transparent
1403
1472
  }
1404
1473
 
1474
+ .htw-bg-primary-50{
1475
+ --tw-bg-opacity:1;
1476
+ background-color:rgb(var(--_histoire-color-primary-50) / var(--tw-bg-opacity))
1477
+ }
1478
+
1405
1479
  .htw-bg-gray-200{
1406
1480
  --tw-bg-opacity:1;
1407
1481
  background-color:rgb(var(--_histoire-color-gray-200) / var(--tw-bg-opacity))
@@ -1422,6 +1496,14 @@ button {
1422
1496
  background-color:rgb(var(--_histoire-color-gray-50) / var(--tw-bg-opacity))
1423
1497
  }
1424
1498
 
1499
+ .htw-bg-gray-500\/10{
1500
+ background-color:rgb(var(--_histoire-color-gray-500) / 0.1)
1501
+ }
1502
+
1503
+ .htw-bg-gray-500\/50{
1504
+ background-color:rgb(var(--_histoire-color-gray-500) / 0.5)
1505
+ }
1506
+
1425
1507
  .htw-stroke-white{
1426
1508
  stroke:#fff
1427
1509
  }
@@ -1442,10 +1524,6 @@ button {
1442
1524
  padding:0.25rem
1443
1525
  }
1444
1526
 
1445
- .htw-p-2\.5{
1446
- padding:0.625rem
1447
- }
1448
-
1449
1527
  .htw-px-1{
1450
1528
  padding-left:0.25rem;
1451
1529
  padding-right:0.25rem
@@ -1476,16 +1554,16 @@ button {
1476
1554
  padding-bottom:1rem
1477
1555
  }
1478
1556
 
1479
- .htw-px-0\.5{
1480
- padding-left:0.125rem;
1481
- padding-right:0.125rem
1482
- }
1483
-
1484
1557
  .htw-py-2{
1485
1558
  padding-top:0.5rem;
1486
1559
  padding-bottom:0.5rem
1487
1560
  }
1488
1561
 
1562
+ .htw-px-0\.5{
1563
+ padding-left:0.125rem;
1564
+ padding-right:0.125rem
1565
+ }
1566
+
1489
1567
  .htw-px-0{
1490
1568
  padding-left:0px;
1491
1569
  padding-right:0px
@@ -1531,8 +1609,8 @@ button {
1531
1609
  padding-left:0.125rem
1532
1610
  }
1533
1611
 
1534
- .htw-pl-5{
1535
- padding-left:1.25rem
1612
+ .htw-pl-4{
1613
+ padding-left:1rem
1536
1614
  }
1537
1615
 
1538
1616
  .htw-pl-2{
@@ -1571,6 +1649,10 @@ button {
1571
1649
  line-height:1
1572
1650
  }
1573
1651
 
1652
+ .htw-leading-normal{
1653
+ line-height:1.5
1654
+ }
1655
+
1574
1656
  .htw-text-white\/40{
1575
1657
  color:rgb(255 255 255 / 0.4)
1576
1658
  }
@@ -1749,6 +1831,18 @@ body {
1749
1831
  visibility: hidden;
1750
1832
  }
1751
1833
 
1834
+ .htw-prose hr {
1835
+ margin: 1rem 0;
1836
+ }
1837
+
1838
+ .first\:htw-mt-0:first-child{
1839
+ margin-top:0px
1840
+ }
1841
+
1842
+ .last\:htw-mb-0:last-child{
1843
+ margin-bottom:0px
1844
+ }
1845
+
1752
1846
  .hover\:htw-bg-primary-100:hover{
1753
1847
  --tw-bg-opacity:1;
1754
1848
  background-color:rgb(var(--_histoire-color-primary-100) / var(--tw-bg-opacity))
@@ -1801,8 +1895,13 @@ body {
1801
1895
  border-color:rgb(var(--_histoire-color-primary-500) / var(--tw-border-opacity))
1802
1896
  }
1803
1897
 
1804
- .htw-group:hover .group-hover\:htw-block{
1805
- display:block
1898
+ .htw-group:nth-child(odd) .group-odd\:htw-bg-gray-100\/50{
1899
+ background-color:rgb(var(--_histoire-color-gray-100) / 0.5)
1900
+ }
1901
+
1902
+ .htw-group:hover .group-hover\:htw-bg-primary-100{
1903
+ --tw-bg-opacity:1;
1904
+ background-color:rgb(var(--_histoire-color-primary-100) / var(--tw-bg-opacity))
1806
1905
  }
1807
1906
 
1808
1907
  .htw-group:hover .group-hover\:htw-opacity-90{
@@ -1896,6 +1995,11 @@ body {
1896
1995
  background-color:rgb(var(--_histoire-color-gray-700) / 0.8)
1897
1996
  }
1898
1997
 
1998
+ .htw-dark .dark\:htw-bg-primary-600{
1999
+ --tw-bg-opacity:1;
2000
+ background-color:rgb(var(--_histoire-color-primary-600) / var(--tw-bg-opacity))
2001
+ }
2002
+
1899
2003
  .htw-dark .dark\:htw-bg-gray-850{
1900
2004
  --tw-bg-opacity:1;
1901
2005
  background-color:rgb(var(--_histoire-color-gray-850) / var(--tw-bg-opacity))
@@ -1916,6 +2020,11 @@ body {
1916
2020
  background-color:rgb(var(--_histoire-color-gray-750) / var(--tw-bg-opacity))
1917
2021
  }
1918
2022
 
2023
+ .htw-dark .dark\:htw-bg-black{
2024
+ --tw-bg-opacity:1;
2025
+ background-color:rgb(0 0 0 / var(--tw-bg-opacity))
2026
+ }
2027
+
1919
2028
  .htw-dark .dark\:htw-text-gray-100{
1920
2029
  --tw-text-opacity:1;
1921
2030
  color:rgb(var(--_histoire-color-gray-100) / var(--tw-text-opacity))
@@ -1970,6 +2079,15 @@ body {
1970
2079
  border-color:rgb(var(--_histoire-color-primary-500) / var(--tw-border-opacity))
1971
2080
  }
1972
2081
 
2082
+ .htw-dark .htw-group:nth-child(odd) .dark\:group-odd\:htw-bg-gray-750\/40{
2083
+ background-color:rgb(var(--_histoire-color-gray-750) / 0.4)
2084
+ }
2085
+
2086
+ .htw-dark .htw-group:hover .dark\:group-hover\:htw-bg-primary-700{
2087
+ --tw-bg-opacity:1;
2088
+ background-color:rgb(var(--_histoire-color-primary-700) / var(--tw-bg-opacity))
2089
+ }
2090
+
1973
2091
  @media (min-width: 640px){
1974
2092
  .sm\:htw-h-4{
1975
2093
  height:1rem
@@ -1999,6 +2117,14 @@ body {
1999
2117
  margin-top:4rem
2000
2118
  }
2001
2119
 
2120
+ .md\:htw-max-w-\[600px\]{
2121
+ max-width:600px
2122
+ }
2123
+
2124
+ .md\:htw-p-12{
2125
+ padding:3rem
2126
+ }
2127
+
2002
2128
  .md\:htw-py-1\.5{
2003
2129
  padding-top:0.375rem;
2004
2130
  padding-bottom:0.375rem
@@ -2009,3 +2135,15 @@ body {
2009
2135
  padding-bottom:0.25rem
2010
2136
  }
2011
2137
  }
2138
+
2139
+ @media (min-width: 1024px){
2140
+ .lg\:htw-max-w-\[800px\]{
2141
+ max-width:800px
2142
+ }
2143
+ }
2144
+
2145
+ @media (min-width: 1280px){
2146
+ .xl\:htw-max-w-\[900px\]{
2147
+ max-width:900px
2148
+ }
2149
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.2.4",
3
+ "version": "0.3.1",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,7 +33,7 @@
33
33
  "histoire": "./bin.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@histoire/controls": "^0.2.4",
36
+ "@histoire/controls": "^0.3.1",
37
37
  "@iconify/vue": "^3.2.1",
38
38
  "@vitejs/plugin-vue": "^2.3.1",
39
39
  "@vueuse/core": "^8.2.5",
@@ -41,8 +41,9 @@
41
41
  "case": "^1.6.3",
42
42
  "chokidar": "^3.5.3",
43
43
  "connect": "^3.7.0",
44
- "defu": "^5.0.1",
44
+ "defu": "^6.0.0",
45
45
  "diacritics": "^1.3.0",
46
+ "flexsearch": "^0.7.21",
46
47
  "floating-vue": "^2.0.0-beta.14",
47
48
  "fs-extra": "^10.0.1",
48
49
  "globby": "^13.1.1",
@@ -70,6 +71,7 @@
70
71
  "devDependencies": {
71
72
  "@peeky/test": "^0.13.5",
72
73
  "@tailwindcss/typography": "^0.5.2",
74
+ "@types/flexsearch": "^0.7.3",
73
75
  "@types/fs-extra": "^9.0.13",
74
76
  "@types/markdown-it": "^12.2.3",
75
77
  "@types/node": "^17.0.23",
@@ -85,9 +87,8 @@
85
87
  "scripts": {
86
88
  "build": "rimraf dist && tsc -d && pnpm run build:css && node ./scripts/copy.mjs",
87
89
  "build:css": "tailwindcss -i src/client/app/style/main.pcss -o ./dist/style.css -c tailwind.config.cjs --postcss postcss.config.cjs",
88
- "watch": "concurrently \"tsc -d -w --sourceMap\" \"pnpm run build:css -- --watch\" \"node ./scripts/watchAndCopy.mjs\"",
90
+ "watch": "concurrently \"tsc -d -w --sourceMap\" \"pnpm run build:css --watch\" \"node ./scripts/watchAndCopy.mjs\"",
89
91
  "test:open": "peeky open",
90
92
  "test": "peeky run"
91
- },
92
- "readme": "# Histoire\n\n> Fast and beautiful interactive component playgrounds\n\n[Learn more](https://github.com/Akryum/histoire)\n\n```\npnpm add histoire -D\npnpm exec histoire dev\npnpm exec histoire build\n```\n"
93
+ }
93
94
  }
package/scripts/copy.mjs CHANGED
@@ -6,6 +6,7 @@ function toDist (file) {
6
6
  return normalizePath(file).replace(/^src\//, 'dist/')
7
7
  }
8
8
 
9
- globbySync('src/client/**/!(*.ts|tsconfig.json)').forEach((file) => {
9
+ globbySync('src/client/**/*').forEach((file) => {
10
+ if (file.endsWith('.ts') || file.endsWith('tsconfig.json')) return
10
11
  fs.copy(file, toDist(file))
11
12
  })
@@ -1,9 +1,15 @@
1
+ <script lang="ts">
2
+ export default {
3
+ name: 'HistoireApp',
4
+ }
5
+ </script>
6
+
1
7
  <script lang="ts" setup>
2
8
  // @ts-expect-error virtual module
3
9
  import { files as rawFiles, tree as rawTree, onUpdate } from '$histoire-stories'
4
- import StoryList from './components/story/StoryList.vue'
10
+ import StoryList from './components/tree/StoryList.vue'
5
11
  import BaseSplitPane from './components/base/BaseSplitPane.vue'
6
- import { computed, ref, watch, defineAsyncComponent } from 'vue'
12
+ import { computed, ref, watch } from 'vue'
7
13
  import AppHeader from './components/app/AppHeader.vue'
8
14
  import type { StoryFile, Tree } from './types'
9
15
  import { useStoryStore } from './stores/story'
@@ -13,8 +19,7 @@ import { histoireConfig } from './util/config.js'
13
19
  import { onKeyboardShortcut } from './util/keyboard.js'
14
20
  import { isMobile } from './util/responsive'
15
21
  import Breadcrumb from './components/app/Breadcrumb.vue'
16
-
17
- const SearchModal = defineAsyncComponent(() => import('./components/search/SearchModal.vue'))
22
+ import SearchModal from './components/search/SearchModal.vue'
18
23
 
19
24
  const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
20
25
  const tree = ref<Tree>(rawTree)
@@ -0,0 +1,3 @@
1
+ export const voidElements = [
2
+ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr',
3
+ ]
@@ -7,20 +7,24 @@ import { pascal } from 'case'
7
7
  import { createAutoBuildingObject, indent } from './util'
8
8
  import { serializeJs } from './serialize-js'
9
9
  import type { Variant } from '../types'
10
+ import { voidElements } from './const'
10
11
 
11
12
  export async function generateSourceCode (variant: Variant) {
12
- const vnode = variant.slots().default?.({ state: variant.state }) ?? []
13
+ const vnode = variant.slots().default?.({ state: variant.state ?? {} }) ?? []
13
14
  const list = Array.isArray(vnode) ? vnode : [vnode]
14
15
  const lines: string[] = []
15
16
  for (const vnode of list) {
16
- lines.push(...await printVNode(vnode))
17
+ lines.push(...(await printVNode(vnode)).lines)
17
18
  }
18
19
  return lines.join('\n')
19
20
  }
20
21
 
21
- async function printVNode (vnode: VNode): Promise<string[]> {
22
+ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: boolean }> {
22
23
  if (vnode.type === Text) {
23
- return [vnode.children.trim()]
24
+ return {
25
+ lines: [vnode.children],
26
+ isText: true,
27
+ }
24
28
  }
25
29
 
26
30
  const lines: string[] = []
@@ -49,6 +53,10 @@ async function printVNode (vnode: VNode): Promise<string[]> {
49
53
  if (dir.arg) {
50
54
  arg = `:${dir.arg}`
51
55
  }
56
+ if (valueCode) {
57
+ // Cleanup render code
58
+ valueCode = valueCode.replace(/^\$(setup|props|data)\./g, '')
59
+ }
52
60
  const valueLines = valueCode ? [valueCode] : serializeAndCleanJs(dir.value)
53
61
  const attr: string[] = []
54
62
  const dirAttr = `v-${dirName}${arg}${modifiers}="`
@@ -78,11 +86,12 @@ async function printVNode (vnode: VNode): Promise<string[]> {
78
86
  }
79
87
  }
80
88
  genDirective('model', dir, valueCode)
81
- } else {
89
+ } else if (dir.instance._ || dir.instance.$) {
90
+ const target = dir.instance.$ ?? dir.instance._
82
91
  let dirName: string
83
- for (const directives of [dir.instance._.directives, dir.instance._.appContext.directives]) {
92
+ for (const directives of [target.directives, target.appContext.directives]) {
84
93
  for (const key in directives) {
85
- if (dir.instance._.directives[key] === dir.dir) {
94
+ if (target.directives[key] === dir.dir) {
86
95
  dirName = key
87
96
  break
88
97
  }
@@ -139,9 +148,20 @@ async function printVNode (vnode: VNode): Promise<string[]> {
139
148
  let serialized: string[]
140
149
  if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
141
150
  // It was formatted from auto building object (slot props)
142
- serialized = [value.substring(2, value.length - 2).trim()]
151
+ serialized = cleanupExpression(value.substring(2, value.length - 2).trim()).split('\n')
143
152
  } else if (typeof value === 'function') {
144
- serialized = [value.toString()]
153
+ let code = cleanupExpression(value.toString().replace(/'/g, '\\\'').replace(/"/g, '\''))
154
+ const testResult = /function ([^\s]+)\(/.exec(code)
155
+ if (testResult) {
156
+ // Function name only
157
+ serialized = [testResult[1]]
158
+ } else {
159
+ if (code.startsWith('($event) => ')) {
160
+ // Remove unnecessary `($event) => `
161
+ code = code.substring('($event) => '.length)
162
+ }
163
+ serialized = code.split('\n')
164
+ }
145
165
  } else {
146
166
  serialized = serializeAndCleanJs(value)
147
167
  }
@@ -166,12 +186,38 @@ async function printVNode (vnode: VNode): Promise<string[]> {
166
186
  const tagName = getTagName(vnode)
167
187
 
168
188
  // Children
189
+ let isChildText = false
169
190
  const childLines: string[] = []
170
191
  if (typeof vnode.children === 'string') {
171
- childLines.push(vnode.children)
192
+ if (tagName === 'pre') {
193
+ childLines.push(vnode.children)
194
+ } else {
195
+ childLines.push(...vnode.children.split('\n'))
196
+ }
197
+ isChildText = true
172
198
  } else if (Array.isArray(vnode.children)) {
199
+ let isAllChildText
173
200
  for (const child of vnode.children) {
174
- childLines.push(...await printVNode(child))
201
+ const result = await printVNode(child)
202
+ if (result.isText) {
203
+ if (isAllChildText === undefined) {
204
+ isAllChildText = true
205
+ }
206
+ const text = result.lines[0]
207
+ if (!childLines.length || /^\s/.test(text)) {
208
+ childLines.push(text.trim())
209
+ } else {
210
+ childLines[childLines.length - 1] += text
211
+ }
212
+ } else {
213
+ if (isAllChildText === undefined) {
214
+ isAllChildText = false
215
+ }
216
+ childLines.push(...result.lines)
217
+ }
218
+ }
219
+ if (isAllChildText !== undefined) {
220
+ isChildText = isAllChildText
175
221
  }
176
222
  }
177
223
 
@@ -188,7 +234,7 @@ async function printVNode (vnode: VNode): Promise<string[]> {
188
234
  const children = vnode.children[key](autoObject.proxy)
189
235
  const slotLines: string[] = []
190
236
  for (const child of children) {
191
- slotLines.push(...await printVNode(child))
237
+ slotLines.push(...(await printVNode(child)).lines)
192
238
  }
193
239
  const slotProps = Object.keys(autoObject.cache)
194
240
  if (slotProps.length) {
@@ -224,23 +270,31 @@ async function printVNode (vnode: VNode): Promise<string[]> {
224
270
  }
225
271
  }
226
272
 
273
+ const isVoid = voidElements.includes(tagName.toLowerCase())
274
+
227
275
  if (childLines.length > 0) {
228
- lines.push(...tag)
229
- lines.push(...indent(childLines))
230
- lines.push(`</${tagName}>`)
276
+ if (childLines.length === 1 && tag.length === 1 && !attrs.length && isChildText) {
277
+ lines.push(`${tag[0]}${childLines[0]}</${tagName}>`)
278
+ } else {
279
+ lines.push(...tag)
280
+ lines.push(...indent(childLines))
281
+ lines.push(`</${tagName}>`)
282
+ }
231
283
  } else if (tag.length > 1) {
232
284
  lines.push(...tag)
233
- lines.push('/>')
285
+ lines.push(isVoid ? '>' : '/>')
234
286
  } else {
235
- lines.push(`${tag[0]} />`)
287
+ lines.push(`${tag[0]}${isVoid ? '' : ' /'}>`)
236
288
  }
237
289
  } else if (vnode?.shapeFlag & 1 << 4) {
238
290
  for (const child of vnode.children) {
239
- lines.push(...await printVNode(child))
291
+ lines.push(...(await printVNode(child)).lines)
240
292
  }
241
293
  }
242
294
 
243
- return lines
295
+ return {
296
+ lines,
297
+ }
244
298
  }
245
299
 
246
300
  function getTagName (vnode: VNode) {
@@ -258,7 +312,7 @@ function getTagName (vnode: VNode) {
258
312
  }
259
313
 
260
314
  function getNameFromFile (file: string) {
261
- const parts = /\/([^/]+)\.vue$/.exec(file)
315
+ const parts = /([^/]+)\.vue$/.exec(file)
262
316
  if (parts) {
263
317
  return pascal(parts[1])
264
318
  }
@@ -269,8 +323,12 @@ function serializeAndCleanJs (value: any) {
269
323
  const isAutoBuildingObject = !!value?.__autoBuildingObject
270
324
  const result = serializeJs(value)
271
325
  if (isAutoBuildingObject) {
272
- return [result.__autoBuildingObjectGetKey]
326
+ return [cleanupExpression(result.__autoBuildingObjectGetKey)]
273
327
  } else {
274
- return result.replace(/\$setup\./g, '').split('\n')
328
+ return cleanupExpression(result).split('\n')
275
329
  }
276
330
  }
331
+
332
+ function cleanupExpression (expr: string) {
333
+ return expr.replace(/\$setup\./g, '')
334
+ }