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

@@ -38,7 +38,7 @@ const LayoutBase = props => {
{/* <Title {...props} /> */}
<div className={(BLOG.LAYOUT_SIDEBAR_REVERSE ? 'flex-row-reverse' : '') + 'w-full relative container mx-auto justify-start md:flex items-start pt-12 px-2'}>
<div className={(BLOG.LAYOUT_SIDEBAR_REVERSE ? 'flex-row-reverse' : '') + ' w-full relative container mx-auto justify-start md:flex items-start pt-12 px-2'}>
<div className='w-full max-w-6xl'>{children}</div>

View File

@@ -5,10 +5,7 @@ export const DropMenu = ({ link }) => {
const [show, changeShow] = useState(false)
const hasSubMenu = link?.subMenus?.length > 0
return <div
onMouseOver={() => changeShow(true)}
onMouseOut={() => changeShow(false)}
>
return <div className='pt-3' onMouseOver={() => changeShow(true)} onMouseOut={() => changeShow(false)} >
<Link
href={link?.to}
className="font-sans menu-link pl-2 pr-4 text-gray-700 dark:text-gray-200 no-underline tracking-widest pb-1">
@@ -20,10 +17,10 @@ export const DropMenu = ({ link }) => {
{hasSubMenu && <ul className={`${show ? 'visible opacity-100' : 'invisible opacity-0'} border-gray-100 bg-white dark:bg-black dark:border-gray-800 transition-all duration-300 z-20 top-12 absolute block border drop-shadow-lg `}>
{link.subMenus.map(sLink => {
return <li key={sLink.id} className=' text-blue-400 hover:bg-gray-50 dark:hover:bg-gray-900 tracking-widest transition-all duration-200 border-b dark:border-gray-800 py-3 pr-6 pl-2'>
<Link href={sLink.to}>
<span className='text-xs'>{sLink.title}</span>
</Link>
</li>
<Link href={sLink.to}>
<span className='text-xs'>{sLink.title}</span>
</Link>
</li>
})}
</ul>}
</div>

View File

@@ -16,17 +16,20 @@ export const Header = (props) => {
{/* 可使用一张单图作为logo */}
{/* eslint-disable-next-line @next/next/no-img-element */}
{/* <img className='max-h-48 hover:opacity-60 duration-200 transition-all cursor-pointer' src={CONFIG_SIMPLE.LOGO_IMG}/> */}
<div>
<div className='flex space-x-12'>
<div className='hover:rotate-45 hover:scale-125 transform duration-200 cursor-pointer'>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={siteInfo?.icon} className='rounded-full' width={120} alt={BLOG.AUTHOR} />
</div>
<div className='text-2xl font-serif dark:text-white py-2 hover:scale-105 transform duration-200'>{BLOG.AUTHOR}</div>
<div className='font-light dark:text-white py-2 hover:scale-105 transform duration-200 text-center'>{BLOG.BIO}</div>
</div>
<div>
<div className='text-2xl font-serif dark:text-white py-2 hover:scale-105 transform duration-200'>{BLOG.AUTHOR}</div>
<div className='font-light dark:text-white py-2 hover:scale-105 transform duration-200 text-center'>{BLOG.BIO}</div>
</div>
</div>
</Link>
<div className='text-xs text-gray-500 dark:text-gray-300'>{siteInfo?.description}</div>
<div className='text-xs mt-4 text-gray-500 dark:text-gray-300'>{siteInfo?.description}</div>
</div>
</header>
)

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>