From 2f6d54f07229959f52bbcb48a7ca63679f3dbb81 Mon Sep 17 00:00:00 2001 From: NCanggoro Date: Tue, 29 Aug 2023 12:06:48 +0700 Subject: [PATCH] fix header --- src/app.css | 25 ++++++++++++- src/components/Header/index.tsx | 63 +++++++++++++++++++++++++++++++++ src/components/index.ts | 5 +++ src/layouts/Default/Default.tsx | 2 ++ src/pages/Home/index.tsx | 46 ------------------------ 5 files changed, 94 insertions(+), 47 deletions(-) create mode 100644 src/components/Header/index.tsx create mode 100644 src/components/index.ts diff --git a/src/app.css b/src/app.css index cc3ba2c..441d105 100644 --- a/src/app.css +++ b/src/app.css @@ -11,11 +11,29 @@ @media screen and (max-width: 488px) { a.navLink{ - display: none; + /* display: none; */ + margin-top: 10px; + width: 100%; + padding: 0; + border-bottom: 1px solid white; + padding: 10px 0 } div.nav-container { + padding: 0 20px; + height: 100vh; + /* align-items: start; */ + justify-content: start; + flex-direction: column; + } + + div.nav-container-disabled { padding: 4px; + height: 0; + } + + a.navLink-disabled { + display: none; } form.search-input { @@ -35,6 +53,11 @@ h1.title-dropdown { display: none; } + + a.navLink:hover{ + border-bottom-width: 1px; + margin-bottom: 0px; + } } @media screen and (max-width: 390px){ diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx new file mode 100644 index 0000000..2039d97 --- /dev/null +++ b/src/components/Header/index.tsx @@ -0,0 +1,63 @@ +import React from "preact/compat"; +import { useState } from "preact/hooks"; + + +function Header() { + + const [searchVal, setSearchVal] = useState(''); + const [dropdown, setDropdown] = useState(false); + + const onInput = (e: React.ChangeEvent): void => { + const val = e.target as HTMLInputElement; + setSearchVal(val.value) + } + + const onSearchSubmit = (e: React.TargetedEvent): void => { + e.preventDefault(); + } + + const onDropdown = (): void => { + document.body.style.overflow = "hidden" + + if(dropdown) { + document.body.style.overflow = "scroll"; + } + setDropdown(!dropdown) + } + + return ( +
+
+

HilingRiviw

+
+ +
+ +
+
+ {dropdown && + Home + } + Best places + Discover + Trending Places + Lists + Stories + News + Forum +
+
+ ) +} + +export default Header; \ No newline at end of file diff --git a/src/components/index.ts b/src/components/index.ts new file mode 100644 index 0000000..4dbc380 --- /dev/null +++ b/src/components/index.ts @@ -0,0 +1,5 @@ +import Header from "./Header"; + +export { + Header +} \ No newline at end of file diff --git a/src/layouts/Default/Default.tsx b/src/layouts/Default/Default.tsx index 8adeaee..b26f75c 100644 --- a/src/layouts/Default/Default.tsx +++ b/src/layouts/Default/Default.tsx @@ -1,4 +1,5 @@ import { ComponentChildren } from "preact"; +import { Header } from "../../components"; type ChildrenProps = { children: ComponentChildren @@ -7,6 +8,7 @@ type ChildrenProps = { function DefaultLayout({ children }: ChildrenProps) { return ( <> +
{children} ) diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index f2897ec..2acc3aa 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -2,59 +2,13 @@ import preactLogo from '../../assets/preact.svg'; import viteLogo from '/vite.svg' import { useState } from "preact/hooks"; import { DefaultLayout } from '../../layouts/'; -import React from 'preact/compat'; function Home() { const [count, setCount] = useState(0) - const [searchVal, setSearchVal] = useState(''); - const [dropdown, setDropdown] = useState(false); - const onInput = (e: React.ChangeEvent): void => { - const val = e.target as HTMLInputElement; - setSearchVal(val.value) - } - - const onSearchSubmit = (e: React.TargetedEvent): void => { - e.preventDefault(); - alert(e) - } - - const onDropdown = (e): void => { - setDropdown(!dropdown) - // alert("bruh"); - } return ( -
-
-

HilingRiviw

-
- -
- -
- -
-