diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-01-07 15:09:46 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-01-07 15:09:46 +0900 |
| commit | 58bfb4dca4a0b0f0d8468667f5a6b0f0bdc374f5 (patch) | |
| tree | ce743174bfa62d80b77d29e0c473c577af13bead /packages/frontend/src/components/MkRadios.vue | |
| parent | fix typo (diff) | |
| download | misskey-58bfb4dca4a0b0f0d8468667f5a6b0f0bdc374f5.tar.gz misskey-58bfb4dca4a0b0f0d8468667f5a6b0f0bdc374f5.tar.bz2 misskey-58bfb4dca4a0b0f0d8468667f5a6b0f0bdc374f5.zip | |
refactor
Diffstat (limited to 'packages/frontend/src/components/MkRadios.vue')
| -rw-r--r-- | packages/frontend/src/components/MkRadios.vue | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/packages/frontend/src/components/MkRadios.vue b/packages/frontend/src/components/MkRadios.vue new file mode 100644 index 0000000000..8590ccf9ae --- /dev/null +++ b/packages/frontend/src/components/MkRadios.vue @@ -0,0 +1,83 @@ +<script lang="ts"> +import { defineComponent, h } from 'vue'; +import MkRadio from './MkRadio.vue'; + +export default defineComponent({ + components: { + MkRadio, + }, + props: { + modelValue: { + required: false, + }, + }, + data() { + return { + value: this.modelValue, + }; + }, + watch: { + value() { + this.$emit('update:modelValue', this.value); + }, + }, + render() { + let options = this.$slots.default(); + const label = this.$slots.label && this.$slots.label(); + const caption = this.$slots.caption && this.$slots.caption(); + + // なぜかFragmentになることがあるため + if (options.length === 1 && options[0].props == null) options = options[0].children; + + return h('div', { + class: 'novjtcto', + }, [ + ...(label ? [h('div', { + class: 'label', + }, [label])] : []), + h('div', { + class: 'body', + }, options.map(option => h(MkRadio, { + key: option.key, + value: option.props.value, + modelValue: this.value, + 'onUpdate:modelValue': value => this.value = value, + }, option.children)), + ), + ...(caption ? [h('div', { + class: 'caption', + }, [caption])] : []), + ]); + }, +}); +</script> + +<style lang="scss"> +.novjtcto { + > .label { + font-size: 0.85em; + padding: 0 0 8px 0; + user-select: none; + + &:empty { + display: none; + } + } + + > .body { + display: flex; + gap: 12px; + flex-wrap: wrap; + } + + > .caption { + font-size: 0.85em; + padding: 8px 0 0 0; + color: var(--fgTransparentWeak); + + &:empty { + display: none; + } + } +} +</style> |