theme-simple search

This commit is contained in:
tangly1024
2023-03-08 22:28:12 +08:00
parent 29fe28a66a
commit 147c92b3fb
4 changed files with 27 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global'
import { useState } from 'react'
import CONFIG_SIMPLE from '../config_simple'
import { DropMenu } from './DropMenu'
@@ -10,6 +11,12 @@ import { DropMenu } from './DropMenu'
*/
export const Nav = ({ customNav, customMenu }) => {
const { locale } = useGlobal()
const [showSearchInput, changeShowSearchInput] = useState(false)
const toggleShowSearchInput = () => {
changeShowSearchInput(!showSearchInput)
}
let links = [
{ icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: CONFIG_SIMPLE.MENU_SEARCH },
{ icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG_SIMPLE.MENU_ARCHIVE },
@@ -31,9 +38,10 @@ export const Nav = ({ customNav, customMenu }) => {
return (
<nav className="w-full bg-white md:pt-0 px-6 relative z-20 shadow-md border-t border-gray-100 dark:border-hexo-black-gray dark:bg-black">
<div className="container mx-auto max-w-8xl md:flex justify-between items-center text-sm md:text-md md:justify-start">
<div className="w-full text-center md:text-left flex flex-wrap justify-center items-stretch md:justify-start md:items-start py-4 space-x-4">
<div className="w-full h-12 text-center md:text-left flex flex-wrap justify-center items-stretch md:justify-start md:items-start space-x-4">
{showSearchInput && <input className='h-full px-4 w-full' aria-label="Submit search" type="search" name="s" autoComplete="off" placeholder="Type then hit enter to search..."/>}
{links?.map(link => {
{!showSearchInput && links?.map(link => {
if (link?.show) {
return <DropMenu key={link.id} link={link}/>
} else {
@@ -41,9 +49,10 @@ export const Nav = ({ customNav, customMenu }) => {
}
})}
</div>
<div className="w-full md:w-1/3 text-center md:text-right">
<div className="w-full md:w-1/3 text-center md:text-right hidden md:block">
{/* <!-- extra links --> */}
<i className='fa'></i>
<i className="fa-solid fa-magnifying-glass cursor-pointer" onClick={toggleShowSearchInput}></i>
</div>
</div>
</nav>