-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
518 additions
and
206 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<script setup lang="ts"> | ||
import { OnClickOutside } from '@vueuse/components'; | ||
import { useElementBounding, useWindowScroll } from '@vueuse/core'; | ||
const props = defineProps<{ | ||
items: { text: string, value: string; }[]; | ||
}>(); | ||
const model = defineModel(); | ||
const isOpen = ref(false); | ||
const dropdown = ref<HTMLElement | null>(null); | ||
const dropdownMenu = ref<HTMLElement | null>(null); | ||
const { x: dropdownX, y: dropdownY } = useElementBounding(dropdown); | ||
const { height: dropdownMenuHeight } = useElementBounding(dropdownMenu); | ||
const { x: windowX, y: windowY } = useWindowScroll(); | ||
const top = computed(() => { | ||
const MARGIN = 8; | ||
if (!isOpen.value) return 0; | ||
return windowY.value + dropdownY.value - dropdownMenuHeight.value - MARGIN; | ||
}); | ||
const left = computed(() => { | ||
if (!isOpen.value) return 0; | ||
return dropdownX.value + windowX.value; | ||
}); | ||
const toggleDropdown = () => { | ||
isOpen.value = !isOpen.value; | ||
}; | ||
const closeDropdown = (ev: any) => { | ||
const isDropdownButton = ev.target.closest('.dropdown-button'); | ||
if (isDropdownButton) return; | ||
isOpen.value = false; | ||
}; | ||
const selectItem = (item: string) => { | ||
console.log(item); | ||
model.value = item; | ||
isOpen.value = false; | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div class="relative" ref="dropdown" @click="toggleDropdown"> | ||
<div class="dropdown-button"> | ||
<slot name="trigger" :selected="model"></slot> | ||
</div> | ||
<Teleport to="#teleports"> | ||
<OnClickOutside @trigger="closeDropdown"> | ||
<div | ||
ref="dropdownMenu" | ||
class="absolute bg-white/50 rounded-md border border-white text-black backdrop-blur-sm shadow-lg z-50 flex flex-col" | ||
:class="{ | ||
'pointer-events-none invisible': !isOpen, | ||
}" | ||
:style="{ | ||
left: left + 'px', | ||
top: top + 'px', | ||
}" | ||
> | ||
<slot | ||
name="item" | ||
v-for="(item, index) in items" | ||
:key="index" | ||
:item="item" | ||
:onClick="selectItem" | ||
></slot> | ||
</div> | ||
</OnClickOutside> | ||
</Teleport> | ||
</div> | ||
</template> |
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,13 @@ | ||
<script setup lang="ts"> | ||
defineProps<{ | ||
class: string; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<button | ||
:class="`text-white text-shadow shadow shadow-black/70 border-2 rounded-md hover:bg-white/20 transition duration-300 ease-in-out ${$props.class}`" | ||
> | ||
<slot /> | ||
</button> | ||
</template> |
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,7 @@ | ||
<script setup lang="ts"> | ||
</script> | ||
|
||
<template> | ||
|
||
</template> |
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.