Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: SettingDialog.vueのボタントグルを共通化 #2111

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions src/components/Dialog/SettingDialog/ButtonToggleCell.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!-- 2種類以上のボタンから1つ選ぶ設定項目 -->

<template>
<BaseCell :title="title" :description="description">
<QBtnToggle
padding="xs md"
unelevated
color="background"
text-color="display"
toggle-color="primary"
toggle-text-color="display-on-primary"
:disable="disable"
:model-value="modelValue"
:options="optionsForQBtnToggle"
@update:model-value="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;
}
>();

const optionsForQBtnToggle = computed(() =>
props.options.map((option) => ({
label: option.label,
value: option.value,
slot: option.label,
})),
);
</script>
Loading
Loading