add grid component

This commit is contained in:
Alina Beck 2019-08-13 16:23:44 +01:00
parent 6f1d94610e
commit 3a93d9abb3
4 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,44 @@
<template>
<component
:is="tag"
class="ds-grid"
:style="styles"
>
<slot />
</component>
</template>
<script>
export default {
name: 'DsGrid',
props: {
gap: {
type: Number,
default: 16, // TODO: how to use tokens.small here?
},
minColumnWidth: {
type: Number,
default: 300,
},
rowHeight: {
type: Number,
default: 20,
},
tag: {
type: String,
default: 'div',
},
},
computed: {
styles() {
return ({
gridTemplateColumns: `repeat(auto-fill, minmax(${this.minColumnWidth}px, 1fr`,
gridGap: `${this.gap}px`,
gridAutoRows: `${this.rowHeight}px`,
})
}
}
}
</script>
<style lang="scss" src="./style.scss" />

View File

@ -0,0 +1,13 @@
<template>
<component :is="tag">
<slot />
</component>
</template>
<script>
export default {
name: 'DsGridItem',
}
</script>
<style/>

View File

@ -0,0 +1,3 @@
.ds-grid {
display: grid;
}