Skip to content

Commit

Permalink
PATCH: doc(components): improve BIMDataCarousel doc + add reactivity …
Browse files Browse the repository at this point in the history
…on minGap prop
  • Loading branch information
NicolasRichel committed Jun 14, 2022
1 parent e30aab6 commit 48d8ef1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
5 changes: 5 additions & 0 deletions src/BIMDataComponents/BIMDataCarousel/BIMDataCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export default {
translations: [],
};
},
watch: {
minGap() {
this.distributeItems();
},
},
mounted() {
this.distributeItems();
this.resizeObserver = new ResizeObserver(() => this.distributeItems());
Expand Down
56 changes: 41 additions & 15 deletions src/web/views/Components/Carousel/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@
:minGap="+minGap"
>
<div
style="height: 100px; background-color: #ddd"
style="
height: 100px;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
background-color: #ddd;
"
:style="{ width: `${itemWidth}px` }"
v-for="i of [1, 2, 3, 4, 5, 6]"
v-for="i of items"
:key="i"
></div>
>
{{ i }}
</div>
</BIMDataCarousel>
</template>

Expand All @@ -28,12 +37,6 @@
placeholder="Carousel width"
v-model="carouselWidth"
/>
<!-- <BIMDataInput
margin="24px 0"
type="number"
placeholder="Item width (in px)"
v-model="itemWidth"
/>
<BIMDataInput
margin="24px 0"
type="number"
Expand All @@ -45,7 +48,19 @@
type="number"
placeholder="Minimum gap (in px)"
v-model="minGap"
/> -->
/>
<BIMDataInput
margin="24px 0"
type="number"
placeholder="Number of items"
v-model="nbItems"
/>
<BIMDataInput
margin="24px 0"
type="number"
placeholder="Item width (in px)"
v-model="itemWidth"
/>
</template>

<template #import>
Expand All @@ -55,13 +70,18 @@

<template #code>
<pre>
&lt;BIMDataCarousel :style="{ width: {{ carouselWidth }} }"&gt;
&lt;BIMDataCarousel
:style="{ width: {{ carouselWidth }} }"
:sliderPadding="{{ sliderPadding }}"
:minGap="{{ minGap }}"
&gt;
&lt;div
style="height: 100px; background-color: #ddd"
:style="{ width: {{ `${itemWidth}px` }} }"
v-for="i of [1, 2, 3, 4, 5, 6]"
v-for="i of items"
:key="i"
&gt;&lt;/div&gt;
&gt;
{{ "{" + "{ i }" + "}" }}
&lt;/div&gt;
&lt;/BIMDataCarousel&gt;
</pre>
</template>
Expand Down Expand Up @@ -97,13 +117,19 @@ export default {
data() {
return {
carouselWidth: "60%",
itemWidth: 150,
sliderPadding: 12,
minGap: 24,
nbItems: 6,
itemWidth: 150,
// Data
propsData,
};
},
computed: {
items() {
return Array.from({ length: this.nbItems }, (_, i) => i + 1);
},
},
};
</script>

0 comments on commit 48d8ef1

Please sign in to comment.