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

#233 카테고리 배너 재조정 #235

Merged
merged 4 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-gtm-module": "^2.0.11",
"react-helmet": "^6.1.0",
"react-mobile-datepicker": "^4.0.2",
"react-range": "^1.8.13",
"react-router-dom": "^6.2.1",
Expand Down Expand Up @@ -53,8 +54,9 @@
"@types/node": "^16.7.13",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/react-slick": "^0.23.10",
"@types/react-gtm-module": "^2.0.1",
"@types/react-helmet": "^6.1.6",
"@types/react-slick": "^0.23.10",
"@types/styled-components": "^5.1.25",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
Expand Down
40 changes: 26 additions & 14 deletions src/@components/CategoryPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Helmet } from "react-helmet";
import { useNavigate } from "react-router-dom";
import { useSetRecoilState } from "recoil";

import { IcSmallRightArrow } from "../../asset/icon/index";
import { ImgCategoryBanner } from "../../asset/image";
import { OriginImgCategoryBanner } from "../../asset/image/origin";
import { sliderIdxState } from "../../core/atom/slider";
import { routePaths } from "../../core/routes/path";
import { categoryTitles } from "../../util/category/categoryList";
Expand All @@ -10,7 +13,7 @@ import Header from "../@common/Header";
import HeadingTitleContainer from "../@common/HeadingTitleContainer";
import useScroll from "../@common/hooks/useScroll";
import CategoryContents from "./CategoryContents";
import { St } from "./style";
import St from "./style";

export default function CategoryPage() {
useScroll();
Expand All @@ -24,18 +27,27 @@ export default function CategoryPage() {
};

return (
<St.Root>
<Header />
<St.CategoryBanner>
<St.BannerTitle>베스트 카드들만 모아서 보기</St.BannerTitle>
<St.BannerSubTitle>북마크를 가장 많이 달성한 핫한 대화 주제 30선</St.BannerSubTitle>
<St.GoBestPiickleBtn type="button" className={GTM_CLASS_NAME.moodShowCard} onClick={moveBestPiickle}>
<St.BtnTitle>카드보기</St.BtnTitle>
<IcSmallRightArrow />
</St.GoBestPiickleBtn>
</St.CategoryBanner>
<HeadingTitleContainer headingTitles={categoryTitles} />
<CategoryContents />
</St.Root>
<>
<Helmet>
<link rel="preload" as="image" href={ImgCategoryBanner} />
</Helmet>
Comment on lines +29 to +31
Copy link
Contributor

Choose a reason for hiding this comment

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

메인 페이지뿐만 아니라, 카테고리 배너도 <Helmet />에 넣어주는 이유는 무엇일까용?-?

Copy link
Member Author

Choose a reason for hiding this comment

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

이미지 파일을 한 파일에서만 import 하고 싶었어요...!
페이지마다, 혹은 html에 그냥 하는 게 나으려나요?!

Copy link
Member Author

Choose a reason for hiding this comment

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

혹은- 정적 파일들을 이미지 파일로 불러오는 데에도 리소스가 들어서,
정적 파일이라면 base64로 바꿔서 html을 파싱할 때 바로 로드되게끔 하는 방법도 있을 것 같아요!

Copy link
Contributor

Choose a reason for hiding this comment

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

이미지 파일을 한 파일에서 import 한다는 게 잘 이해가 안됐습니다😂 좀 더 설명해주실 수 있을까용?!

Copy link
Member Author

Choose a reason for hiding this comment

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

제가 질문을 잘 이해를 못한 것 같아요.
메인 페이지, 카테고리 배너 각각 다른 이미지 파일을 프리로드 하기 위해 각각 Helmet을 선언한 건데,
어떤 다른 방법이 있는 걸까요??!

Copy link
Contributor

Choose a reason for hiding this comment

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

옷 카테고리 배너도 프리로드 하는 이유가 궁금하다는 질뭉이었어요,,!
제가 질문을 아리까리하게 했네요 ㅎㅎ,,

Copy link
Member Author

Choose a reason for hiding this comment

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

아하!!!! 카테고리 페이지에 들어갈 때 배너 이미지가 빨리 보이게 하기 위함이었어요

<St.Root>
<Header />
<St.CategoryBanner>
<picture>
<source srcSet={ImgCategoryBanner} type="image/webp" />
<St.BgImg src={OriginImgCategoryBanner} alt="" />
</picture>
<St.BannerTitle>베스트 카드들만 모아서 보기</St.BannerTitle>
<St.BannerSubTitle>북마크를 가장 많이 달성한 핫한 대화 주제 30선</St.BannerSubTitle>
<St.GoBestPiickleBtn type="button" className={GTM_CLASS_NAME.moodShowCard} onClick={moveBestPiickle}>
<St.BtnTitle>카드보기</St.BtnTitle>
<IcSmallRightArrow />
</St.GoBestPiickleBtn>
</St.CategoryBanner>
<HeadingTitleContainer headingTitles={categoryTitles} />
<CategoryContents />
</St.Root>
</>
);
}
118 changes: 65 additions & 53 deletions src/@components/CategoryPage/style.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,68 @@
import styled from "styled-components";

import { ImgCategoryBanner } from "../../asset/image";
import { OriginImgCategoryBanner } from "../../asset/image/origin";

export const St = {
Root: styled.main`
display: flex;
flex-direction: column;
margin-bottom: 4rem;
margin-top: -2.4rem;
`,

CategoryBanner: styled.section`
height: 17.9rem;
padding: 2rem 0 0 1.6rem;

background-image: url(${ImgCategoryBanner});
background-image: image-set(
${ImgCategoryBanner} type("image/webp"),
${OriginImgCategoryBanner} type("image/png"),
)
background-size: cover;

position: relative;
`,

BannerTitle: styled.h2`
${({ theme }) => theme.newFonts.graphic1};
color: ${({ theme }) => theme.colors.darkblue};
`,

BannerSubTitle: styled.p`
${({ theme }) => theme.newFonts.h2};
color: ${({ theme }) => theme.colors.gray800};
`,

GoBestPiickleBtn: styled.button`
position: absolute;

height: 1.5rem;
right: 1.6rem;
bottom: 1.2rem;

color: ${({ theme }) => theme.colors.gray900};
${({ theme }) => theme.newFonts.btn2};

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

BtnTitle: styled.p`
margin-right: 0.8rem;
`,
const Root = styled.main`
display: flex;
flex-direction: column;
margin-bottom: 4rem;
margin-top: -2.4rem;
`;

const CategoryBanner = styled.section`
height: 17.9rem;
padding: 2rem 0 0 1.6rem;

position: relative;
`;

const BgImg = styled.img`
position: absolute;
left: 0;
top: 0;

width: 100%;
height: 17.9rem;

object-fit: cover;

z-index: -10;
`;

const BannerTitle = styled.h2`
${({ theme }) => theme.newFonts.graphic1};
color: ${({ theme }) => theme.colors.darkblue};
`;

const BannerSubTitle = styled.p`
${({ theme }) => theme.newFonts.h2};
color: ${({ theme }) => theme.colors.gray800};
`;

const GoBestPiickleBtn = styled.button`
position: absolute;

height: 1.5rem;
right: 1.6rem;
bottom: 1.2rem;

color: ${({ theme }) => theme.colors.gray900};
${({ theme }) => theme.newFonts.btn2};

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

const BtnTitle = styled.p`
margin-right: 0.8rem;
`;

const St = {
Root,
CategoryBanner,
BgImg,
BannerTitle,
BannerSubTitle,
GoBestPiickleBtn,
BtnTitle,
};
export default St;
36 changes: 21 additions & 15 deletions src/@components/MainPage/Banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";

import { useState } from "react";
import { Helmet } from "react-helmet";
import Slider from "react-slick";

import { bannerImage } from "../../../util/main/banner";
Expand All @@ -22,21 +23,26 @@ export default function Banner() {
};

return (
<St.BannerSlider>
<Slider {...settings}>
{bannerImage.map((img, index) => (
<picture key={index}>
<source srcSet={img.src} type="image/webp" />
<St.ImageWrapper src={img.subSrc} alt={img.alt} loading="lazy" />
</picture>
))}
</Slider>
<>
<Helmet>
<link rel="preload" as="image" href={bannerImage[0].src} />
</Helmet>
<St.BannerSlider>
<Slider {...settings}>
{bannerImage.map((img, index) => (
<picture key={index}>
<source srcSet={img.src} type="image/webp" />
<St.ImageWrapper src={img.subSrc} alt={img.alt} loading="lazy" />
</picture>
))}
</Slider>

<St.ContentsPages>
<St.CurrentPage>
{currentSlide + 1} / {bannerImage.length}
</St.CurrentPage>
</St.ContentsPages>
</St.BannerSlider>
<St.ContentsPages>
<St.CurrentPage>
{currentSlide + 1} / {bannerImage.length}
</St.CurrentPage>
</St.ContentsPages>
</St.BannerSlider>
</>
);
}
29 changes: 28 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,13 @@
resolved "https://registry.yarnpkg.com/@types/react-gtm-module/-/react-gtm-module-2.0.1.tgz#b2c6cd14ec251d6ae7fa576edf1d43825908a378"
integrity sha512-T/DN9gAbCYk5wJ1nxf4pSwmXz4d1iVjM++OoG+mwMfz9STMAotGjSb65gJHOS5bPvl6vLSsJnuC+y/43OQrltg==

"@types/react-helmet@^6.1.6":
version "6.1.6"
resolved "https://registry.yarnpkg.com/@types/react-helmet/-/react-helmet-6.1.6.tgz#7d1afd8cbf099616894e8240e9ef70e3c6d7506d"
integrity sha512-ZKcoOdW/Tg+kiUbkFCBtvDw0k3nD4HJ/h/B9yWxN4uDO8OkRksWTO+EL+z/Qu3aHTeTll3Ro0Cc/8UhwBCMG5A==
dependencies:
"@types/react" "*"

"@types/react-slick@^0.23.10":
version "0.23.10"
resolved "https://registry.yarnpkg.com/@types/react-slick/-/react-slick-0.23.10.tgz#56126e6e4e95cdce7771535b2811c2c1931a7caa"
Expand Down Expand Up @@ -7920,7 +7927,7 @@ prompts@^2.0.1, prompts@^2.4.2:
kleur "^3.0.3"
sisteransi "^1.0.5"

prop-types@^15.8.1:
prop-types@^15.7.2, prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand Down Expand Up @@ -8065,11 +8072,26 @@ react-error-overlay@^6.0.11:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb"
integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==

react-fast-compare@^3.1.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.1.tgz#53933d9e14f364281d6cba24bfed7a4afb808b5f"
integrity sha512-xTYf9zFim2pEif/Fw16dBiXpe0hoy5PxcD8+OwBnTtNLfIm3g6WxhKNurY+6OmdH1u6Ta/W/Vl6vjbYP1MFnDg==

react-gtm-module@^2.0.11:
version "2.0.11"
resolved "https://registry.yarnpkg.com/react-gtm-module/-/react-gtm-module-2.0.11.tgz#14484dac8257acd93614e347c32da9c5ac524206"
integrity sha512-8gyj4TTxeP7eEyc2QKawEuQoAZdjKvMY4pgWfycGmqGByhs17fR+zEBs0JUDq4US/l+vbTl+6zvUIx27iDo/Vw==

react-helmet@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-6.1.0.tgz#a750d5165cb13cf213e44747502652e794468726"
integrity sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==
dependencies:
object-assign "^4.1.1"
prop-types "^15.7.2"
react-fast-compare "^3.1.1"
react-side-effect "^2.1.0"

react-is@^16.13.1, react-is@^16.7.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
Expand Down Expand Up @@ -8170,6 +8192,11 @@ react-scripts@5.0.1:
optionalDependencies:
fsevents "^2.3.2"

react-side-effect@^2.1.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-2.1.2.tgz#dc6345b9e8f9906dc2eeb68700b615e0b4fe752a"
integrity sha512-PVjOcvVOyIILrYoyGEpDN3vmYNLdy1CajSFNt4TDsVQC5KpTijDvWVoR+/7Rz2xT978D8/ZtFceXxzsPwZEDvw==

react-slick@^0.29.0:
version "0.29.0"
resolved "https://registry.yarnpkg.com/react-slick/-/react-slick-0.29.0.tgz#0bed5ea42bf75a23d40c0259b828ed27627b51bb"
Expand Down