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

106 lines
2.0 KiB
Vue
Raw Normal View History

<template>
<label
class="checkbox"
:class="{ disabled, indeterminate }"
2019-10-29 08:35:42 +01:00
>
2019-07-05 09:17:44 +02:00
<input
type="checkbox"
:disabled="disabled"
2019-07-05 09:17:44 +02:00
:checked="checked"
:indeterminate.prop="indeterminate"
@change="$emit('change', $event.target.checked)"
>
<i class="checkbox-indicator" />
<span
v-if="!!$slots.default"
2019-11-08 17:14:01 +01:00
class="label"
2019-10-29 08:35:42 +01:00
>
<slot />
</span>
</label>
</template>
2019-04-04 03:13:25 +02:00
<script>
export default {
2019-04-06 19:24:28 +02:00
model: {
prop: 'checked',
event: 'change'
},
props: [
'checked',
'indeterminate',
'disabled'
]
}
</script>
<style lang="scss">
2019-04-06 19:21:41 +02:00
@import '../../_variables.scss';
2019-04-04 03:13:25 +02:00
.checkbox {
position: relative;
display: inline-block;
min-height: 1.2em;
2019-04-04 03:13:25 +02:00
&-indicator {
position: relative;
padding-left: 1.2em;
}
2019-04-04 03:13:25 +02:00
&-indicator::before {
position: absolute;
right: 0;
2019-04-04 03:13:25 +02:00
top: 0;
display: block;
content: '✔';
transition: color 200ms;
width: 1.1em;
height: 1.1em;
border-radius: $fallback--checkboxRadius;
border-radius: var(--checkboxRadius, $fallback--checkboxRadius);
box-shadow: 0px 0px 2px black inset;
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 {
opacity: .5;
}
.label {
color: $fallback--faint;
color: var(--faint, $fallback--faint);
}
}
2019-04-04 03:13:25 +02:00
input[type=checkbox] {
display: none;
&:checked + .checkbox-indicator::before {
color: $fallback--text;
color: var(--inputText, $fallback--text);
2019-04-04 03:13:25 +02:00
}
2019-04-06 19:45:28 +02:00
&:indeterminate + .checkbox-indicator::before {
content: '';
color: $fallback--text;
color: var(--inputText, $fallback--text);
2019-04-06 19:45:28 +02:00
}
2019-04-04 03:13:25 +02:00
}
& > span {
margin-left: .5em;
}
}
</style>