-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
refactor: SettingDialog.vueのボタントグルを共通化 (#2111)
* 途中 * できた * @update:model-valueに * slot * ちょっと変更 * npm run fmt
Showing
3 changed files
with
188 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!-- 2種類以上のボタンから1つ選ぶ設定項目 --> | ||
|
||
<template> | ||
<BaseCell :title :description> | ||
<QBtnToggle | ||
padding="xs md" | ||
unelevated | ||
color="background" | ||
textColor="display" | ||
toggleColor="primary" | ||
toggleTextColor="display-on-primary" | ||
:disable | ||
:modelValue | ||
:options="optionsForQBtnToggle" | ||
@update:modelValue="props['onUpdate:modelValue']" | ||
> | ||
<slot /> | ||
|
||
<!-- FIXME: ツールチップの内容をaria-labelに付ける --> | ||
<template | ||
v-for="option in options.filter( | ||
(option) => option.description != undefined, | ||
)" | ||
:key="option.label" | ||
#[option.label] | ||
> | ||
<QTooltip :delay="500"> | ||
{{ option.description }} | ||
</QTooltip> | ||
</template> | ||
</QBtnToggle> | ||
</BaseCell> | ||
</template> | ||
|
||
<script setup lang="ts" generic="T"> | ||
import { computed } from "vue"; | ||
import BaseCell, { Props as BaseCellProps } from "./BaseCell.vue"; | ||
|
||
const props = defineProps< | ||
BaseCellProps & { | ||
modelValue: T; | ||
// eslint-disable-next-line vue/prop-name-casing | ||
"onUpdate:modelValue"?: (value: T) => void; | ||
options: { label: string; value: T; description?: string }[]; | ||
disable?: boolean; | ||
} | ||
>(); | ||
|
||
/** QBtnToggle用のoptions */ | ||
const optionsForQBtnToggle = computed(() => | ||
props.options.map((option) => ({ | ||
label: option.label, | ||
value: option.value, | ||
slot: option.label, | ||
})), | ||
); | ||
</script> |
Oops, something went wrong.