schlechtenburg/packages/heading/lib/view.ts

45 lines
735 B
TypeScript
Raw Normal View History

2022-03-11 17:23:14 +00:00
import {
defineComponent,
computed,
PropType,
h,
} from 'vue';
import {
model,
} from '@schlechtenburg/core';
import {
getDefaultData,
IHeadingData,
} from './util';
import './style.scss';
export default defineComponent({
name: 'sb-heading-display',
model,
props: {
data: {
type: Object as PropType<IHeadingData>,
default: getDefaultData,
},
},
setup(props) {
const classes = computed(() => ({
'sb-heading': true,
[`sb-heading_align-${props.data.align}`]: true,
[`sb-heading_${props.data.level}`]: true,
}));
return () => h(
`h${props.data.level}`,
{
2022-03-11 17:32:31 +00:00
class: classes.value,
2022-03-11 17:23:14 +00:00
innerHTML: props.data.value,
},
);
},
});