tethys.backend/resources/js/Components/BaseButtons.vue

52 lines
1.4 KiB
Vue
Raw Permalink Normal View History

2023-03-03 15:54:28 +00:00
<script>
import { h, defineComponent } from 'vue';
2023-03-03 15:54:28 +00:00
export default defineComponent({
name: 'BaseButtons',
props: {
noWrap: Boolean,
type: {
type: String,
default: 'justify-start',
},
classAddon: {
type: String,
default: 'mr-3 last:mr-0 mb-3',
},
mb: {
type: String,
default: '-mb-3',
},
2023-03-03 15:54:28 +00:00
},
render() {
const hasSlot = this.$slots && this.$slots.default;
2023-03-03 15:54:28 +00:00
const parentClass = ['flex', 'items-center', this.type, this.noWrap ? 'flex-nowrap' : 'flex-wrap'];
2023-03-03 15:54:28 +00:00
if (this.mb) {
parentClass.push(this.mb);
}
2023-03-03 15:54:28 +00:00
return h(
'div',
{ class: parentClass },
hasSlot
? this.$slots.default().map((element) => {
if (element && element.children && typeof element.children === 'object') {
return h(
element,
{},
element.children.map((child) => {
return h(child, { class: [this.classAddon] });
}),
);
}
2023-03-03 15:54:28 +00:00
return h(element, { class: [this.classAddon] });
})
: null,
);
},
});
2023-03-03 15:54:28 +00:00
</script>