Skip to content

Commit

Permalink
feat: Layout 컴포넌트 구현 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Puterism authored Jan 27, 2024
1 parent 53f2a01 commit 8312a9b
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SignUpCompletePage from './pages/SignUpComplete/SignUpCompletePage';
import 'the-new-css-reset/css/reset.css';
import './index.css';
import { PATH } from './constants/routes';
import HomePage from './pages/HomePage/HomePage';

const router = createBrowserRouter([
{
Expand All @@ -20,7 +21,7 @@ const router = createBrowserRouter([
path: PATH.SIGNUP_COMPLETE,
element: <SignUpCompletePage />,
},
{ path: PATH.HOME, element: <></> },
{ path: PATH.HOME, element: <HomePage /> },
{
path: '*',
element: <Navigate to={PATH.INDEX} replace />,
Expand Down
18 changes: 18 additions & 0 deletions apps/admin/src/components/Header/Header.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import styled from '@emotion/styled';

const Header = styled.div`
height: 68px;
display: flex;
justify-content: space-between;
align-items: center;
`;

const HeaderLeft = styled.div``;

const HeaderRight = styled.div``;

export default {
Header,
HeaderLeft,
HeaderRight,
};
18 changes: 18 additions & 0 deletions apps/admin/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import Styled from './Header.styles';

interface HeaderProps {
left?: React.ReactNode;
right?: React.ReactNode;
}

const Header = ({ left, right }: HeaderProps) => {
return (
<Styled.Header>
<Styled.HeaderLeft>{left}</Styled.HeaderLeft>
<Styled.HeaderRight>{right}</Styled.HeaderRight>
</Styled.Header>
);
};

export default Header;
31 changes: 31 additions & 0 deletions apps/admin/src/components/Layout/Layout.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import styled from '@emotion/styled';

const Layout = styled.div`
background-color: ${({ theme }) => theme.palette.grey.g00};
`;

const HeaderContainer = styled.div`
background-color: ${({ theme }) => theme.palette.grey.w};
border-bottom: 1px solid ${({ theme }) => theme.palette.grey.g30};
`;

const Header = styled.header`
width: ${({ theme }) => theme.breakpoint.desktop};
margin: 0 auto;
padding: 0 20px;
`;

const ContentContainer = styled.div``;

const Content = styled.div`
width: ${({ theme }) => theme.breakpoint.desktop};
margin: 0 auto;
`;

export default {
Layout,
HeaderContainer,
Header,
ContentContainer,
Content,
};
23 changes: 23 additions & 0 deletions apps/admin/src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Styled from './Layout.styles';

interface LayoutProps {
children: React.ReactNode;
header?: React.ReactNode;
}

const Layout = ({ children, header }: LayoutProps) => {
return (
<Styled.Layout>
{header && (
<Styled.HeaderContainer>
<Styled.Header>{header}</Styled.Header>
</Styled.HeaderContainer>
)}
<Styled.ContentContainer>
<Styled.Content>{children}</Styled.Content>
</Styled.ContentContainer>
</Styled.Layout>
);
};

export default Layout;
28 changes: 28 additions & 0 deletions apps/admin/src/pages/HomePage/HomePage.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import styled from '@emotion/styled';
import { Link } from 'react-router-dom';

const Logo = styled.div`
display: inline-flex;
justify-content: center;
align-items: center;
background-color: ${({ theme }) => theme.palette.grey.g40};
width: 174px;
height: 44px;
`;

const LogoutLink = styled(Link)`
display: inline-flex;
align-items: center;
height: 44px;
padding: 0 18px;
${({ theme }) => theme.typo.sh1};
color: ${({ theme }) => theme.palette.grey.g90};
`;

const HomePage = styled.div``;

export default {
Logo,
LogoutLink,
HomePage,
};
21 changes: 21 additions & 0 deletions apps/admin/src/pages/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Header from '../../components/Header/Header';
import Layout from '../../components/Layout/Layout';
import { PATH } from '../../constants/routes';
import Styled from './HomePage.styles';

const HomePage = () => {
return (
<Layout
header={
<Header
left={<Styled.Logo>Boolti Logo</Styled.Logo>}
right={<Styled.LogoutLink to={PATH.LOGIN}>로그아웃</Styled.LogoutLink>}
/>
}
>
<h2>HomePage</h2>
</Layout>
);
};

export default HomePage;
2 changes: 2 additions & 0 deletions apps/admin/src/styles/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { ThemeProvider as BaseThemeProvider } from '@emotion/react';

import palette from './palette';
import typo from './typo';
import breakpoint from './breakpoint';

const theme = {
palette,
typo,
breakpoint,
};

interface ThemeProviderProps {
Expand Down
5 changes: 5 additions & 0 deletions apps/admin/src/styles/breakpoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const breakpoint = {
desktop: '1280px',
} as const;

export default breakpoint;
2 changes: 2 additions & 0 deletions apps/admin/src/styles/emotion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import '@emotion/react';

import palette from './palette';
import typo from './typo';
import breakpoint from './breakpoint';

declare module '@emotion/react' {
export interface Theme {
palette: typeof palette;
typo: typeof typo;
breakpoint: typeof breakpoint;
}
}

0 comments on commit 8312a9b

Please sign in to comment.