barkey/src/client/components/sample.vue

117 lines
2.9 KiB
Vue
Raw Normal View History

2020-10-17 15:49:02 +00:00
<template>
<div class="_card">
<div class="_content">
<MkInput v-model:value="text">
<span>Text</span>
</MkInput>
<MkSwitch v-model:value="flag">
<span>Switch is now {{ flag ? 'on' : 'off' }}</span>
</MkSwitch>
<div style="margin: 32px 0;">
<MkRadio v-model="radio" value="misskey">Misskey</MkRadio>
<MkRadio v-model="radio" value="mastodon">Mastodon</MkRadio>
<MkRadio v-model="radio" value="pleroma">Pleroma</MkRadio>
</div>
<MkButton inline>This is</MkButton>
<MkButton inline primary>the button</MkButton>
</div>
2021-01-09 08:18:45 +00:00
<div class="_content" style="pointer-events: none;">
2020-10-17 15:49:02 +00:00
<Mfm :text="mfm"/>
</div>
<div class="_content">
<MkButton inline primary @click="openMenu">Open menu</MkButton>
<MkButton inline primary @click="openDialog">Open dialog</MkButton>
<MkButton inline primary @click="openForm">Open form</MkButton>
<MkButton inline primary @click="openDrive">Open drive</MkButton>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
2021-03-23 08:30:14 +00:00
import MkButton from '@client/components/ui/button.vue';
import MkInput from '@client/components/ui/input.vue';
import MkSwitch from '@client/components/ui/switch.vue';
import MkTextarea from '@client/components/ui/textarea.vue';
import MkRadio from '@client/components/ui/radio.vue';
import * as os from '@client/os';
import * as config from '@client/config';
2020-10-17 15:49:02 +00:00
export default defineComponent({
components: {
MkButton,
MkInput,
MkSwitch,
MkTextarea,
MkRadio,
},
data() {
return {
text: '',
2021-01-09 08:18:45 +00:00
flag: true,
2020-10-17 15:49:02 +00:00
radio: 'misskey',
2021-02-13 06:39:13 +00:00
mfm: `Hello world! This is an @example mention. BTW you are @${this.$i ? this.$i.username : 'guest'}.\nAlso, here is ${config.url} and [example link](${config.url}). for more details, see https://example.com.\nAs you know #misskey is open-source software.`
2020-10-17 15:49:02 +00:00
}
},
methods: {
async openDialog() {
os.dialog({
type: 'warning',
title: 'Oh my Aichan',
text: 'Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
});
},
async openForm() {
os.form('Example form', {
foo: {
type: 'boolean',
default: true,
label: 'This is a boolean property'
},
bar: {
type: 'number',
default: 300,
label: 'This is a number property'
},
baz: {
type: 'string',
default: 'Misskey makes you happy.',
label: 'This is a string property'
},
});
},
async openDrive() {
os.selectDriveFile();
},
async selectUser() {
os.selectUser();
},
async openMenu(ev) {
os.modalMenu([{
type: 'label',
text: 'Fruits'
}, {
text: 'Create some apples',
action: () => {},
}, {
text: 'Read some oranges',
action: () => {},
}, {
text: 'Update some melons',
action: () => {},
}, null, {
text: 'Delete some bananas',
danger: true,
action: () => {},
}], ev.currentTarget || ev.target);
},
}
});
</script>