schlechtenburg/src/App.tsx

64 lines
1.4 KiB
TypeScript
Raw Normal View History

2020-05-20 14:21:08 +00:00
import {
defineComponent,
reactive,
2020-05-27 13:57:57 +00:00
ref,
2020-05-20 14:21:08 +00:00
} from '@vue/composition-api';
import Schlechtenburg from '@components/Schlechtenburg';
2020-05-27 15:06:14 +00:00
import { Block } from './components/TreeElement';
2020-05-20 14:21:08 +00:00
import './App.scss';
export default defineComponent({
name: 'App',
setup() {
2020-05-27 13:57:57 +00:00
const activeTab = ref('edit');
2020-05-20 17:12:51 +00:00
const block = reactive({
2020-05-24 15:33:25 +00:00
name: 'sb-layout',
blockId: `${+(new Date())}`,
data: {
orientation: 'vertical',
children: [],
},
2020-05-27 15:06:14 +00:00
}) as Block;
2020-05-20 14:21:08 +00:00
2020-05-25 21:10:21 +00:00
return () => (
2020-05-20 14:21:08 +00:00
<div id="app">
2020-05-27 13:57:57 +00:00
<select
value={activeTab.value}
2020-05-25 21:10:21 +00:00
{...{
on: {
2020-05-27 13:57:57 +00:00
change: ($event: Event) => {
activeTab.value = ($event.target as HTMLSelectElement).value;
2020-05-25 21:10:21 +00:00
},
},
}}
2020-05-27 13:57:57 +00:00
>
<option>edit</option>
<option>display</option>
<option>json</option>
</select>
<Schlechtenburg
vShow={activeTab.value === 'edit'}
block={block}
2020-05-27 15:06:14 +00:00
eventUpdate={(newBlock: Block) => {
2020-05-27 13:57:57 +00:00
block.name = newBlock.name;
block.blockId = newBlock.blockId;
block.data = newBlock.data;
}}
/>
<Schlechtenburg
vShow={activeTab.value === 'display'}
block={block}
mode="display"
2020-05-25 21:10:21 +00:00
/>
2020-05-20 14:21:08 +00:00
2020-05-27 13:57:57 +00:00
<pre vShow={activeTab.value === 'json'}>
<code>{JSON.stringify(block, null, 2)}</code>
</pre>
2020-05-20 14:21:08 +00:00
</div>
);
},
});