2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
|
|
|
<div
|
2022-01-02 21:35:23 +09:00
|
|
|
v-adaptive-border
|
2020-01-30 04:37:25 +09:00
|
|
|
class="novjtctn"
|
|
|
|
:class="{ disabled, checked }"
|
|
|
|
:aria-checked="checked"
|
|
|
|
:aria-disabled="disabled"
|
|
|
|
@click="toggle"
|
|
|
|
>
|
2022-06-28 18:09:42 +09:00
|
|
|
<input
|
|
|
|
type="radio"
|
2020-01-30 04:37:25 +09:00
|
|
|
:disabled="disabled"
|
|
|
|
>
|
|
|
|
<span class="button">
|
|
|
|
<span></span>
|
|
|
|
</span>
|
|
|
|
<span class="label"><slot></slot></span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
|
|
|
|
export default defineComponent({
|
2020-01-30 04:37:25 +09:00
|
|
|
props: {
|
2020-10-17 20:12:00 +09:00
|
|
|
modelValue: {
|
2022-06-28 18:09:42 +09:00
|
|
|
required: false,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
value: {
|
2022-06-28 18:09:42 +09:00
|
|
|
required: false,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
2022-06-28 18:09:42 +09:00
|
|
|
default: false,
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
checked(): boolean {
|
2020-10-17 20:12:00 +09:00
|
|
|
return this.modelValue === this.value;
|
2022-06-28 18:09:42 +09:00
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggle() {
|
2020-08-01 10:53:23 +09:00
|
|
|
if (this.disabled) return;
|
2020-10-17 20:12:00 +09:00
|
|
|
this.$emit('update:modelValue', this.value);
|
2022-06-28 18:09:42 +09:00
|
|
|
},
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.novjtctn {
|
2020-10-17 20:12:00 +09:00
|
|
|
position: relative;
|
2020-01-30 04:37:25 +09:00
|
|
|
display: inline-block;
|
2020-10-27 18:11:41 +09:00
|
|
|
text-align: left;
|
2020-01-30 04:37:25 +09:00
|
|
|
cursor: pointer;
|
2022-06-28 18:09:42 +09:00
|
|
|
padding: 9px 12px;
|
2022-06-28 22:32:01 +09:00
|
|
|
min-width: 60px;
|
2022-01-02 21:35:23 +09:00
|
|
|
background-color: var(--panel);
|
|
|
|
background-clip: padding-box !important;
|
|
|
|
border: solid 1px var(--panel);
|
2021-11-28 20:07:37 +09:00
|
|
|
border-radius: 6px;
|
2020-01-30 04:37:25 +09:00
|
|
|
transition: all 0.3s;
|
|
|
|
|
|
|
|
> * {
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.disabled {
|
|
|
|
opacity: 0.6;
|
2020-08-01 10:53:23 +09:00
|
|
|
|
|
|
|
&, * {
|
|
|
|
cursor: not-allowed !important;
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
|
2022-01-02 21:35:23 +09:00
|
|
|
&:hover {
|
|
|
|
border-color: var(--inputBorderHover) !important;
|
|
|
|
}
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
&.checked {
|
2022-01-02 21:35:23 +09:00
|
|
|
background-color: var(--accentedBg) !important;
|
|
|
|
border-color: var(--accentedBg) !important;
|
2021-11-28 20:07:37 +09:00
|
|
|
color: var(--accent);
|
|
|
|
|
|
|
|
&, * {
|
|
|
|
cursor: default !important;
|
|
|
|
}
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
> .button {
|
2020-01-31 15:50:46 +09:00
|
|
|
border-color: var(--accent);
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
&:after {
|
2020-01-31 15:50:46 +09:00
|
|
|
background-color: var(--accent);
|
2020-01-30 04:37:25 +09:00
|
|
|
transform: scale(1);
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> input {
|
|
|
|
position: absolute;
|
|
|
|
width: 0;
|
|
|
|
height: 0;
|
|
|
|
opacity: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .button {
|
|
|
|
position: absolute;
|
2021-11-28 20:07:37 +09:00
|
|
|
width: 14px;
|
|
|
|
height: 14px;
|
2020-01-30 04:37:25 +09:00
|
|
|
background: none;
|
2020-02-01 11:44:31 +09:00
|
|
|
border: solid 2px var(--inputBorder);
|
2020-01-30 04:37:25 +09:00
|
|
|
border-radius: 100%;
|
|
|
|
transition: inherit;
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: '';
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
top: 3px;
|
|
|
|
right: 3px;
|
|
|
|
bottom: 3px;
|
|
|
|
left: 3px;
|
|
|
|
border-radius: 100%;
|
|
|
|
opacity: 0;
|
|
|
|
transform: scale(0);
|
|
|
|
transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .label {
|
|
|
|
margin-left: 28px;
|
|
|
|
display: block;
|
|
|
|
line-height: 20px;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|