schlechtenburg/packages/layout/lib/display.tsx

51 lines
842 B
TypeScript
Raw Normal View History

2020-05-27 13:57:57 +00:00
import {
defineComponent,
2020-12-27 21:32:43 +00:00
computed,
2020-05-27 13:57:57 +00:00
PropType,
2020-12-27 21:32:43 +00:00
} from 'vue';
2020-05-27 13:57:57 +00:00
import {
model,
blockProps,
2020-12-30 13:34:23 +00:00
SbBlock,
} from '@schlechtenburg/core';
2020-05-27 13:57:57 +00:00
import {
LayoutData,
LayoutProps,
getDefaultData,
} from './util';
import './style.scss';
export default defineComponent({
name: 'sb-layout-display',
model,
props: {
...blockProps,
data: {
type: (null as unknown) as PropType<LayoutData>,
default: getDefaultData,
},
},
2020-05-27 15:32:35 +00:00
setup(props: LayoutProps) {
2020-05-27 13:57:57 +00:00
const classes = computed(() => ({
'sb-layout': true,
[`sb-layout_${props.data.orientation}`]: true,
}));
return () => (
<div class={classes.value}>
2020-05-27 15:32:35 +00:00
{...props.data.children.map((child) => (
2020-05-27 13:57:57 +00:00
<SbBlock
key={child.blockId}
block={child}
/>
))}
</div>
);
},
});