Skip to content

Commit

Permalink
fix(grid): update column count when content szie changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Oct 17, 2022
1 parent 091da7b commit 0786a57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 10 additions & 4 deletions examples/vue3/src/components/EventButtonGrid.story.vue
Expand Up @@ -8,9 +8,15 @@ import { logEvent } from 'histoire/client'
title="events/EventButtonGrid"
:layout="{ type: 'grid', width: 500 }"
>
<EventButton @myEvent="logEvent('My event', $event)" /><br>
<button @click="logEvent('Click', $event)">
Click
</button>
<Variant
v-for="n in 9"
:key="n"
:title="`Variant ${n}`"
>
<EventButton @myEvent="logEvent('My event', $event)" /><br>
<button @click="logEvent('Click', $event)">
Click
</button>
</Variant>
</Story>
</template>
Expand Up @@ -107,6 +107,10 @@ onMounted(() => {
updateSize()
})
useResizeObserver(gridEl, () => {
updateSize()
})
const columnCount = computed(() => Math.min(storyStore.currentStory.variants.length, Math.floor((viewWidth.value + gap) / (gridColumnWidth.value + gap))))
</script>

Expand Down

0 comments on commit 0786a57

Please sign in to comment.