diff --git a/src/components/common/SearchDialog.vue b/src/components/common/SearchDialog.vue new file mode 100644 index 0000000..eadefcc --- /dev/null +++ b/src/components/common/SearchDialog.vue @@ -0,0 +1,337 @@ + + + + + \ No newline at end of file diff --git a/src/components/navs/Header.vue b/src/components/navs/Header.vue index e1f2663..bc0bed2 100644 --- a/src/components/navs/Header.vue +++ b/src/components/navs/Header.vue @@ -5,12 +5,27 @@ Logo - +
+ + + +
- + + +
+ @@ -88,9 +108,11 @@ import { CATEGORIES, NEW, UPDATED } from '../../constants/Categories'; import FadeContent from '../../content/Animations/FadeContent/FadeContent.vue'; import Logo from '../../assets/logos/vue-bits-logo.svg'; import Star from '../../assets/common/star.svg'; +import SearchDialog from '../common/SearchDialog.vue' const isDrawerOpen = ref(false); const isTransitioning = ref(false); +const isSearchOpen = ref(false) const stars = useStars(); const route = useRoute(); const router = useRouter(); @@ -132,6 +154,13 @@ const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape' && isDrawerOpen.value) { closeDrawer(); } + if (e.key === '/' && !isSearchOpen.value) { + e.preventDefault() + openSearch() + } + if (e.key === 'Escape' && isSearchOpen.value) { + closeSearch() + } }; const Category = defineComponent({ @@ -224,6 +253,14 @@ const Category = defineComponent({ } }); +const openSearch = () => { + isSearchOpen.value = true +} + +const closeSearch = () => { + isSearchOpen.value = false +} + onMounted(() => { document.addEventListener('keydown', handleKeyDown); });