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(app, home): emotion 기반으로 홈 배너와 홈 페이지 컨테이너 로직을 변경합니다. #77

Merged
merged 11 commits into from
Sep 9, 2023
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
372 changes: 372 additions & 0 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions apps/react-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@types/axios": "^0.14.0",
"axios": "^1.5.0",
"react": "^18.2.0",
Expand Down
15 changes: 0 additions & 15 deletions apps/react-world/src/components/Layout.tsx

This file was deleted.

26 changes: 26 additions & 0 deletions apps/react-world/src/components/home/HomeBanner.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import styled from '@emotion/styled';
import { Banner, BannerTitle } from '../shared/banner/Banner.styled';

export const HomeBannerContainer = styled(Banner)`
background: #5cb85c;
box-shadow:
inset 0 8px 8px -8px rgba(0, 0, 0, 0.3),
inset 0 -8px 8px -8px rgba(0, 0, 0, 0.3);
text-align: center;
`;

export const HomeBannerTitle = styled(BannerTitle)`
text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
font-weight: 700;
font-size: 3.5rem;
padding-bottom: 0.5rem;
margin-bottom: 0px;
font-family: 'Titillium Web', sans-serif;
`;

export const HomeBannerText = styled.p`
color: #fff;
font-size: 1.5rem;
font-weight: 300;
margin-bottom: 0px;
`;
18 changes: 10 additions & 8 deletions apps/react-world/src/components/home/HomeBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {
HomeBannerContainer,
HomeBannerText,
HomeBannerTitle,
} from './HomeBanner.styled';

export const HomeBanner: React.FC = () => {
return (
Comment on lines +6 to 8
Copy link
Member

Choose a reason for hiding this comment

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

React.FC를 사용하지 말라는 여러가지 커뮤니티의 의견이 있는데요,

  1. function 기명식 컴포넌트 선언에서는 타이핑 함수를 사용할 수가 없습니다.
  2. 항상 children을 가질 수 있으므로 인식의 차이가 발생할 수 있습니다.
  3. React에서 제공하는 defaultProps를 사용할 수 없게 합니다.

더 자세한 내용을 보고 싶다면 이 블로그를 참조하면 좋을 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

코멘트 감사합니다! 블로그 포함해서 관련 내용은 더 살펴봐야겠지만 우선은 안 쓰는 방향으로 반영해나갈게요!

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에서 반영했습니다!

<div className="home-page">
<div className="banner">
<div className="container">
<h1 className="logo-font">conduit</h1>
<p>A place to share your knowledge.</p>
</div>
</div>
</div>
<HomeBannerContainer>
<HomeBannerTitle>conduit</HomeBannerTitle>
<HomeBannerText>A place to share your knowledge.</HomeBannerText>
</HomeBannerContainer>
);
};
29 changes: 24 additions & 5 deletions apps/react-world/src/components/home/HomePageContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
interface HomePageContainerProps {
children: React.ReactNode;
}
import { ReactNode } from 'react';
import styled from '@emotion/styled';

const HomePageContainer: React.FC<HomePageContainerProps> = ({ children }) => {
return <div className="home-page">{children}</div>;
type ContainerProps = {
children?: ReactNode;
};

export const HomePageContainer = ({ children }: ContainerProps) => {
return <Container>{children}</Container>;
};

const Container = styled.div`
&.home-page .feed-toggle {
margin-bottom: -1px;
}

&.home-page .sidebar {
padding: 5px 10px 10px 10px;
background: #f3f3f3;
border-radius: 4px;
}

&.home-page .sidebar p {
margin-bottom: 0.2rem;
}
`;

export default HomePageContainer;
24 changes: 24 additions & 0 deletions apps/react-world/src/components/shared/Container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import styled from '@emotion/styled';

export const Container = styled.div`
margin-left: auto;
margin-right: auto;
padding-left: 15px;
padding-right: 15px;

@media (min-width: 544px) {
max-width: 576px;
}

@media (min-width: 768px) {
max-width: 720px;
}

@media (min-width: 992px) {
max-width: 940px;
}

@media (min-width: 1200px) {
max-width: 1140px;
}
Comment on lines +9 to +23
Copy link
Member

Choose a reason for hiding this comment

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

이렇게 반응형 미디어 쿼리를 여러 곳에서 사용하게 되면 아래와 같은 상황이 헷갈리게 됩니다.

  1. 데스크탑 우선 vs 모바일 우선: min-width / max-width 차이
  2. px 기준

그래서 보통은, 디자인 토큰이나 상수로 width 값을 관리하게 됩니다.
추후에는 분리해도 좋을 것 같네요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이렇게 반응형 미디어 쿼리를 여러 곳에서 사용하게 되면 아래와 같은 상황이 헷갈리게 됩니다.

  1. 데스크탑 우선 vs 모바일 우선: min-width / max-width 차이
  2. px 기준

그래서 보통은, 디자인 토큰이나 상수로 width 값을 관리하게 됩니다. 추후에는 분리해도 좋을 것 같네요!

오 그렇군요 이 부분은 향후 더 좋은 방향을 접하는대로 조금씩 개선해 나가겠습니다!

`;
13 changes: 13 additions & 0 deletions apps/react-world/src/components/shared/banner/Banner.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styled from '@emotion/styled';

export const Banner = styled.div`
color: #fff;
background: #333;
padding: 2rem;
margin-bottom: 2rem;
`;

export const BannerTitle = styled.h1`
text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
margin-bottom: 0px;
`;
17 changes: 17 additions & 0 deletions apps/react-world/src/components/shared/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ReactNode } from 'react';
import { Navbar } from './NavBar';
import { Footer } from './Footer';

type LayoutProps = {
children?: ReactNode;
};

export const Layout = ({ children }: LayoutProps) => {
return (
<>
<Navbar />
{children}
<Footer />
</>
);
};
1 change: 1 addition & 0 deletions apps/react-world/src/components/shared/layout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Layout.tsx';
2 changes: 1 addition & 1 deletion apps/react-world/src/routes/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import { Layout } from '../components/Layout';
import { Layout } from '../components/shared/layout/Layout';
import { HomePage } from '../pages/home';
import { LoginPage } from '../pages/login';
import { RegisterPage } from '../pages/register';
Expand Down
26 changes: 0 additions & 26 deletions apps/react-world/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5204,32 +5204,6 @@ footer {
.btn .counter {
font-size: 0.8rem !important; }

.home-page .banner {
background: #5CB85C;
box-shadow: inset 0 8px 8px -8px rgba(0, 0, 0, 0.3), inset 0 -8px 8px -8px rgba(0, 0, 0, 0.3); }
.home-page .banner p {
color: #fff;
text-align: center;
font-size: 1.5rem;
font-weight: 300 !important;
margin-bottom: 0px; }
.home-page .banner h1 {
text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
font-weight: 700 !important;
text-align: center;
font-size: 3.5rem;
padding-bottom: 0.5rem; }

.home-page .feed-toggle {
margin-bottom: -1px; }

.home-page .sidebar {
padding: 5px 10px 10px 10px;
background: #f3f3f3;
border-radius: 4px; }
.home-page .sidebar p {
margin-bottom: 0.2rem; }

.article-page .banner {
padding: 2rem 0 2rem 0; }
.article-page .banner h1 {
Expand Down
Loading