2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
|
|
|
<div
|
2022-01-02 13:35:23 +01:00
|
|
|
v-adaptive-border
|
2023-09-23 02:01:20 +02:00
|
|
|
:class="[$style.root, { [$style.disabled]: disabled, [$style.checked]: checked ,[$style.gamingDark]: gaming === 'dark',[$style.gamingLight]: gaming === 'light' } ]"
|
2020-01-29 20:37:25 +01:00
|
|
|
:aria-checked="checked"
|
|
|
|
:aria-disabled="disabled"
|
|
|
|
@click="toggle"
|
|
|
|
>
|
2022-06-28 11:09:42 +02:00
|
|
|
<input
|
|
|
|
type="radio"
|
2020-01-29 20:37:25 +01:00
|
|
|
:disabled="disabled"
|
2023-05-10 10:49:30 +02:00
|
|
|
:class="$style.input"
|
2020-01-29 20:37:25 +01:00
|
|
|
>
|
2023-09-23 02:01:20 +02:00
|
|
|
<span :class="[$style.button , {[$style.gamingDark]: gaming === 'dark',[$style.gamingLight]: gaming === 'light'}]">
|
2020-01-29 20:37:25 +01:00
|
|
|
<span></span>
|
|
|
|
</span>
|
2023-05-10 10:49:30 +02:00
|
|
|
<span :class="$style.label"><slot></slot></span>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-07-20 12:59:50 +02:00
|
|
|
<script lang="ts" setup>
|
2023-09-23 02:01:20 +02:00
|
|
|
import { ref,computed,watch } from 'vue';
|
|
|
|
import {defaultStore} from "@/store.js";
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2023-09-23 02:01:20 +02:00
|
|
|
let gaming = ref('');
|
|
|
|
|
|
|
|
const gamingMode = computed(defaultStore.makeGetterSetter('gamingMode'));
|
|
|
|
const darkMode = computed(defaultStore.makeGetterSetter('darkMode'));
|
|
|
|
if (darkMode.value && gamingMode.value == true) {
|
|
|
|
gaming.value = 'dark';
|
|
|
|
} else if (!darkMode.value && gamingMode.value == true) {
|
|
|
|
gaming.value = 'light';
|
|
|
|
} else {
|
|
|
|
gaming.value = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
watch(darkMode, () => {
|
|
|
|
if (darkMode.value && gamingMode.value == true) {
|
|
|
|
gaming.value = 'dark';
|
|
|
|
} else if (!darkMode.value && gamingMode.value == true) {
|
|
|
|
gaming.value = 'light';
|
|
|
|
} else {
|
|
|
|
gaming.value = '';
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
watch(gamingMode, () => {
|
|
|
|
if (darkMode.value && gamingMode.value == true) {
|
|
|
|
gaming.value = 'dark';
|
|
|
|
} else if (!darkMode.value && gamingMode.value == true) {
|
|
|
|
gaming.value = 'light';
|
|
|
|
} else {
|
|
|
|
gaming.value = '';
|
|
|
|
}
|
|
|
|
})
|
2022-07-20 12:59:50 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
modelValue: any;
|
|
|
|
value: any;
|
2023-04-15 14:35:19 +02:00
|
|
|
disabled?: boolean;
|
2022-07-20 12:59:50 +02:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'update:modelValue', value: any): void;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let checked = $computed(() => props.modelValue === props.value);
|
|
|
|
|
|
|
|
function toggle(): void {
|
|
|
|
if (props.disabled) return;
|
|
|
|
emit('update:modelValue', props.value);
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
2023-05-10 10:49:30 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
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-12-19 11:01:30 +01:00
|
|
|
padding: 7px 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-12-19 11:01:30 +01:00
|
|
|
font-size: 90%;
|
2022-07-20 12:59:50 +02:00
|
|
|
transition: all 0.2s;
|
2023-05-10 10:49:30 +02:00
|
|
|
user-select: none;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
&.disabled {
|
|
|
|
opacity: 0.6;
|
2023-05-10 10:49:30 +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;
|
|
|
|
}
|
|
|
|
|
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-05-10 10:49:30 +02:00
|
|
|
cursor: default !important;
|
2023-09-23 02:01:20 +02:00
|
|
|
&.gamingDark{
|
|
|
|
color:black !important;
|
|
|
|
border-color: black !important;
|
|
|
|
background: linear-gradient(270deg, #e7a2a2, #e3cfa2, #ebefa1, #b3e7a6, #a6ebe7, #aec5e3, #cabded, #e0b9e3, #f4bddd);
|
|
|
|
background-size: 1800% 1800%;
|
|
|
|
-webkit-animation: AnimationDark 44s cubic-bezier(0, 0.25, 0.25, 1) infinite;
|
|
|
|
-moz-animation: AnimationDark 44s cubic-bezier(0, 0.25, 0.25, 1) infinite;
|
|
|
|
animation: AnimationDark 44s cubic-bezier(0, 0.25, 0.25, 1) infinite;
|
|
|
|
}
|
|
|
|
&.gamingLight{
|
|
|
|
color:white;
|
|
|
|
border-color: white !important;
|
|
|
|
background: linear-gradient(270deg, #c06161, #c0a567, #b6ba69, #81bc72, #63c3be, #8bacd6, #9f8bd6, #d18bd6, #d883b4); background-size: 1800% 1800% !important;
|
|
|
|
-webkit-animation: AnimationLight 45s cubic-bezier(0, 0.25, 0.25, 1) infinite !important;
|
|
|
|
-moz-animation: AnimationLight 45s cubic-bezier(0, 0.25, 0.25, 1) infinite !important;
|
|
|
|
animation: AnimationLight 45s cubic-bezier(0, 0.25, 0.25, 1) infinite !important;
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
> .button {
|
2020-01-31 07:50:46 +01:00
|
|
|
border-color: var(--accent);
|
2023-09-23 02:01:20 +02:00
|
|
|
&.gamingDark{
|
|
|
|
border-color:black;
|
|
|
|
color:black !important;
|
|
|
|
}
|
|
|
|
&.gamingLight{
|
|
|
|
border-color: white;
|
|
|
|
color:white;
|
|
|
|
}
|
|
|
|
&.gamingDark:after{
|
|
|
|
background-color: black;
|
|
|
|
transform: scale(1);
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
&.gamingLight:after{
|
|
|
|
background-color:white !important;
|
|
|
|
transform: scale(1);
|
|
|
|
opacity: 1;
|
|
|
|
}
|
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;
|
2023-09-23 02:01:20 +02:00
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-10 10:49:30 +02:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-05-10 10:49:30 +02:00
|
|
|
.input {
|
|
|
|
position: absolute;
|
|
|
|
width: 0;
|
|
|
|
height: 0;
|
|
|
|
opacity: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-05-10 10:49:30 +02:00
|
|
|
.button {
|
|
|
|
position: absolute;
|
|
|
|
width: 14px;
|
|
|
|
height: 14px;
|
|
|
|
background: none;
|
|
|
|
border: solid 2px var(--inputBorder);
|
|
|
|
border-radius: 100%;
|
|
|
|
transition: inherit;
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: '';
|
|
|
|
display: block;
|
2020-01-29 20:37:25 +01:00
|
|
|
position: absolute;
|
2023-05-10 10:49:30 +02:00
|
|
|
top: 3px;
|
|
|
|
right: 3px;
|
|
|
|
bottom: 3px;
|
|
|
|
left: 3px;
|
2020-01-29 20:37:25 +01:00
|
|
|
border-radius: 100%;
|
2023-05-10 10:49:30 +02:00
|
|
|
opacity: 0;
|
|
|
|
transform: scale(0);
|
|
|
|
transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2023-05-10 10:49:30 +02:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-05-10 10:49:30 +02:00
|
|
|
.label {
|
|
|
|
margin-left: 28px;
|
|
|
|
display: block;
|
|
|
|
line-height: 20px;
|
|
|
|
cursor: pointer;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2023-09-23 02:01:20 +02:00
|
|
|
@-webkit-keyframes AnimationLight {
|
|
|
|
0% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
50% {
|
|
|
|
background-position: 100% 50%
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@-moz-keyframes AnimationLight {
|
|
|
|
0% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
50% {
|
|
|
|
background-position: 100% 50%
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
} @keyframes AnimationLight {
|
|
|
|
0% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
50% {
|
|
|
|
background-position: 100% 50%
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@-webkit-keyframes AnimationDark {
|
|
|
|
0% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
50% {
|
|
|
|
background-position: 100% 50%
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@-moz-keyframes AnimationDark {
|
|
|
|
0% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
50% {
|
|
|
|
background-position: 100% 50%
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@keyframes AnimationDark {
|
|
|
|
0% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
50% {
|
|
|
|
background-position: 100% 50%
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
background-position: 0% 50%
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
</style>
|