@histoire/app 0.11.6 → 0.11.7

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.
@@ -64,7 +64,7 @@ button {
64
64
  }
65
65
  }
66
66
 
67
- .__histoire-sandbox {
67
+ .htw-sandbox-contain {
68
68
  contain: content;
69
69
  }
70
70
 
@@ -17,3 +17,7 @@ html {
17
17
  .htw-sandbox-hidden {
18
18
  display: none;
19
19
  }
20
+
21
+ .htw-sandbox-contain {
22
+ contain: content;
23
+ }
@@ -23,7 +23,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
23
23
  return (_ctx, _cache) => {
24
24
  return mountComponent.value ? (openBlock(), createBlock(resolveDynamicComponent(mountComponent.value), mergeProps({
25
25
  key: 0,
26
- class: "histoire-generic-render-story",
26
+ class: "histoire-generic-render-story htw-sandbox-contain",
27
27
  story: __props.story
28
28
  }, _ctx.$attrs), null, 16, ["story"])) : createCommentVNode("", true);
29
29
  };
@@ -11,6 +11,7 @@ const _hoisted_2 = {
11
11
  key: 0,
12
12
  class: "htw-flex-none htw-flex htw-items-center htw-justify-end htw-h-8 htw-mx-2 htw-mt-1"
13
13
  };
14
+ const _hoisted_3 = { class: "htw-overflow-y-auto htw-flex htw-flex-1" };
14
15
  const _sfc_main = /* @__PURE__ */ defineComponent({
15
16
  __name: "StoryVariantGrid",
16
17
  setup(__props) {
@@ -67,6 +68,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
67
68
  }
68
69
  }
69
70
  watch(() => storyStore.currentVariant, () => {
71
+ maxItemHeight.value = 0;
70
72
  updateMaxCount();
71
73
  });
72
74
  const gridEl = ref(null);
@@ -78,10 +80,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
78
80
  viewWidth.value = el.value.clientWidth;
79
81
  if (!gridEl.value)
80
82
  return;
81
- const firstCellEl = gridEl.value.children[0];
82
- if (!firstCellEl)
83
- return;
84
- gridColumnWidth.value = firstCellEl.clientWidth;
83
+ if (gridTemplateWidth.value.endsWith("%")) {
84
+ gridColumnWidth.value = viewWidth.value * parseInt(gridTemplateWidth.value) / 100 - gap;
85
+ } else {
86
+ gridColumnWidth.value = parseInt(gridTemplateWidth.value);
87
+ }
85
88
  }
86
89
  onMounted(() => {
87
90
  updateSize();
@@ -96,37 +99,39 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
96
99
  createVNode(ToolbarBackground),
97
100
  createVNode(_sfc_main$1)
98
101
  ])) : createCommentVNode("", true),
99
- createElementVNode("div", {
100
- ref_key: "el",
101
- ref: el,
102
- class: "htw-overflow-y-auto htw-flex htw-flex-1",
103
- onScroll: _cache[0] || (_cache[0] = ($event) => updateMaxCount())
104
- }, [
102
+ createElementVNode("div", _hoisted_3, [
105
103
  createElementVNode("div", {
106
- class: "htw-m-auto",
107
- style: normalizeStyle({
108
- minHeight: `${unref(storyStore).currentStory.variants.length / countPerRow.value * (maxItemHeight.value + gap) - gap}px`
109
- })
104
+ ref_key: "el",
105
+ ref: el,
106
+ class: "htw-flex htw-w-0 htw-flex-1 htw-mx-4",
107
+ onScroll: _cache[0] || (_cache[0] = ($event) => updateMaxCount())
110
108
  }, [
111
109
  createElementVNode("div", {
112
- ref_key: "gridEl",
113
- ref: gridEl,
114
- class: "htw-grid htw-gap-4 htw-m-4",
110
+ class: "htw-m-auto",
115
111
  style: normalizeStyle({
116
- gridTemplateColumns: `repeat(${unref(columnCount)}, ${unref(gridTemplateWidth)})`
112
+ minHeight: `${unref(storyStore).currentStory.variants.length / countPerRow.value * (maxItemHeight.value + gap) - gap}px`
117
113
  })
118
114
  }, [
119
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory.variants.slice(0, maxCount.value), (variant, index) => {
120
- return openBlock(), createBlock(StoryVariantGridItem, {
121
- key: index,
122
- variant,
123
- story: unref(storyStore).currentStory,
124
- onResize: onItemResize
125
- }, null, 8, ["variant", "story"]);
126
- }), 128))
115
+ createElementVNode("div", {
116
+ ref_key: "gridEl",
117
+ ref: gridEl,
118
+ class: "htw-grid htw-gap-4 htw-my-4",
119
+ style: normalizeStyle({
120
+ gridTemplateColumns: `repeat(${unref(columnCount)}, ${gridColumnWidth.value}px)`
121
+ })
122
+ }, [
123
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory.variants.slice(0, maxCount.value), (variant, index) => {
124
+ return openBlock(), createBlock(StoryVariantGridItem, {
125
+ key: index,
126
+ variant,
127
+ story: unref(storyStore).currentStory,
128
+ onResize: onItemResize
129
+ }, null, 8, ["variant", "story"]);
130
+ }), 128))
131
+ ], 4)
127
132
  ], 4)
128
- ], 4)
129
- ], 544)
133
+ ], 544)
134
+ ])
130
135
  ]);
131
136
  };
132
137
  }
@@ -55,22 +55,21 @@
55
55
  color: var(--ae892164);
56
56
  }
57
57
 
58
- .__histoire-code-placeholder[data-v-36810e45] {
59
- color: inherit;
60
- font-size: inherit;
58
+ .bind-icon-color[data-v-ddfc5b4f] {
59
+ color: var(--4d25d048);
61
60
  }
62
61
 
63
62
  .bind-icon-color[data-v-ab890d9c] {
64
63
  color: var(--89126aaa);
65
64
  }
66
65
 
67
- .bind-icon-color[data-v-ddfc5b4f] {
68
- color: var(--4d25d048);
66
+ .__histoire-code-placeholder[data-v-36810e45] {
67
+ color: inherit;
68
+ font-size: inherit;
69
69
  }
70
70
 
71
- .bind-preview-bg[data-v-c48fb2b2] {
72
- background-color: var(--627bec82);
73
- color: var(--35068428);
71
+ .bind-icon-color[data-v-d95fcb03] {
72
+ color: var(--beebbd52);
74
73
  }
75
74
 
76
75
  .bind-icon-color[data-v-f7c98176] {
@@ -80,8 +79,9 @@
80
79
  background-color: var(--f4b27ac2);
81
80
  }
82
81
 
83
- .bind-icon-color[data-v-d95fcb03] {
84
- color: var(--beebbd52);
82
+ .bind-preview-bg[data-v-c48fb2b2] {
83
+ background-color: var(--627bec82);
84
+ color: var(--35068428);
85
85
  }
86
86
 
87
87
  .bind-preview-bg[data-v-a83b1911] {
package/dist/style.css CHANGED
@@ -440,6 +440,10 @@ body {
440
440
  }
441
441
  }
442
442
 
443
+ .htw-sandbox-contain {
444
+ contain: content;
445
+ }
446
+
443
447
  .__histoire-code .shiki {
444
448
  background: transparent !important;
445
449
  }
@@ -1298,14 +1302,14 @@ body {
1298
1302
  margin:auto
1299
1303
  }
1300
1304
 
1301
- .htw-m-4{
1302
- margin:1rem
1303
- }
1304
-
1305
1305
  .htw-m-1{
1306
1306
  margin:0.25rem
1307
1307
  }
1308
1308
 
1309
+ .htw-m-4{
1310
+ margin:1rem
1311
+ }
1312
+
1309
1313
  .-htw-my-1{
1310
1314
  margin-top:-0.25rem;
1311
1315
  margin-bottom:-0.25rem
@@ -1326,6 +1330,16 @@ body {
1326
1330
  margin-right:0.5rem
1327
1331
  }
1328
1332
 
1333
+ .htw-mx-4{
1334
+ margin-left:1rem;
1335
+ margin-right:1rem
1336
+ }
1337
+
1338
+ .htw-my-4{
1339
+ margin-top:1rem;
1340
+ margin-bottom:1rem
1341
+ }
1342
+
1329
1343
  .htw-my-0{
1330
1344
  margin-top:0px;
1331
1345
  margin-bottom:0px
@@ -1336,11 +1350,6 @@ body {
1336
1350
  margin-bottom:2rem
1337
1351
  }
1338
1352
 
1339
- .htw-mx-4{
1340
- margin-left:1rem;
1341
- margin-right:1rem
1342
- }
1343
-
1344
1353
  .htw-mt-2{
1345
1354
  margin-top:0.5rem
1346
1355
  }
@@ -1579,6 +1588,10 @@ body {
1579
1588
  width:0.5rem
1580
1589
  }
1581
1590
 
1591
+ .htw-w-0{
1592
+ width:0px
1593
+ }
1594
+
1582
1595
  .htw-w-max{
1583
1596
  width:-moz-max-content;
1584
1597
  width:max-content
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@histoire/app",
3
- "version": "0.11.6",
3
+ "version": "0.11.7",
4
4
  "description": "Pre-bundled UI for Histoire",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,9 +24,9 @@
24
24
  },
25
25
  "types": "./src/index.ts",
26
26
  "dependencies": {
27
- "@histoire/controls": "^0.11.6",
28
- "@histoire/shared": "^0.11.6",
29
- "@histoire/vendors": "^0.11.6",
27
+ "@histoire/controls": "^0.11.7",
28
+ "@histoire/shared": "^0.11.7",
29
+ "@histoire/vendors": "^0.11.7",
30
30
  "@types/flexsearch": "^0.7.3",
31
31
  "flexsearch": "0.7.21",
32
32
  "shiki": "0.10.1"
@@ -29,7 +29,7 @@ watchEffect(async () => {
29
29
  <component
30
30
  :is="mountComponent"
31
31
  v-if="mountComponent"
32
- class="histoire-generic-render-story"
32
+ class="histoire-generic-render-story htw-sandbox-contain"
33
33
  :story="story"
34
34
  v-bind="$attrs"
35
35
  />
@@ -82,6 +82,7 @@ function onItemResize (w: number, h: number) {
82
82
  }
83
83
 
84
84
  watch(() => storyStore.currentVariant, () => {
85
+ maxItemHeight.value = 0 // Reset max height
85
86
  updateMaxCount()
86
87
  })
87
88
 
@@ -97,10 +98,11 @@ function updateSize () {
97
98
 
98
99
  if (!gridEl.value) return
99
100
 
100
- const firstCellEl = gridEl.value.children[0] as HTMLDivElement
101
- if (!firstCellEl) return
102
-
103
- gridColumnWidth.value = firstCellEl.clientWidth
101
+ if (gridTemplateWidth.value.endsWith('%')) {
102
+ gridColumnWidth.value = viewWidth.value * parseInt(gridTemplateWidth.value) / 100 - gap
103
+ } else {
104
+ gridColumnWidth.value = parseInt(gridTemplateWidth.value)
105
+ }
104
106
  }
105
107
 
106
108
  onMounted(() => {
@@ -125,31 +127,33 @@ const columnCount = computed(() => Math.min(storyStore.currentStory.variants.len
125
127
  <ToolbarTextDirection />
126
128
  </div>
127
129
 
128
- <div
129
- ref="el"
130
- class="htw-overflow-y-auto htw-flex htw-flex-1"
131
- @scroll="updateMaxCount()"
132
- >
130
+ <div class="htw-overflow-y-auto htw-flex htw-flex-1">
133
131
  <div
134
- class="htw-m-auto"
135
- :style="{
136
- minHeight: `${(storyStore.currentStory.variants.length / countPerRow) * (maxItemHeight + gap) - gap}px`,
137
- }"
132
+ ref="el"
133
+ class="htw-flex htw-w-0 htw-flex-1 htw-mx-4"
134
+ @scroll="updateMaxCount()"
138
135
  >
139
136
  <div
140
- ref="gridEl"
141
- class="htw-grid htw-gap-4 htw-m-4"
137
+ class="htw-m-auto"
142
138
  :style="{
143
- gridTemplateColumns: `repeat(${columnCount}, ${gridTemplateWidth})`,
139
+ minHeight: `${(storyStore.currentStory.variants.length / countPerRow) * (maxItemHeight + gap) - gap}px`,
144
140
  }"
145
141
  >
146
- <StoryVariantGridItem
147
- v-for="(variant, index) of storyStore.currentStory.variants.slice(0, maxCount)"
148
- :key="index"
149
- :variant="variant"
150
- :story="storyStore.currentStory"
151
- @resize="onItemResize"
152
- />
142
+ <div
143
+ ref="gridEl"
144
+ class="htw-grid htw-gap-4 htw-my-4"
145
+ :style="{
146
+ gridTemplateColumns: `repeat(${columnCount}, ${gridColumnWidth}px)`,
147
+ }"
148
+ >
149
+ <StoryVariantGridItem
150
+ v-for="(variant, index) of storyStore.currentStory.variants.slice(0, maxCount)"
151
+ :key="index"
152
+ :variant="variant"
153
+ :story="storyStore.currentStory"
154
+ @resize="onItemResize"
155
+ />
156
+ </div>
153
157
  </div>
154
158
  </div>
155
159
  </div>
@@ -64,7 +64,7 @@ button {
64
64
  }
65
65
  }
66
66
 
67
- .__histoire-sandbox {
67
+ .htw-sandbox-contain {
68
68
  contain: content;
69
69
  }
70
70
 
@@ -17,3 +17,7 @@ html {
17
17
  .htw-sandbox-hidden {
18
18
  display: none;
19
19
  }
20
+
21
+ .htw-sandbox-contain {
22
+ contain: content;
23
+ }