Skip to content

Commit

Permalink
Adds mosaic rows and columns settings to vue side of block. #329.
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuswetah committed Nov 11, 2019
1 parent 3233106 commit f3c673c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Expand Up @@ -15,6 +15,8 @@ document.addEventListener("DOMContentLoaded", () => {
searchURL: '',
maxItemsNumber: 12,
mosaicHeight: 40,
mosaicGridRows: 3,
mosaicGridColumns: 3,
order: 'asc',
showSearchBar: false,
showCollectionHeader: false,
Expand All @@ -34,6 +36,8 @@ document.addEventListener("DOMContentLoaded", () => {
layout: this.layout,
gridMargin: this.gridMargin,
mosaicHeight: this.mosaicHeight,
mosaicGridRows: this.mosaicGridRows,
mosaicGridColumns: this.mosaicGridColumns,
searchURL: this.searchURL,
maxItemsNumber: this.maxItemsNumber,
order: this.order,
Expand All @@ -57,6 +61,8 @@ document.addEventListener("DOMContentLoaded", () => {
this.layout = this.$el.attributes['layout'] != undefined ? this.$el.attributes['layout'].value : undefined;
this.gridMargin = this.$el.attributes['grid-margin'] != undefined ? Number(this.$el.attributes['grid-margin'].value) : undefined;
this.mosaicHeight = this.$el.attributes['mosaic-height'] != undefined ? Number(this.$el.attributes['mosaic-height'].value) : undefined;
this.mosaicGridRows = this.$el.attributes['mosaic-grid-rows'] != undefined ? Number(this.$el.attributes['mosaic-grid-rows'].value) : undefined;
this.mosaicGridColumns = this.$el.attributes['mosaic-grid-columns'] != undefined ? Number(this.$el.attributes['mosaic-grid-columns'].value) : undefined;
this.maxItemsNumber = this.$el.attributes['max-items-number'] != undefined ? this.$el.attributes['max-items-number'].value : undefined;
this.order = this.$el.attributes['order'] != undefined ? this.$el.attributes['order'].value : undefined;
this.showSearchBar = this.$el.attributes['show-search-bar'] != undefined ? this.$el.attributes['show-search-bar'].value == 'true' : false;
Expand Down
Expand Up @@ -202,13 +202,13 @@
<div
:style="{
width: 'calc((100% / ' + mosaicPartition(items, 5).length + ') - ' + gridMargin + 'px)',
height: 'calc(((2 * ' + gridMargin + 'px) + ' + mosaicHeight + 'vh))',
gridTemplateColumns: 'repeat(3, calc((100% / 3) - (' + (2*Number(gridMargin)) + 'px/3)))',
height: 'calc(((' + (mosaicGridRows - 1) + ' * ' + gridMargin + 'px) + ' + mosaicHeight + 'vh))',
gridTemplateColumns: 'repeat(' + mosaicGridColumns + ', calc((100% / ' + mosaicGridColumns + ') - (' + ((mosaicGridColumns - 1)*Number(gridMargin)) + 'px/' + mosaicGridColumns + ')))',
margin: gridMargin + 'px',
gridGap: gridMargin + 'px',
}"
class="mosaic-container"
:class="'mosaic-container--' + mosaicGroup.length"
:class="'mosaic-container--' + mosaicGroup.length + '-' + mosaicGridRows + 'x' + mosaicGridColumns"
:key="mosaicIndex"
v-for="(mosaicGroup, mosaicIndex) of mosaicPartition(items, 5)">
<li
Expand Down Expand Up @@ -271,6 +271,8 @@ export default {
searchURL: String,
maxItemsNumber: Number,
mosaicHeight: Number,
mosaicGridRows: Number,
mosaicGridColumns: Number,
order: String,
showSearchBar: Boolean,
showCollectionHeader: Boolean,
Expand Down
Expand Up @@ -197,7 +197,7 @@ registerBlockType('tainacan/dynamic-items-list', {
{
width: 'calc((100% / ' + mosaicGroupsLength + ') - ' + gridMargin + 'px)',
height: 'calc(((' + (mosaicGridRows - 1) + ' * ' + gridMargin + 'px) + ' + mosaicHeight + 'vh))',
gridTemplateColumns: 'repeat(' + mosaicGridColumns + ', calc((100% / ' + mosaicGridColumns + ') - (' + ((mosaicGridRows - 1)*Number(gridMargin)) + 'px/' + mosaicGridColumns + ')))',
gridTemplateColumns: 'repeat(' + mosaicGridColumns + ', calc((100% / ' + mosaicGridColumns + ') - (' + ((mosaicGridColumns - 1)*Number(gridMargin)) + 'px/' + mosaicGridColumns + ')))',
margin: gridMargin + 'px',
gridGap: gridMargin + 'px',
}
Expand Down Expand Up @@ -863,7 +863,9 @@ registerBlockType('tainacan/dynamic-items-list', {
showCollectionLabel,
collectionBackgroundColor,
collectionTextColor,
mosaicHeight
mosaicHeight,
mosaicGridRows,
mosaicGridColumns
} = attributes;

return <div
Expand All @@ -877,6 +879,8 @@ registerBlockType('tainacan/dynamic-items-list', {
show-collection-label={ '' + showCollectionLabel }
layout={ layout }
mosaic-height={ mosaicHeight }
mosaic-grid-rows={ mosaicGridRows }
mosaic-grid-columns={ mosaicGridColumns }
collection-background-color={ collectionBackgroundColor }
collection-text-color={ collectionTextColor }
grid-margin={ gridMargin }
Expand Down

0 comments on commit f3c673c

Please sign in to comment.