2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-05-17 05:31:13 +02:00
|
|
|
<label v-adaptive-border class="novjtctn" :class="{ disabled, checked }">
|
|
|
|
<input
|
2023-05-15 22:19:33 +02:00
|
|
|
type="radio"
|
|
|
|
:disabled="disabled"
|
|
|
|
:checked="checked"
|
|
|
|
v-on:change="(x) => toggle(x)"
|
|
|
|
/>
|
2023-04-08 02:01:42 +02:00
|
|
|
<span class="button">
|
|
|
|
<span></span>
|
|
|
|
</span>
|
|
|
|
<span class="label"><slot></slot></span>
|
2023-05-15 22:19:33 +02:00
|
|
|
</label>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-07-20 12:59:50 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import {} from "vue";
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-07-20 12:59:50 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
modelValue: any;
|
|
|
|
value: any;
|
|
|
|
disabled: boolean;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "update:modelValue", value: any): void;
|
2022-07-20 12:59:50 +02:00
|
|
|
}>();
|
|
|
|
|
|
|
|
let checked = $computed(() => props.modelValue === props.value);
|
|
|
|
|
2023-05-15 22:19:33 +02:00
|
|
|
function toggle(x) {
|
2022-07-20 12:59:50 +02:00
|
|
|
if (props.disabled) return;
|
2023-04-08 02:01:42 +02:00
|
|
|
emit("update:modelValue", props.value);
|
2022-07-20 12:59:50 +02:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.novjtctn {
|
2020-10-17 13:12:00 +02:00
|
|
|
position: relative;
|
2020-01-29 20:37:25 +01:00
|
|
|
display: inline-block;
|
2020-10-27 10:11:41 +01:00
|
|
|
text-align: left;
|
2020-01-29 20:37:25 +01:00
|
|
|
cursor: pointer;
|
2022-07-20 12:59:50 +02:00
|
|
|
padding: 8px 10px;
|
2022-06-28 15:32:01 +02:00
|
|
|
min-width: 60px;
|
2022-01-02 13:35:23 +01:00
|
|
|
background-color: var(--panel);
|
|
|
|
background-clip: padding-box !important;
|
|
|
|
border: solid 1px var(--panel);
|
2021-11-28 12:07:37 +01:00
|
|
|
border-radius: 6px;
|
2022-07-20 12:59:50 +02:00
|
|
|
transition: all 0.2s;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
> * {
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.disabled {
|
|
|
|
opacity: 0.6;
|
2020-08-01 03:53:23 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
&,
|
|
|
|
* {
|
2020-08-01 03:53:23 +02:00
|
|
|
cursor: not-allowed !important;
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
|
2022-01-02 13:35:23 +01:00
|
|
|
&:hover {
|
|
|
|
border-color: var(--inputBorderHover) !important;
|
|
|
|
}
|
2023-02-06 21:52:00 +01:00
|
|
|
&:focus-within {
|
|
|
|
outline: auto;
|
|
|
|
}
|
2022-01-02 13:35:23 +01:00
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
&.checked {
|
2022-01-02 13:35:23 +01:00
|
|
|
background-color: var(--accentedBg) !important;
|
|
|
|
border-color: var(--accentedBg) !important;
|
2021-11-28 12:07:37 +01:00
|
|
|
color: var(--accent);
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
&,
|
|
|
|
* {
|
2021-11-28 12:07:37 +01:00
|
|
|
cursor: default !important;
|
|
|
|
}
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
> .button {
|
2020-01-31 07:50:46 +01:00
|
|
|
border-color: var(--accent);
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
&:after {
|
2020-01-31 07:50:46 +01:00
|
|
|
background-color: var(--accent);
|
2020-01-29 20:37:25 +01:00
|
|
|
transform: scale(1);
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> input {
|
|
|
|
position: absolute;
|
2023-05-15 22:19:33 +02:00
|
|
|
width: 18px;
|
|
|
|
height: 18px;
|
2020-01-29 20:37:25 +01:00
|
|
|
opacity: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .button {
|
|
|
|
position: absolute;
|
2021-11-28 12:07:37 +01:00
|
|
|
width: 14px;
|
|
|
|
height: 14px;
|
2020-01-29 20:37:25 +01:00
|
|
|
background: none;
|
2020-02-01 03:44:31 +01:00
|
|
|
border: solid 2px var(--inputBorder);
|
2020-01-29 20:37:25 +01:00
|
|
|
border-radius: 100%;
|
|
|
|
transition: inherit;
|
2023-05-15 22:19:33 +02:00
|
|
|
pointer-events: none;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
&:after {
|
2023-04-08 02:01:42 +02:00
|
|
|
content: "";
|
2020-01-29 20:37:25 +01:00
|
|
|
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>
|