Files
Graphite/frontend/src/components/widgets/inputs/CheckboxInput.vue
Keavon Chambers 7e0cbb60b4 Major frontend code cleanup (#452)
Many large changes, including:
- TypeScript enums are now string unions throughout
- Strong type-checking throughout the TS and Vue codebase
- Vue component props now all specify `as PropType<...>`
- Usage of annotated return types on all functions
- Sorting of JS import statements
- Explicit usage of Vue bind attribute function call arguments (`@click="foo"` is now `@click=(e) => foo(e)`)
- Much improved code quality related to the color picker
- Consistent camelCase Vue bind and v-model attributes
- Consistent Vue HTML attribute strings with single quotes
- Bug fix and clarity improvement with incorrect hint class parameters
- Empty Vue component objects like `props: {}` and `components: {}` removed
2022-01-02 06:00:02 -08:00

106 lines
1.9 KiB
Vue

<template>
<div class="checkbox-input" :class="{ 'outline-style': outlineStyle }">
<input type="checkbox" :id="`checkbox-input-${id}`" :checked="checked" @input="(e) => $emit('update:checked', e.target.checked)" />
<label :for="`checkbox-input-${id}`">
<div class="checkbox-box">
<IconLabel :icon="icon" />
</div>
</label>
</div>
</template>
<style lang="scss">
.checkbox-input {
display: inline-block;
input {
display: none;
}
label {
display: block;
.checkbox-box {
display: block;
background: var(--color-e-nearwhite);
padding: 2px;
border-radius: 2px;
.icon-label {
fill: var(--color-2-mildblack);
}
}
&:hover .checkbox-box {
background: var(--color-f-white);
}
}
input:checked + label {
.checkbox-box {
background: var(--color-accent);
.icon-label {
fill: var(--color-f-white);
}
}
&:hover .checkbox-box {
background: var(--color-accent-hover);
}
}
&.outline-style label {
.checkbox-box {
border: 1px solid var(--color-e-nearwhite);
padding: 1px;
background: none;
svg {
display: none;
}
}
&:hover .checkbox-box {
border: 1px solid var(--color-f-white);
}
}
&.outline-style input:checked + label {
.checkbox-box {
background: none;
svg {
display: block;
fill: var(--color-e-nearwhite);
}
}
}
}
</style>
<script lang="ts">
import { defineComponent, PropType } from "vue";
import IconLabel, { IconName } from "@/components/widgets/labels/IconLabel.vue";
export default defineComponent({
data() {
return {
id: `${Math.random()}`.substring(2),
};
},
methods: {
isChecked() {
return this.checked;
},
},
props: {
checked: { type: Boolean as PropType<boolean>, required: true },
icon: { type: String as PropType<IconName>, default: "Checkmark" },
outlineStyle: { type: Boolean as PropType<boolean>, default: false },
},
components: { IconLabel },
});
</script>