2
0
mirror of https://github.com/frappe/books.git synced 2025-01-27 09:08:24 +00:00
books/src/components/Row.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.0 KiB
Vue
Raw Normal View History

<template>
<div class="inline-grid" :style="style" v-bind="$attrs">
<slot></slot>
</div>
</template>
2019-10-04 23:30:51 +05:30
<script>
export default {
name: 'Row',
2019-10-04 23:30:51 +05:30
props: {
columnWidth: {
type: String,
default: '1fr',
},
2019-10-04 23:30:51 +05:30
columnCount: {
type: Number,
default: 0,
},
ratio: {
type: Array,
default: () => [],
2019-10-14 03:26:20 +05:30
},
gridTemplateColumns: {
type: String,
default: null,
},
gap: String,
2019-10-04 23:30:51 +05:30
},
computed: {
style() {
2019-10-14 03:26:20 +05:30
let obj = {};
if (this.columnCount) {
2019-12-21 21:19:01 +05:30
// prettier-ignore
obj['grid-template-columns'] = `repeat(${this.columnCount}, ${this.columnWidth})`;
}
if (this.ratio.length) {
obj['grid-template-columns'] = this.ratio
.map((r) => `minmax(0, ${r}fr)`)
.join(' ');
2019-10-14 03:26:20 +05:30
}
if (this.gridTemplateColumns) {
obj['grid-template-columns'] = this.gridTemplateColumns;
}
2019-10-14 03:26:20 +05:30
if (this.gap) {
obj['grid-gap'] = this.gap;
2019-10-04 23:30:51 +05:30
}
2019-10-14 03:26:20 +05:30
return obj;
},
},
2019-10-14 03:26:20 +05:30
};
2019-10-04 23:30:51 +05:30
</script>