-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Vision): Add new vision-blocking mode: Behind
- Loading branch information
Showing
41 changed files
with
514 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<script setup lang="ts" generic="T, MS extends boolean"> | ||
import { computed } from "vue"; | ||
const props = withDefaults( | ||
defineProps<{ | ||
// data | ||
options: readonly { label: string; value: T }[]; | ||
modelValue: MS extends true ? T[] : T; | ||
// styles | ||
id?: string; | ||
activeColor?: string; | ||
color?: string; | ||
disabled?: boolean; | ||
multiSelect: MS; | ||
}>(), | ||
{ | ||
id: undefined, | ||
color: "rgba(236, 242, 255, 0.25)", | ||
activeColor: "rgba(236, 242, 255, 1)", | ||
disabled: false, | ||
}, | ||
); | ||
const emit = defineEmits<(e: "update:modelValue", s: MS extends true ? T[] : T) => void>(); | ||
const data = computed(() => (props.multiSelect ? props.modelValue : [props.modelValue]) as T[]); | ||
function toggle(option: T): void { | ||
if (props.disabled) return; | ||
let data: MS extends true ? T[] : T; | ||
if (props.multiSelect) { | ||
const arr = props.modelValue as T[]; | ||
if (arr.includes(option)) { | ||
data = arr.filter((d) => d !== option) as MS extends true ? T[] : T; | ||
} else { | ||
data = [...arr, option] as MS extends true ? T[] : T; | ||
} | ||
} else { | ||
// idk eslint and typescript are not agreeing with eachother | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
data = option as MS extends true ? T[] : T; | ||
} | ||
emit("update:modelValue", data); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div :id="id" class="toggle-group" :class="{ disabled }"> | ||
<div | ||
v-for="option of options" | ||
:key="option.label" | ||
:class="{ selected: data.includes(option.value) }" | ||
@click="toggle(option.value)" | ||
> | ||
{{ option.label }} | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.toggle-group { | ||
display: flex; | ||
align-items: stretch; | ||
flex-wrap: wrap; | ||
width: fit-content; | ||
overflow: hidden; | ||
border-radius: 1rem; | ||
background-color: v-bind("color"); | ||
border: solid 2px v-bind("activeColor"); | ||
> div { | ||
padding: 0.5rem 0.7rem; | ||
display: flex; | ||
align-items: center; | ||
&:hover { | ||
cursor: pointer; | ||
background-color: v-bind("activeColor"); | ||
} | ||
&.selected { | ||
background-color: v-bind("activeColor"); | ||
} | ||
} | ||
&.disabled > { | ||
div:hover { | ||
cursor: not-allowed; | ||
} | ||
:not(.selected):hover { | ||
background-color: inherit; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.