diff --git a/src/components/common/SearchDialog.vue b/src/components/common/SearchDialog.vue new file mode 100644 index 0000000..03e7a91 --- /dev/null +++ b/src/components/common/SearchDialog.vue @@ -0,0 +1,371 @@ + + + + + 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); }); diff --git a/src/css/sidebar.css b/src/css/sidebar.css index d79ad2f..357f157 100644 --- a/src/css/sidebar.css +++ b/src/css/sidebar.css @@ -380,11 +380,13 @@ align-items: center; gap: 0.25rem; font-size: 10px; - padding: 0 0.5rem; border-radius: 50px; background: #1a1a1a; color: #a6a6a6; border: 1px solid #333; + width: 20px; + height: 20px; + justify-content: center; } .star-count {