2
0
mirror of https://github.com/frappe/books.git synced 2025-01-30 10:38:26 +00:00
books/src/components/Row.vue
18alantom 2f6a2f4cc2 refactor: vue 2 → 3 migration
- render functions
- slots
- creation
2022-02-10 12:11:51 +05:30

52 lines
1.0 KiB
Vue

<template>
<div class="inline-grid border-b" :style="style" v-bind="$attrs">
<slot></slot>
</div>
</template>
<script>
export default {
name: 'Row',
props: {
columnWidth: {
type: String,
default: '1fr',
},
columnCount: {
type: Number,
default: 0,
},
ratio: {
type: Array,
default: () => [],
},
gridTemplateColumns: {
type: String,
default: null,
},
gap: String,
},
computed: {
style() {
let obj = {};
if (this.columnCount) {
// prettier-ignore
obj['grid-template-columns'] = `repeat(${this.columnCount}, ${this.columnWidth})`;
}
if (this.ratio.length) {
obj['grid-template-columns'] = this.ratio
.map((r) => `${r}fr`)
.join(' ');
}
if (this.gridTemplateColumns) {
obj['grid-template-columns'] = this.gridTemplateColumns;
}
if (this.gap) {
obj['grid-gap'] = this.gap;
}
return obj;
},
},
};
</script>