| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- import { useCallback, useState } from "react";
- import clsx from "clsx";
- import Link from "next/link";
- import ClickAwayListener from "@mui/base/ClickAwayListener";
- export default function Header() {
- const [open, setOpen] = useState(false);
- const toggleMenu = useCallback(() => {
- setOpen((o) => !o);
- }, [setOpen]);
- const closeMenu = useCallback(() => {
- setOpen(false);
- }, [setOpen]);
- const toggleTheme = function () {
- const _html = document.documentElement;
- if (_html.classList.contains("dark")) {
- _html.classList.remove("dark");
- localStorage.setItem("theme", "lite");
- } else {
- _html.classList.add("dark");
- localStorage.setItem("theme", "dark");
- }
- };
- return (
- <header className={clsx("header", { open })}>
- <ClickAwayListener onClickAway={closeMenu}>
- <div className="container">
- <Link href="/">
- <a className="logo mr-5" title="NovelDit">
- {/* eslint-disable-next-line @next/next/no-img-element */}
- <img src="/logo.svg" alt="NovelDit" />
- <span>NovelDit</span>
- </a>
- </Link>
- <div className="menu">
- <nav>
- <ul>
- <li>
- <a className="menu-item" href="" title="Browse">
- <svg width="24" height="24">
- <use href="/icons.svg#browse"></use>
- </svg>
- <strong>Browse</strong>
- </a>
- <div className="sub-menu">
- <ul className="sub-menu-sized">
- <li>
- <a href="/stories/novel" title="Novels">
- Novels
- </a>
- <div className="sub-menu-list">
- <p>
- <strong>MALE LEAD</strong>
- <a href="/stories/novel-urban-male" title="Urban">
- Urban
- </a>
- <a
- href="/stories/novel-eastern-male"
- title="Eastern"
- >
- Eastern
- </a>
- <a href="/stories/novel-games-male" title="Games">
- Games
- </a>
- <a
- href="/stories/novel-fantasy-male"
- title="Fantasy"
- >
- Fantasy
- </a>
- <a href="/stories/novel-scifi-male" title="Sci-fi">
- Sci-fi
- </a>
- <a href="/stories/novel-acg-male" title="ACG">
- ACG
- </a>
- <a href="/stories/novel-horror-male" title="Horror">
- Horror
- </a>
- <a href="/stories/novel-sports-male" title="Sports">
- Sports
- </a>
- <a href="/stories/novel-action-male" title="Action">
- Action
- </a>
- <a href="/stories/novel-war-male" title="War">
- War
- </a>
- <a
- href="/stories/novel-realistic-male"
- title="Realistic"
- >
- Realistic
- </a>
- <a
- href="/stories/novel-history-male"
- title="History"
- >
- History
- </a>
- </p>
- <p>
- <strong>FEMALE LEAD</strong>
- <a href="/stories/novel-urban-female" title="Urban">
- Urban
- </a>
- <a
- href="/stories/novel-fantasy-female"
- title="Fantasy"
- >
- Fantasy
- </a>
- <a
- href="/stories/novel-history-female"
- title="History"
- >
- History
- </a>
- <a href="/stories/novel-teen-female" title="Teen">
- Teen
- </a>
- <a href="/stories/novel-lgbt-female" title="LGBT+">
- LGBT+
- </a>
- <a
- href="/stories/novel-scifi-female"
- title="Sci-fi"
- >
- Sci-fi
- </a>
- <a
- href="/stories/novel-general-female"
- title="General"
- >
- General
- </a>
- </p>
- </div>
- </li>
- <li>
- <a href="/stories/fanfic" title="Fan-fic">
- Fan-fic
- </a>
- <div className="sub-menu-list">
- <p>
- <a
- href="/stories/fanfic-anime-comics"
- title="Anime & Comics"
- >
- Anime & Comics
- </a>
- <a
- href="/stories/fanfic-video-games"
- title="Video Games"
- >
- Video Games
- </a>
- <a
- href="/stories/fanfic-celebrities"
- title="Celebrities"
- >
- Celebrities
- </a>
- <a
- href="/stories/fanfic-music-bands"
- title="Music & Bands"
- >
- Music & Bands
- </a>
- <a href="/stories/fanfic-movies" title="Movies">
- Movies
- </a>
- <a
- href="/stories/fanfic-book-literature"
- title="Book&Literature"
- >
- Book&Literature
- </a>
- <a href="/stories/fanfic-tv" title="TV">
- TV
- </a>
- <a href="/stories/fanfic-theater" title="Theater">
- Theater
- </a>
- <a href="/stories/fanfic-others" title="Others">
- Others
- </a>
- </p>
- </div>
- </li>
- </ul>
- </div>
- </li>
- <li>
- <a className="menu-item" href="" title="Rankings">
- <svg viewBox="0 0 1024 1024" width="24" height="24">
- <use href="/icons.svg#ranking"></use>
- </svg>
- <strong>Rankings</strong>
- </a>
- <div className="sub-menu">
- <ul>
- <li>
- <a
- href="/ranking/novel/bi_annual/power_rank?timeType=3&sourceType=2&signStatus=1"
- title="Novels ranking"
- >
- Novels ranking
- </a>
- </li>
- <li>
- <a
- href="/ranking/comic/all_time/comic_power_rank"
- title="Comics ranking"
- >
- Comics ranking
- </a>
- </li>
- <li>
- <a
- href="/ranking/fanfic/bi_annual/power_rank"
- title="Fan-fic ranking"
- >
- Fan-fic ranking
- </a>
- </li>
- </ul>
- </div>
- </li>
- </ul>
- </nav>
- <form action="./search" className="search-input">
- <svg className="icon-search">
- <use href="/icons.svg#search"></use>
- </svg>
- <input type="search" name="q" placeholder="Search" />
- </form>
- </div>
- <div className="buttons">
- <button className="btn" onClick={toggleTheme}>
- <svg className="icon-sun" viewBox="0 0 16 16">
- <use href="/icons.svg#sun"></use>
- </svg>
- <svg className="icon-moon" viewBox="0 0 16 16">
- <use href="/icons.svg#moon"></use>
- </svg>
- </button>
- <button className="btn menu-btn" onClick={toggleMenu}>
- <svg
- className="icon-menu"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 16 16"
- >
- <rect
- x="1"
- y="4"
- width="14"
- height="1.5"
- rx="1"
- className="r-1"
- ></rect>
- <rect
- x="1"
- y="7.25"
- width="14"
- height="1.5"
- rx="1"
- className="r-2"
- ></rect>
- <rect
- x="1"
- y="10.5"
- width="14"
- height="1.5"
- rx="1"
- className="r-3"
- ></rect>
- </svg>
- </button>
- </div>
- </div>
- </ClickAwayListener>
- </header>
- );
- }
|