-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse handling of cell selection with BSSelection component
- Loading branch information
Showing
4 changed files
with
77 additions
and
53 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,61 @@ | ||
<template> | ||
<slot :selectable="{ | ||
[$style.selectable]: true, | ||
[$style.focused]: focused, | ||
}" /> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed, defineProps } from 'vue'; | ||
import { useEditorStore } from '@/stores/editor'; | ||
const props = defineProps<{ | ||
row: number; | ||
offset: number; | ||
length: number; | ||
}>(); | ||
const editorStore = useEditorStore(); | ||
const focused = computed(() => { | ||
const { selection } = editorStore; | ||
return ( | ||
typeof selection != 'undefined' && | ||
selection.row == props.row && | ||
selection.offset >= props.offset && | ||
selection.offset <= props.offset + props.length | ||
); | ||
}); | ||
</script> | ||
|
||
<style lang="scss" module> | ||
.selectable { | ||
position: relative; | ||
&::after { | ||
display: block; | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
background: #0099ff; | ||
opacity: 0; | ||
transition: opacity 200ms; | ||
} | ||
&:hover::after { | ||
opacity: 0.2; | ||
} | ||
&.focused::after { | ||
opacity: 0.3; | ||
} | ||
} | ||
</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