Skip to content

Commit

Permalink
Merge pull request #24 from depromeet/feat/#11/AppBar
Browse files Browse the repository at this point in the history
AppBar Component 개발
  • Loading branch information
sean2337 committed Jul 15, 2024
2 parents 59c39d5 + 5228362 commit 75bdc73
Show file tree
Hide file tree
Showing 9 changed files with 3,087 additions and 2,452 deletions.
5,412 changes: 2,984 additions & 2,428 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/app/login/Login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DefaultLayout } from "@/layout/DefaultLayout";
import SocialLoginButton from "@/component/button/SocialLoginButton";
import { kakaoLogin } from "./kakao/kakaoLogin";
import { googleLogin } from "./google/googleLogin";

const Login = () => {
return (
<DefaultLayout appBarVisible={false}>
<SocialLoginButton type="kakao" handler={kakaoLogin} />
<SocialLoginButton type="google" handler={googleLogin} />
</DefaultLayout>
);
};
export default Login;
3 changes: 3 additions & 0 deletions src/app/login/google/googleLogin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function googleLogin() {
console.log("구글 로그인 시도");
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
const Login = () => {
export function kakaoLogin() {
const REST_API_KEY: string = import.meta.env.VITE_REST_API_KEY;
const REDIRECT_URI: string = import.meta.env.VITE_REDIRECT_URI;
const link = `https://kauth.kakao.com/oauth/authorize?client_id=${REST_API_KEY}&redirect_uri=${REDIRECT_URI}&response_type=code`;

const loginHandler = () => {
window.location.href = link;
};

return (
<div>
<button type="button" onClick={loginHandler}>
Hello Kakao Login
</button>
</div>
);
};
export default Login;
window.location.href = link;
}
2 changes: 1 addition & 1 deletion src/component/common/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = {

const DEFAULT_ICON_COLOR = "#000000";

function Icon({ icon, color = DEFAULT_ICON_COLOR, size = "0.2rem", onClick }: Props) {
function Icon({ icon, color = DEFAULT_ICON_COLOR, size = "2rem", onClick }: Props) {
const SVGIcon = icons[icon];
const widthRem = typeof size === "number" ? `${size}rem` : size;

Expand Down
68 changes: 68 additions & 0 deletions src/component/common/appBar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { css } from "@emotion/react";
import { useNavigate } from "react-router-dom";
import Icon from "../Icon/Icon";

export type AppBarProps = {
title?: string;
LeftComp?: React.ReactNode;
RightComp?: React.ReactNode;
};

//FIXME: 색깔 디자인 토큰에 따라 변경
const Back = () => {
const navigate = useNavigate();

return (
<Icon
icon="ic_back"
onClick={() => {
navigate(-1);
}}
/>
);
};

//FIXME : 디자인 토큰에 따라 색깔 변경, 폰트 수정
const AppBar = ({ title, LeftComp = <Back />, RightComp = <div></div> }: AppBarProps) => {
return (
<>
<div
css={css`
width: 100%;
max-width: 48rem;
height: 4.8rem;
padding: 0 2rem;
background-color: transparent;
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
left: 50%;
transform: translateX(-50%);
box-sizing: border-box;
`}
>
{LeftComp}
<div
css={css`
position: absolute;
left: 50%;
transform: translateX(-50%);
font-size: 1.8rem;
`}
>
{title}
</div>
{RightComp}
</div>
<div
css={css`
width: 100%;
height: 4.8rem;
`}
/>
</>
);
};

export default AppBar;
15 changes: 8 additions & 7 deletions src/layout/DefaultLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { css } from "@emotion/react";
import { Fragment, PropsWithChildren } from "react";
import AppBar from "@/component/common/appBar";
import { AppBarProps } from "@/component/common/appBar";

export function DefaultLayout({ children }: PropsWithChildren) {
type DefaultLayoutProps = PropsWithChildren<AppBarProps> & {
appBarVisible?: boolean;
};

export function DefaultLayout({ children, title, appBarVisible = true, LeftComp, RightComp }: DefaultLayoutProps) {
return (
<Fragment>
{/* FIXME: 헤더 컴포넌트 작업 시, 해당 헤더 엘리먼트 제거 */}
<header
css={css`
height: 4.6rem;
`}
/>
{appBarVisible && <AppBar title={title} LeftComp={LeftComp} RightComp={RightComp} />}
<main
css={css`
flex: 1 1 0;
Expand Down
7 changes: 6 additions & 1 deletion src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Fragment } from "react";
import { createBrowserRouter, RouterProvider } from "react-router-dom";

import MainPage from "@/app/MainPage.tsx"; /* FIXME - 실제 메인 페이지 작성 후 대체해주세요. */
import Login from "@/app/login/Login";
import Staging from "@/app/test/Staging.tsx";
import GlobalLayout from "@/layout/GlobalLayout.tsx";

Expand All @@ -14,6 +15,10 @@ const routerChildren = [
path: "/staging",
element: <Staging />,
},
{
path: "/login",
element: <Login />,
},
];

const router = createBrowserRouter([
Expand All @@ -26,4 +31,4 @@ const router = createBrowserRouter([
]);
export const Routers = () => {
return <RouterProvider router={router} />;
};
};

0 comments on commit 75bdc73

Please sign in to comment.