Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 공통 Header를 구현합니다. #19

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
8 changes: 7 additions & 1 deletion src/Menu/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Header from "@/common/components/Header";
import UserListItemCard from "@/common/components/UserListItemCard";
import UserProfileAvatar from "@/common/components/UserProfileAvatar";
import { css } from "@emotion/react";
Expand All @@ -17,6 +18,11 @@ import { Link } from "react-router";
export default function MenuPage() {
return (
<>
<Header
leftElement={"왼쪽"}
centerElement={"중앙"}
rightElement={"오른쪽"}
/>
{version}
<Card variant="surface">menu</Card>

Expand Down Expand Up @@ -70,5 +76,5 @@ export default function MenuPage() {

const UserListContainer = styled.div({
width: "100vw",
padding: "10px",
padding: "1rem",
});
51 changes: 51 additions & 0 deletions src/common/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { ReactElement } from "react";
import styled from "@emotion/styled";
import { Z_INDEX } from "../constants/zIndex";

interface HeaderProps {
leftElement?: ReactElement | string;
centerElement: ReactElement | string;
rightElement?: ReactElement | string;
}

function Header({ leftElement, centerElement, rightElement }: HeaderProps) {
return (
<HeaderWrapper aria-label="페이지 헤더">
<LeftElement>{leftElement}</LeftElement>
<CenterElement as={typeof centerElement === "string" ? "h1" : "div"}>
{centerElement}
</CenterElement>
<RightElement>{rightElement}</RightElement>
</HeaderWrapper>
);
}

export default Header;

const HeaderWrapper = styled.header({
position: "sticky",
zIndex: Z_INDEX.HEADER,
top: 0,

display: "flex",
alignItems: "center",

width: "100%",
height: "4.8rem",

backgroundColor: "white",
});

const LeftElement = styled.div({
position: "absolute",
left: "1.5rem",
});

const CenterElement = styled.div({
margin: "0 auto",
});

const RightElement = styled.div({
position: "absolute",
right: "1.5rem",
});
5 changes: 5 additions & 0 deletions src/common/constants/zIndex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const Z_INDEX = {
MODAL: 1000,
DROPDOWN: 100,
HEADER: 10,
} as const;