pleroma-fe/src/components/checkbox/checkbox.vue

106 行
2.0 KiB
Vue
Raw 通常表示 履歴

<template>
<label
class="checkbox"
:class="{ disabled, indeterminate }"
2019-10-29 16:35:42 +09:00
>
2019-07-05 16:17:44 +09:00
<input
type="checkbox"
class="visible-for-screenreader-only"
:disabled="disabled"
2022-03-24 20:41:52 +09:00
:checked="modelValue"
2022-03-17 15:35:19 +09:00
:indeterminate="indeterminate"
@change="$emit('update:modelValue', $event.target.checked)"
2019-07-05 16:17:44 +09:00
>
2023-01-29 12:10:06 +09:00
<i
class="checkbox-indicator"
:aria-hidden="true"
/>
<span
v-if="!!$slots.default"
2019-11-09 01:14:01 +09:00
class="label"
2019-10-29 16:35:42 +09:00
>
<slot />
</span>
</label>
</template>
2019-04-04 10:13:25 +09:00
<script>
export default {
props: [
'modelValue',
'indeterminate',
'disabled'
2022-07-31 18:35:48 +09:00
],
emits: ['update:modelValue']
}
</script>
<style lang="scss">
2023-01-10 03:02:16 +09:00
@import "../../variables";
2023-01-29 12:10:06 +09:00
@import "../../mixins";
2019-04-07 02:21:41 +09:00
2019-04-04 10:13:25 +09:00
.checkbox {
position: relative;
display: inline-block;
min-height: 1.2em;
2019-04-04 10:13:25 +09:00
&-indicator {
position: relative;
padding-left: 1.2em;
}
2019-04-04 10:13:25 +09:00
&-indicator::before {
position: absolute;
right: 0;
2019-04-04 10:13:25 +09:00
top: 0;
display: block;
2023-01-10 03:02:16 +09:00
content: "✓";
2019-04-04 10:13:25 +09:00
transition: color 200ms;
width: 1.1em;
height: 1.1em;
border-radius: $fallback--checkboxRadius;
border-radius: var(--checkboxRadius, $fallback--checkboxRadius);
2023-01-10 03:02:16 +09:00
box-shadow: 0 0 2px black inset;
2019-04-04 10:13:25 +09:00
box-shadow: var(--inputShadow);
background-color: $fallback--fg;
background-color: var(--input, $fallback--fg);
vertical-align: top;
text-align: center;
line-height: 1.1em;
font-size: 1.1em;
color: transparent;
overflow: hidden;
box-sizing: border-box;
}
&.disabled {
.checkbox-indicator::before,
.label {
2023-01-10 03:02:16 +09:00
opacity: 0.5;
}
2023-01-10 03:02:16 +09:00
.label {
color: $fallback--faint;
color: var(--faint, $fallback--faint);
}
}
2023-01-10 03:02:16 +09:00
input[type="checkbox"] {
2019-04-04 10:13:25 +09:00
&:checked + .checkbox-indicator::before {
color: $fallback--text;
color: var(--inputText, $fallback--text);
2019-04-04 10:13:25 +09:00
}
2019-04-07 02:45:28 +09:00
&:indeterminate + .checkbox-indicator::before {
2023-01-10 03:02:16 +09:00
content: "";
2019-04-07 02:45:28 +09:00
color: $fallback--text;
color: var(--inputText, $fallback--text);
2019-04-07 02:45:28 +09:00
}
2019-04-04 10:13:25 +09:00
}
& > span {
2023-01-10 03:02:16 +09:00
margin-left: 0.5em;
2019-04-04 10:13:25 +09:00
}
}
</style>