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

Feature/share 결과 공유 페이지 #7

Merged
merged 4 commits into from
Aug 28, 2024
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
2 changes: 2 additions & 0 deletions src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Route, Routes } from "react-router-dom";

import { RootLayout } from "./components/layout/RootLayout";
import HomePage from "./pages/HomePage";
import ResultShare from "./pages/ResultShare";
import ResultPage from "./pages/ResultPage";

export const Router = () => {
Expand All @@ -10,6 +11,7 @@ export const Router = () => {
<Route path="/" element={<RootLayout />}>
<Route index element={<HomePage />}></Route>
<Route path="/result" element={<ResultPage />}></Route>
<Route path="/share" element={<ResultShare />}></Route>
</Route>
</Routes>
);
Expand Down
10 changes: 10 additions & 0 deletions src/assets/back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/assets/shareLarge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/components/navigation/AppBar.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { AppBarProps } from "./AppBar";
import styled from "@emotion/styled";

export const AppBarElement = styled.span<AppBarProps>`
position: relative;

width: 100%;
height: 60px;

display: flex;
justify-content: center;
align-items: center;

box-sizing: border-box;

border-bottom: 2px solid #0000001f;

& > span {
font-weight: 800;
}

& > img {
position: absolute;
left: 15px;
}
`;
15 changes: 15 additions & 0 deletions src/components/navigation/AppBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { forwardRef } from "react";

import { AppBarElement } from "./AppBar.style";

export interface AppBarProps extends React.ComponentProps<"div"> {
children: React.ReactNode;
}

export const AppBar = forwardRef<HTMLDivElement, AppBarProps>(({ children, ...props }, ref) => {
return (
<AppBarElement ref={ref} {...props}>
{children}
</AppBarElement>
);
});
Comment on lines +1 to +15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forwardRef 는 리액트 노드의 ref 속성에 접근할때
예를들어 input, button 과 같은 경우에만 사용하면 될것 같습니다!
ref props 는 일반적인 props 와 다르게 React Fiber Node 에 저장되기 때문에 forwardRef 로 전달하는거에요!
그냥 styled component 를 사용하면 ref 도 자동으로 전달해주니 저런식으로 굳이 짤 필요는 없다고 생각됩니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이해됐습니다! 다음 PR과 함께 수정하겠습니다!

45 changes: 45 additions & 0 deletions src/pages/ResultShare.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { useEffect, useState } from "react";

import { AppBar } from "@/components/navigation/AppBar";
import { Text } from "@/components/typography/Text";

import BackIcon from "@/assets/back.svg";
import ShareIcon from "@/assets/shareLarge.svg";

import styled from "@emotion/styled";

const Header = styled.div`
margin-top: 20px;
margin-left: 30px;

& > img {
margin-bottom: 20px;
}
`;

export default function ResultShare() {
const [name, setName] = useState<string>("");

useEffect(() => {
// 전역 상태에서 이름을 불러와서 setName으로 디스플레이 이름을 변경합니다.
setName("홍길동");
}, []);

return (
<>
{/* 나중에 통일된 Header||AppBar로 변경해도 됩니다. */}
<AppBar>
<img src={BackIcon} />
<Text size="m">결과 공유</Text>
</AppBar>
<Header>
<img src={ShareIcon} />
<Text size="xl">
{name}님의 동BTI를
<br />
공유해보세요
</Text>
</Header>
</>
);
}