2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
|
|
|
<div
|
2022-01-02 12:35:23 +00:00
|
|
|
v-adaptive-border
|
2023-05-10 08:49:30 +00:00
|
|
|
:class="[$style.root, { [$style.disabled]: disabled, [$style.checked]: checked }]"
|
2020-01-29 19:37:25 +00:00
|
|
|
:aria-checked="checked"
|
|
|
|
:aria-disabled="disabled"
|
|
|
|
@click="toggle"
|
|
|
|
>
|
2022-06-28 09:09:42 +00:00
|
|
|
<input
|
|
|
|
type="radio"
|
2020-01-29 19:37:25 +00:00
|
|
|
:disabled="disabled"
|
2023-05-10 08:49:30 +00:00
|
|
|
:class="$style.input"
|
2020-01-29 19:37:25 +00:00
|
|
|
>
|
2023-05-10 08:49:30 +00:00
|
|
|
<span :class="$style.button">
|
2020-01-29 19:37:25 +00:00
|
|
|
<span></span>
|
|
|
|
</span>
|
2023-05-10 08:49:30 +00:00
|
|
|
<span :class="$style.label"><slot></slot></span>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-07-20 10:59:50 +00:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 05:42:09 +00:00
|
|
|
import { computed } from 'vue';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-07-20 10:59:50 +00:00
|
|
|
const props = defineProps<{
|
|
|
|
modelValue: any;
|
|
|
|
value: any;
|
2023-04-15 12:35:19 +00:00
|
|
|
disabled?: boolean;
|
2022-07-20 10:59:50 +00:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'update:modelValue', value: any): void;
|
|
|
|
}>();
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const checked = computed(() => props.modelValue === props.value);
|
2022-07-20 10:59:50 +00:00
|
|
|
|
|
|
|
function toggle(): void {
|
|
|
|
if (props.disabled) return;
|
|
|
|
emit('update:modelValue', props.value);
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
</script>
|
|
|
|
|
2023-05-10 08:49:30 +00:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-10-17 11:12:00 +00:00
|
|
|
position: relative;
|
2020-01-29 19:37:25 +00:00
|
|
|
display: inline-block;
|
2020-10-27 09:11:41 +00:00
|
|
|
text-align: left;
|
2020-01-29 19:37:25 +00:00
|
|
|
cursor: pointer;
|
2022-12-19 10:01:30 +00:00
|
|
|
padding: 7px 10px;
|
2022-06-28 13:32:01 +00:00
|
|
|
min-width: 60px;
|
2022-01-02 12:35:23 +00:00
|
|
|
background-color: var(--panel);
|
|
|
|
background-clip: padding-box !important;
|
|
|
|
border: solid 1px var(--panel);
|
2023-10-31 18:44:34 +00:00
|
|
|
border-radius: var(--radius-sm);
|
2022-12-19 10:01:30 +00:00
|
|
|
font-size: 90%;
|
2022-07-20 10:59:50 +00:00
|
|
|
transition: all 0.2s;
|
2023-05-10 08:49:30 +00:00
|
|
|
user-select: none;
|
2020-01-29 19:37:25 +00:00
|
|
|
|
|
|
|
&.disabled {
|
|
|
|
opacity: 0.6;
|
2023-05-10 08:49:30 +00:00
|
|
|
cursor: not-allowed !important;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
2022-01-02 12:35:23 +00:00
|
|
|
&:hover {
|
|
|
|
border-color: var(--inputBorderHover) !important;
|
|
|
|
}
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
&.checked {
|
2022-01-02 12:35:23 +00:00
|
|
|
background-color: var(--accentedBg) !important;
|
|
|
|
border-color: var(--accentedBg) !important;
|
2021-11-28 11:07:37 +00:00
|
|
|
color: var(--accent);
|
2023-05-10 08:49:30 +00:00
|
|
|
cursor: default !important;
|
2021-11-28 11:07:37 +00:00
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
> .button {
|
2020-01-31 06:50:46 +00:00
|
|
|
border-color: var(--accent);
|
2020-01-29 19:37:25 +00:00
|
|
|
|
|
|
|
&:after {
|
2020-01-31 06:50:46 +00:00
|
|
|
background-color: var(--accent);
|
2020-01-29 19:37:25 +00:00
|
|
|
transform: scale(1);
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-10 08:49:30 +00:00
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-05-10 08:49:30 +00:00
|
|
|
.input {
|
|
|
|
position: absolute;
|
|
|
|
width: 0;
|
|
|
|
height: 0;
|
|
|
|
opacity: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-05-10 08:49:30 +00:00
|
|
|
.button {
|
|
|
|
position: absolute;
|
|
|
|
width: 14px;
|
|
|
|
height: 14px;
|
|
|
|
background: none;
|
|
|
|
border: solid 2px var(--inputBorder);
|
2023-10-31 18:44:34 +00:00
|
|
|
border-radius: var(--radius-full);
|
2023-05-10 08:49:30 +00:00
|
|
|
transition: inherit;
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: '';
|
|
|
|
display: block;
|
2020-01-29 19:37:25 +00:00
|
|
|
position: absolute;
|
2023-05-10 08:49:30 +00:00
|
|
|
top: 3px;
|
|
|
|
right: 3px;
|
|
|
|
bottom: 3px;
|
|
|
|
left: 3px;
|
2023-10-31 18:44:34 +00:00
|
|
|
border-radius: var(--radius-full);
|
2023-05-10 08:49:30 +00:00
|
|
|
opacity: 0;
|
|
|
|
transform: scale(0);
|
|
|
|
transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
2023-05-10 08:49:30 +00:00
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-05-10 08:49:30 +00:00
|
|
|
.label {
|
|
|
|
margin-left: 28px;
|
|
|
|
display: block;
|
|
|
|
line-height: 20px;
|
|
|
|
cursor: pointer;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
</style>
|