rudeshark.net/packages/client/src/components/MkSample.vue

131 lines
3.0 KiB
Vue
Raw Normal View History

2020-10-17 17:49:02 +02:00
<template>
2023-04-08 02:01:42 +02:00
<div class="_card">
<div class="_content">
<MkInput v-model="text">
<template #label>Text</template>
</MkInput>
<MkSwitch v-model="flag">
<span>Switch is now {{ flag ? "on" : "off" }}</span>
</MkSwitch>
<div style="margin: 32px 0">
<MkRadio v-model="radio" value="misskey">Calckey</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>
<div class="_content" style="pointer-events: none">
<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>
2020-10-17 17:49:02 +02:00
</div>
</div>
</template>
<script lang="ts">
2023-04-08 02:01:42 +02:00
import { defineComponent } from "vue";
import MkButton from "@/components/MkButton.vue";
import MkInput from "@/components/form/input.vue";
import MkSwitch from "@/components/form/switch.vue";
import MkTextarea from "@/components/form/textarea.vue";
import MkRadio from "@/components/form/radio.vue";
import * as os from "@/os";
import * as config from "@/config";
2020-10-17 17:49:02 +02:00
export default defineComponent({
components: {
MkButton,
MkInput,
MkSwitch,
MkTextarea,
MkRadio,
},
data() {
return {
2023-04-08 02:01:42 +02:00
text: "",
2021-01-09 09:18:45 +01:00
flag: true,
2023-04-08 02:01:42 +02:00
radio: "calckey",
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
2023-05-08 22:39:39 +02:00
}). for more details, see https://calckey.org.\nAs you know #misskey is open-source software.`,
};
2020-10-17 17:49:02 +02:00
},
methods: {
async openDialog() {
os.alert({
2023-04-08 02:01:42 +02:00
type: "warning",
title: "Oh my Calc",
text: "Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
2020-10-17 17:49:02 +02:00
});
},
async openForm() {
2023-04-08 02:01:42 +02:00
os.form("Example form", {
2020-10-17 17:49:02 +02:00
foo: {
2023-04-08 02:01:42 +02:00
type: "boolean",
2020-10-17 17:49:02 +02:00
default: true,
2023-04-08 02:01:42 +02:00
label: "This is a boolean property",
2020-10-17 17:49:02 +02:00
},
bar: {
2023-04-08 02:01:42 +02:00
type: "number",
2020-10-17 17:49:02 +02:00
default: 300,
2023-04-08 02:01:42 +02:00
label: "This is a number property",
2020-10-17 17:49:02 +02:00
},
baz: {
2023-04-08 02:01:42 +02:00
type: "string",
default: "Calckey makes you happy.",
label: "This is a string property",
2020-10-17 17:49:02 +02:00
},
});
},
async openDrive() {
os.selectDriveFile();
},
async selectUser() {
os.selectUser();
},
async openMenu(ev) {
2023-04-08 02:01:42 +02:00
os.popupMenu(
[
{
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
);
2020-10-17 17:49:02 +02:00
},
2023-04-08 02:01:42 +02:00
},
2020-10-17 17:49:02 +02:00
});
</script>