separated Navbar into its components
This commit is contained in:
parent
671c529ee2
commit
6de997f19c
4 changed files with 71 additions and 50 deletions
30
src/components/Navbar/NavLinks.tsx
Normal file
30
src/components/Navbar/NavLinks.tsx
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import styled from "styled-components"
|
||||||
|
import { Link } from "react-router-dom"
|
||||||
|
|
||||||
|
import NavbarData from "../../data/NavbarData"
|
||||||
|
import theming from "../../styles/theming"
|
||||||
|
|
||||||
|
import { StyledLink } from "./Navbar"
|
||||||
|
|
||||||
|
const StyledNavLinks = styled.div`
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
@media only screen and (max-width: ${theming.size.screen_size1}) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const NavLinks = () => {
|
||||||
|
return (
|
||||||
|
<StyledNavLinks>
|
||||||
|
{NavbarData.map((item, index) => (
|
||||||
|
<Link key={index} to={item.path}>
|
||||||
|
<StyledLink>{item.title}</StyledLink>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</StyledNavLinks>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NavLinks
|
|
@ -1,16 +1,13 @@
|
||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
import { Link } from "react-router-dom"
|
import { Link } from "react-router-dom"
|
||||||
import ReactTooltip from "react-tooltip"
|
|
||||||
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
import ThemeToggleButton from "../ThemeToggleButton"
|
||||||
import { faSearch } from "@fortawesome/free-solid-svg-icons"
|
import ReadProgress from "../ReadProgress"
|
||||||
|
import Sidebar from "../Sidebar"
|
||||||
|
import SearchButton from "./SearchButton"
|
||||||
|
import NavLinks from "./NavLinks"
|
||||||
|
|
||||||
import ThemeToggleButton from "./ThemeToggleButton"
|
import theming from "../../styles/theming"
|
||||||
import ReadProgress from "./ReadProgress"
|
|
||||||
import Sidebar from "./Sidebar"
|
|
||||||
|
|
||||||
import theming from "../styles/theming"
|
|
||||||
import NavbarData from "../data/NavbarData"
|
|
||||||
|
|
||||||
const StyledNav = styled.nav`
|
const StyledNav = styled.nav`
|
||||||
/* set z index to arbitrarily high value to prevent other components from drawing over the navbar */
|
/* set z index to arbitrarily high value to prevent other components from drawing over the navbar */
|
||||||
|
@ -48,15 +45,6 @@ const StyledContainer = styled.div`
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const StyledNavLinks = styled.div`
|
|
||||||
display: flex;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
@media only screen and (max-width: ${theming.size.screen_size1}) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
const StyledImg = styled.img`
|
const StyledImg = styled.img`
|
||||||
height: 2.5rem;
|
height: 2.5rem;
|
||||||
|
|
||||||
|
@ -64,53 +52,23 @@ const StyledImg = styled.img`
|
||||||
margin: 1rem;
|
margin: 1rem;
|
||||||
`
|
`
|
||||||
|
|
||||||
const StyledLink = styled.div`
|
export const StyledLink = styled.div`
|
||||||
${theming.styles.navbarButtonStyle}
|
${theming.styles.navbarButtonStyle}
|
||||||
`
|
`
|
||||||
|
|
||||||
const SearchButton = () => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div style={{ height: "100%" }}>
|
|
||||||
<Link
|
|
||||||
data-tip
|
|
||||||
data-for="search"
|
|
||||||
to={`${process.env.PUBLIC_URL}/search`}
|
|
||||||
>
|
|
||||||
<StyledLink>
|
|
||||||
<FontAwesomeIcon icon={faSearch} />
|
|
||||||
</StyledLink>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
<ReactTooltip id="search" type="dark" effect="solid">
|
|
||||||
<span>Search</span>
|
|
||||||
</ReactTooltip>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const Navbar = () => {
|
const Navbar = () => {
|
||||||
return (
|
return (
|
||||||
<StyledNav>
|
<StyledNav>
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
{/* icon */}
|
{/* icon */}
|
||||||
|
|
||||||
<Link to="/">
|
<Link to="/">
|
||||||
<StyledImg src={process.env.PUBLIC_URL + "/icon/icon_circle.svg"} />
|
<StyledImg src={process.env.PUBLIC_URL + "/icon/icon_circle.svg"} />
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
{/* nav links */}
|
{/* nav links */}
|
||||||
|
<NavLinks />
|
||||||
<StyledNavLinks>
|
|
||||||
{NavbarData.map((item, index) => (
|
|
||||||
<Link key={index} to={item.path}>
|
|
||||||
<StyledLink>{item.title}</StyledLink>
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</StyledNavLinks>
|
|
||||||
|
|
||||||
{/* right buttons */}
|
{/* right buttons */}
|
||||||
|
|
||||||
<ThemeToggleButton />
|
<ThemeToggleButton />
|
||||||
<SearchButton />
|
<SearchButton />
|
||||||
<Sidebar />
|
<Sidebar />
|
30
src/components/Navbar/SearchButton.tsx
Normal file
30
src/components/Navbar/SearchButton.tsx
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import { Link } from "react-router-dom"
|
||||||
|
import ReactTooltip from "react-tooltip"
|
||||||
|
|
||||||
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
|
import { faSearch } from "@fortawesome/free-solid-svg-icons"
|
||||||
|
|
||||||
|
import { StyledLink } from "./Navbar"
|
||||||
|
|
||||||
|
const SearchButton = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div style={{ height: "100%" }}>
|
||||||
|
<Link
|
||||||
|
data-tip
|
||||||
|
data-for="search"
|
||||||
|
to={`${process.env.PUBLIC_URL}/search`}
|
||||||
|
>
|
||||||
|
<StyledLink>
|
||||||
|
<FontAwesomeIcon icon={faSearch} />
|
||||||
|
</StyledLink>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<ReactTooltip id="search" type="dark" effect="solid">
|
||||||
|
<span>Search</span>
|
||||||
|
</ReactTooltip>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SearchButton
|
3
src/components/Navbar/index.tsx
Normal file
3
src/components/Navbar/index.tsx
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import Navbar from "./Navbar"
|
||||||
|
|
||||||
|
export default Navbar
|
Loading…
Add table
Add a link
Reference in a new issue