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/#8] 공통 레이아웃 설정 #11

Merged
merged 15 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/app/chats/[chatId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import HeaderContent from '@/shared/components/HeaderContent';
import MainContent from '@/shared/components/MainContent';

export default function ChatPage() {
return (
<>
<HeaderContent>{null}</HeaderContent>
<MainContent>{null}</MainContent>
</>
);
}
11 changes: 11 additions & 0 deletions src/app/chats/[chatId]/tarot-reading/[resultId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import HeaderContent from '@/shared/components/HeaderContent';
import MainContent from '@/shared/components/MainContent';

export default function TarotReadingResultPage() {
return (
<>
<HeaderContent>{null}</HeaderContent>
<MainContent>{null}</MainContent>
</>
);
}
6 changes: 0 additions & 6 deletions src/app/global.css

This file was deleted.

20 changes: 11 additions & 9 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import SUIT from "@/shared/assets/font/font";
import ReactQueryClientProvider from "@/shared/lib/reactQuery/ReactQueryClientProvider";
import StyledComponentsRegistry from "@/shared/lib/styledComponents/StyledComponentsRegistry";
import StyledReset from "@/shared/lib/styledComponents/StyledReset";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import "./global.css";
import StyledComponentsTheme from "@/shared/lib/styledComponents/StyledComponentsTheme";
import SUIT from '@/shared/assets/font/font';
import ResponsiveRootLayout from '@/shared/components/ResponsiveRootLayout';
import ReactQueryClientProvider from '@/shared/lib/reactQuery/ReactQueryClientProvider';
import GlobalStyle from '@/shared/lib/styledComponents/GlobalStyle';
import StyledComponentsRegistry from '@/shared/lib/styledComponents/StyledComponentsRegistry';
import StyledComponentsTheme from '@/shared/lib/styledComponents/StyledComponentsTheme';
import StyledReset from '@/shared/lib/styledComponents/StyledReset';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
export default function RootLayout({
children,
}: Readonly<{
Expand All @@ -15,9 +16,10 @@ export default function RootLayout({
<body>
<ReactQueryClientProvider>
<StyledComponentsRegistry>
<StyledReset />
<GlobalStyle />
<StyledComponentsTheme>
<StyledReset />
{children}
<ResponsiveRootLayout>{children}</ResponsiveRootLayout>
</StyledComponentsTheme>
</StyledComponentsRegistry>
<ReactQueryDevtools initialIsOpen={false} />
Expand Down
12 changes: 10 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export default function Home() {
return null;
import HeaderContent from '@/shared/components/HeaderContent';
import MainContent from '@/shared/components/MainContent';

export default function HomePage() {
return (
<>
<HeaderContent>{null}</HeaderContent>
<MainContent>{null}</MainContent>
</>
);
}
58 changes: 58 additions & 0 deletions src/shared/components/HeaderContent/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use client';

import { ReactNode } from 'react';
import { css } from 'styled-components';

interface HeaderContentProps {
children: ReactNode;
/**
* 시작 부분에 표시할 요소입니다.
*/
startAction?: ReactNode;
/**
* 끝 부분에 표시할 요소입니다.
*/
endAction?: ReactNode;
/**
* true일 경우 헤더가 스티키 포지션으로 고정됩니다. (top: 0)
*/
sticky?: boolean;
/**
* 헤더 구분선 표시 여부
*/
divider?: boolean;
}

export default function HeaderContent({ children, startAction, endAction, sticky, divider }: HeaderContentProps) {
return (
<>
<header
css={css`
position: relative;
padding: 14px 20px;
display: flex;
align-items: center;
justify-content: space-between;
${sticky && `position: sticky; top: 0;`}
`}
>
{startAction ? startAction : <span role="presentation" />}
{children}
{endAction ? endAction : <span role="presentation" />}
</header>
{divider && (
<hr
css={css`
margin: 0;
block-size: 1px;
border: none;
width: 100%;
background-color: ${(props) => props.theme.colors.grey10};
box-shadow: 0 0 0 100vmax ${(props) => props.theme.colors.grey10};
clip-path: inset(0px -100vmax);
`}
/>
)}
</>
);
}
17 changes: 17 additions & 0 deletions src/shared/components/MainContent/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use client';

import { ReactNode } from 'react';
import { css } from 'styled-components';

export default function MainContent({ children }: { children: ReactNode }) {
return (
<main
css={css`
position: relative;
flex: 1;
`}
>
{children}
</main>
);
}
22 changes: 22 additions & 0 deletions src/shared/components/ResponsiveRootLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use client';

import { ReactNode } from 'react';
import { css } from 'styled-components';

export default function ResponsiveRootLayout({ children }: { children: ReactNode }) {
return (
<div
css={css`
margin-inline: auto;
min-height: 100dvh;
display: flex;
flex-direction: column;
@media screen and (min-width: 450px) {
max-width: 600px;
}
`}
>
{children}
</div>
);
}
24 changes: 24 additions & 0 deletions src/shared/lib/styledComponents/GlobalStyle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use client';

import { createGlobalStyle } from 'styled-components';

const GlobalStyle = createGlobalStyle`
*,
*::before,
*::after {
box-sizing: border-box;
}

body {
word-break: break-all;
}

button,
input,
select,
textarea {
font-family: inherit;
}
`;

export default GlobalStyle;
17 changes: 14 additions & 3 deletions src/shared/lib/styledComponents/styled.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import "styled-components";
import { ColorsTypes, FontsTypes } from "./theme";
declare module "styled-components" {
import 'styled-components';
import type { CSSProp } from 'styled-components';
import { ColorsTypes, FontsTypes } from './theme';

/**
* TypeScript 환경에서 css prop을 사용하기 위한 타입 선언
* @see {@link https://styled-components.com/docs/api#usage-with-typescript}
*/
declare module 'react' {
interface Attributes {
css?: CSSProp | undefined;
}
}
declare module 'styled-components' {
export interface DefaultTheme {
colors: ColorsTypes;
fonts: FontsTypes;
Expand Down