diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2022-01-30 14:11:52 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-30 14:11:52 +0900 |
| commit | 55b3ae22ee81774b5641f3a42216327b9277f6e5 (patch) | |
| tree | 0467accc21547ddd0122c4520ac3aa38ceeb29c9 /packages/client/src/components/form | |
| parent | update misskey-js (diff) | |
| download | misskey-55b3ae22ee81774b5641f3a42216327b9277f6e5.tar.gz misskey-55b3ae22ee81774b5641f3a42216327b9277f6e5.tar.bz2 misskey-55b3ae22ee81774b5641f3a42216327b9277f6e5.zip | |
enhance: メニュー関連をComposition API化、switchアイテム追加 (#8215)
* メニューをComposition API化、switchアイテム追加
クライアントサイド画像圧縮の準備
* メニュー型定義を分離 (TypeScriptの型支援が効かないので)
* disabled
* make keepOriginal to follow setting value
* fix
* fix
* Fix
* clean up
Diffstat (limited to 'packages/client/src/components/form')
| -rw-r--r-- | packages/client/src/components/form/switch.vue | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/packages/client/src/components/form/switch.vue b/packages/client/src/components/form/switch.vue index f8a07b4caa..b5a30d635c 100644 --- a/packages/client/src/components/form/switch.vue +++ b/packages/client/src/components/form/switch.vue @@ -20,45 +20,33 @@ </div> </template> -<script lang="ts"> -import { defineComponent, ref, toRefs } from 'vue'; +<script lang="ts" setup> +import { toRefs, Ref } from 'vue'; import * as os from '@/os'; import Ripple from '@/components/ripple.vue'; -export default defineComponent({ - props: { - modelValue: { - type: Boolean, - default: false - }, - disabled: { - type: Boolean, - default: false - } - }, +const props = defineProps<{ + modelValue: boolean | Ref<boolean>; + disabled?: boolean; +}>(); - setup(props, context) { - const button = ref<HTMLElement>(); - const checked = toRefs(props).modelValue; - const toggle = () => { - if (props.disabled) return; - context.emit('update:modelValue', !checked.value); +const emit = defineEmits<{ + (e: 'update:modelValue', v: boolean): void; +}>(); - if (!checked.value) { - const rect = button.value.getBoundingClientRect(); - const x = rect.left + (button.value.offsetWidth / 2); - const y = rect.top + (button.value.offsetHeight / 2); - os.popup(Ripple, { x, y, particle: false }, {}, 'end'); - } - }; +let button = $ref<HTMLElement>(); +const checked = toRefs(props).modelValue; +const toggle = () => { + if (props.disabled) return; + emit('update:modelValue', !checked.value); - return { - button, - checked, - toggle, - }; - }, -}); + if (!checked.value) { + const rect = button.getBoundingClientRect(); + const x = rect.left + (button.offsetWidth / 2); + const y = rect.top + (button.offsetHeight / 2); + os.popup(Ripple, { x, y, particle: false }, {}, 'end'); + } +}; </script> <style lang="scss" scoped> |