From 4d366f8c254b9c7d62f203a6618bb29ace96d906 Mon Sep 17 00:00:00 2001 From: pheralb Date: Tue, 21 Jun 2022 15:19:13 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=92=EF=B8=8F=20Create=20header=20&=20layo?= =?UTF-8?q?ut=20config.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/animations/show.tsx | 24 ++++++ src/layout/{sidebar => header}/categories.tsx | 12 +-- src/layout/header/index.tsx | 73 +++++++++++++++++++ src/layout/header/links.ts | 12 +++ src/layout/header/mobile.tsx | 56 ++++++++++++++ src/layout/{sidebar => header}/theme.tsx | 7 +- src/layout/index.tsx | 10 ++- src/layout/sidebar/content.tsx | 53 -------------- src/layout/sidebar/index.tsx | 59 --------------- src/pages/api/all.ts | 2 +- src/pages/index.tsx | 17 ++--- 11 files changed, 188 insertions(+), 137 deletions(-) create mode 100644 src/animations/show.tsx rename src/layout/{sidebar => header}/categories.tsx (64%) create mode 100644 src/layout/header/index.tsx create mode 100644 src/layout/header/links.ts create mode 100644 src/layout/header/mobile.tsx rename src/layout/{sidebar => header}/theme.tsx (82%) delete mode 100644 src/layout/sidebar/content.tsx delete mode 100644 src/layout/sidebar/index.tsx diff --git a/src/animations/show.tsx b/src/animations/show.tsx new file mode 100644 index 0000000..0d8a350 --- /dev/null +++ b/src/animations/show.tsx @@ -0,0 +1,24 @@ +import React, { FC } from "react"; +import { motion } from "framer-motion"; + +type ShowProps = { + children: React.ReactNode; + delay?: number; +}; + +const Show = ({ children, delay }: ShowProps) => { + return ( + + {children} + + ); +}; + +export default Show; diff --git a/src/layout/sidebar/categories.tsx b/src/layout/header/categories.tsx similarity index 64% rename from src/layout/sidebar/categories.tsx rename to src/layout/header/categories.tsx index fcb7d2e..af69f48 100644 --- a/src/layout/sidebar/categories.tsx +++ b/src/layout/header/categories.tsx @@ -2,7 +2,7 @@ import React from "react"; import useSWR from "swr"; import { getCategorySvgs } from "@/services"; import CustomLink from "@/common/link"; -import { Text } from "@chakra-ui/react"; +import { Box, Text } from "@chakra-ui/react"; const Categories = () => { const { data, error } = useSWR(getCategorySvgs); @@ -11,13 +11,13 @@ const Categories = () => { if (!data) return
loading...
; return ( -
+ <> {data.map((category: string) => ( - - {category} - + + {category} + ))} -
+ ); }; diff --git a/src/layout/header/index.tsx b/src/layout/header/index.tsx new file mode 100644 index 0000000..5473a96 --- /dev/null +++ b/src/layout/header/index.tsx @@ -0,0 +1,73 @@ +import React from "react"; +import { + Box, + Flex, + useColorModeValue, + HStack, + Button, + Container, + Heading, +} from "@chakra-ui/react"; +import { Sticker } from "phosphor-react"; +import Theme from "./theme"; +import Tap from "@/animations/tap"; +import Mobile from "./mobile"; +import { Links } from "./links"; +import CustomLink from "@/common/link"; +import Categories from "./categories"; + +const Header = () => { + const bg = useColorModeValue("bg.light", "bg.dark"); + return ( + <> + + + + + + + + svgl + + + + + + {Links.map((link) => ( + + + + ))} + + + + + + + + + + + + + + ); +}; + +export default Header; diff --git a/src/layout/header/links.ts b/src/layout/header/links.ts new file mode 100644 index 0000000..ffaf4e5 --- /dev/null +++ b/src/layout/header/links.ts @@ -0,0 +1,12 @@ +export const Links = [ + { + title: "Github", + slug: "https://github.com/pheralb/svgl", + external: true, + }, + { + title: "Twitter", + slug: "https://twitter.com/pheralb_", + external: true, + }, +]; diff --git a/src/layout/header/mobile.tsx b/src/layout/header/mobile.tsx new file mode 100644 index 0000000..11d57e6 --- /dev/null +++ b/src/layout/header/mobile.tsx @@ -0,0 +1,56 @@ +import CustomLink from "@/common/link"; +import { + Button, + CloseButton, + IconButton, + useColorModeValue, + useDisclosure, + VStack, +} from "@chakra-ui/react"; +import { List } from "phosphor-react"; +import { Links } from "./links"; + +const Mobile = () => { + const bg = useColorModeValue("bg.light", "bg.dark"); + const mobileNav = useDisclosure(); + return ( + <> + } + onClick={mobileNav.onOpen} + /> + + + + {Links.map((link) => ( + + + + ))} + + + ); +}; + +export default Mobile; diff --git a/src/layout/sidebar/theme.tsx b/src/layout/header/theme.tsx similarity index 82% rename from src/layout/sidebar/theme.tsx rename to src/layout/header/theme.tsx index 86dce01..589aa90 100644 --- a/src/layout/sidebar/theme.tsx +++ b/src/layout/header/theme.tsx @@ -2,19 +2,18 @@ import React from "react"; import { AnimatePresence, motion } from "framer-motion"; import { useColorMode, useColorModeValue } from "@chakra-ui/react"; import CustomIconBtn from "@/common/iconBtn"; -import { IoMoonOutline, IoSunnyOutline } from "react-icons/io5"; +import { Moon, Sun } from "phosphor-react"; const Theme = () => { const { toggleColorMode } = useColorMode(); const key = useColorModeValue("light", "dark"); const icon = useColorModeValue( - , - + , + ); return ( { - return {children}; + return ( + <> +
+ {children} + + ); }; export default Index; diff --git a/src/layout/sidebar/content.tsx b/src/layout/sidebar/content.tsx deleted file mode 100644 index 7a8ff39..0000000 --- a/src/layout/sidebar/content.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import React from "react"; -import { SidebarContentProps } from "@/interfaces/components"; -import { - Box, - Divider, - Flex, - Heading, - useColorModeValue, -} from "@chakra-ui/react"; -import { HandGrabbing } from "phosphor-react"; -import CustomLink from "@/common/link"; -import Categories from "./categories"; - -const Content = (props: SidebarContentProps) => { - const bg = useColorModeValue("bg.light", "bg.dark"); - return ( - - - - - - - - - Categories - - - - - - ); -}; - -export default Content; diff --git a/src/layout/sidebar/index.tsx b/src/layout/sidebar/index.tsx deleted file mode 100644 index 1c401d3..0000000 --- a/src/layout/sidebar/index.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { SidebarContentProps } from "@/interfaces/components"; -import { - Box, - Drawer, - DrawerContent, - DrawerOverlay, - Flex, - IconButton, - useColorModeValue, - useDisclosure, -} from "@chakra-ui/react"; -import React from "react"; -import { IoApps } from "react-icons/io5"; -import Content from "./content"; - -const Index = ({ children }: SidebarContentProps) => { - const sidebar = useDisclosure(); - return ( - - - - - - - - - - - } - size="sm" - /> - - - - {children} - - - - ); -}; - -export default Index; diff --git a/src/pages/api/all.ts b/src/pages/api/all.ts index 3e4e497..1ca35f0 100644 --- a/src/pages/api/all.ts +++ b/src/pages/api/all.ts @@ -1,5 +1,5 @@ -import type { NextApiRequest, NextApiResponse } from "next"; import db from "data/svgs"; +import type { NextApiRequest, NextApiResponse } from "next"; import { SvgData } from "@/interfaces/svgData"; export default function handler( diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 28883c7..3978baf 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -13,18 +13,11 @@ const Home: NextPage = () => { if (!data) return
loading...
; return ( - - - {data.map((svg: SvgData) => ( - - ))} - - + + {data.map((svg: SvgData) => ( + + ))} + ); };