-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feat/#228 suspense
- Loading branch information
Showing
29 changed files
with
259 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { PropsWithChildren, Suspense } from "react"; | ||
import { ErrorBoundary } from "react-error-boundary"; | ||
|
||
import Error404Page from "../../Error404Page"; | ||
import Loading from "../Loading"; | ||
|
||
interface SuspenseBoundaryProps { | ||
bgColor?: string; | ||
} | ||
|
||
const SuspenseBoundary = ({ children, bgColor }: PropsWithChildren<SuspenseBoundaryProps>) => { | ||
return ( | ||
<ErrorBoundary fallback={<Error404Page />}> | ||
<Suspense fallback={<Loading backgroundColor={bgColor || "transparent"} />}>{children}</Suspense> | ||
</ErrorBoundary> | ||
); | ||
}; | ||
|
||
export default SuspenseBoundary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/@components/CardCollectionPage/hooks/useCardListsFilter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useEffect } from "react"; | ||
import { useRecoilState } from "recoil"; | ||
|
||
import { filterTagsState } from "../../../core/atom/slider"; | ||
import { LocationType } from "../../../types/cardCollection"; | ||
import { intimacyTags } from "../../../util/cardCollection/filter"; | ||
import useNavigateCardCollection, { | ||
NavigateCardCollectionFilterType, | ||
} from "../../@common/hooks/useNavigateCardCollection"; | ||
|
||
const useCardListsFilter = (isFilterTypeLocation: boolean) => { | ||
const navigateCardCollection = useNavigateCardCollection(LocationType.FILTER) as NavigateCardCollectionFilterType; | ||
|
||
const [filterTags, setFilterTags] = useRecoilState(filterTagsState); | ||
|
||
useEffect(() => { | ||
if (isFilterTypeLocation) setFilterTags((prev) => ({ ...prev, isActive: false })); | ||
}, [isFilterTypeLocation, setFilterTags]); | ||
|
||
const fetchCardListsWithFilter = () => { | ||
// 남 -> 남자, 여 -> 여자 | ||
const _fetchingCheckedTags = new Set([...filterTags.tags, intimacyTags[filterTags.intimacy[0]]]); | ||
if (_fetchingCheckedTags.has("남")) { | ||
_fetchingCheckedTags.delete("남"); | ||
_fetchingCheckedTags.add("남자"); | ||
} | ||
if (_fetchingCheckedTags.has("여")) { | ||
_fetchingCheckedTags.delete("여"); | ||
_fetchingCheckedTags.add("여자"); | ||
} | ||
|
||
setFilterTags((prevFilterTags) => { | ||
return { ...prevFilterTags, isActive: true }; | ||
}); | ||
|
||
navigateCardCollection([..._fetchingCheckedTags]); | ||
}; | ||
|
||
return { fetchCardListsWithFilter }; | ||
}; | ||
|
||
export default useCardListsFilter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Helmet } from "react-helmet"; | ||
|
||
import { IcSmallRightArrow } from "../../../asset/icon"; | ||
import { ImgCategoryBanner } from "../../../asset/image"; | ||
import { OriginImgCategoryBanner } from "../../../asset/image/origin"; | ||
import { LocationType } from "../../../types/cardCollection"; | ||
import { GTM_CLASS_NAME } from "../../../util/const/gtm"; | ||
import useNavigateCardCollection, { | ||
NavigateCardCollectionBestType, | ||
} from "../../@common/hooks/useNavigateCardCollection"; | ||
import St from "./style"; | ||
|
||
const CategoryBanner = () => { | ||
const navigateCardCollection = useNavigateCardCollection(LocationType.BEST) as NavigateCardCollectionBestType; | ||
|
||
return ( | ||
<> | ||
<Helmet> | ||
<link rel="preload" as="image" href={ImgCategoryBanner} /> | ||
</Helmet> | ||
|
||
<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={() => navigateCardCollection()}> | ||
<St.BtnTitle className={GTM_CLASS_NAME.moodShowCard}>카드보기</St.BtnTitle> | ||
<IcSmallRightArrow /> | ||
</St.GoBestPiickleBtn> | ||
</St.CategoryBanner> | ||
</> | ||
); | ||
}; | ||
|
||
export default CategoryBanner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import styled from "styled-components"; | ||
|
||
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 = { | ||
CategoryBanner, | ||
BgImg, | ||
BannerTitle, | ||
BannerSubTitle, | ||
GoBestPiickleBtn, | ||
BtnTitle, | ||
}; | ||
export default St; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.