refactor(frontend): use css module

This commit is contained in:
syuilo 2023-05-10 17:49:30 +09:00
parent 02059fdee4
commit f9f115b66d

View File

@ -1,8 +1,7 @@
<template> <template>
<div <div
v-adaptive-border v-adaptive-border
class="novjtctn" :class="[$style.root, { [$style.disabled]: disabled, [$style.checked]: checked }]"
:class="{ disabled, checked }"
:aria-checked="checked" :aria-checked="checked"
:aria-disabled="disabled" :aria-disabled="disabled"
@click="toggle" @click="toggle"
@ -10,11 +9,12 @@
<input <input
type="radio" type="radio"
:disabled="disabled" :disabled="disabled"
:class="$style.input"
> >
<span class="button"> <span :class="$style.button">
<span></span> <span></span>
</span> </span>
<span class="label"><slot></slot></span> <span :class="$style.label"><slot></slot></span>
</div> </div>
</template> </template>
@ -39,8 +39,8 @@ function toggle(): void {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.novjtctn { .root {
position: relative; position: relative;
display: inline-block; display: inline-block;
text-align: left; text-align: left;
@ -53,17 +53,11 @@ function toggle(): void {
border-radius: 6px; border-radius: 6px;
font-size: 90%; font-size: 90%;
transition: all 0.2s; transition: all 0.2s;
user-select: none;
> * {
user-select: none;
}
&.disabled { &.disabled {
opacity: 0.6; opacity: 0.6;
cursor: not-allowed !important;
&, * {
cursor: not-allowed !important;
}
} }
&:hover { &:hover {
@ -74,10 +68,7 @@ function toggle(): void {
background-color: var(--accentedBg) !important; background-color: var(--accentedBg) !important;
border-color: var(--accentedBg) !important; border-color: var(--accentedBg) !important;
color: var(--accent); color: var(--accent);
cursor: default !important;
&, * {
cursor: default !important;
}
> .button { > .button {
border-color: var(--accent); border-color: var(--accent);
@ -89,44 +80,44 @@ function toggle(): void {
} }
} }
} }
}
> input { .input {
position: absolute; position: absolute;
width: 0; width: 0;
height: 0; height: 0;
opacity: 0; opacity: 0;
margin: 0; margin: 0;
} }
> .button { .button {
position: absolute; position: absolute;
width: 14px; width: 14px;
height: 14px; height: 14px;
background: none; background: none;
border: solid 2px var(--inputBorder); border: solid 2px var(--inputBorder);
border-radius: 100%; border-radius: 100%;
transition: inherit; transition: inherit;
&:after { &:after {
content: ''; 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; display: block;
line-height: 20px; position: absolute;
cursor: pointer; 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> </style>