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: 꿀조합 검색 디자인 변경점 적용 #91

Merged
merged 13 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
3 changes: 2 additions & 1 deletion src/components/Recipe/RecipeItem/RecipeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
RECIPE_CARD_DEFAULT_IMAGE_URL_4,
RECIPE_CARD_DEFAULT_IMAGE_URL_5,
} from '@/constants/image';
import { PATH } from '@/constants/path';
import RecipeItemProvider from '@/contexts/RecipeItemContext';
import { useRecipeItemValueContext } from '@/hooks/context';
import type { Recipe } from '@/types/recipe';
Expand All @@ -50,7 +51,7 @@ const RecipeItem = ({ recipe, children }: RecipeItemProps) => {

return (
<RecipeItemProvider recipe={recipe}>
<Link to={`${id}`}>{children}</Link>
<Link to={`${PATH.RECIPE}/${id}`}>{children}</Link>
</RecipeItemProvider>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useRef } from 'react';
import { Link } from 'react-router-dom';

import { linkWrapper, listWrapper, showMore } from './recipeSearchResultPreviewList.css';
import SearchNotFound from '../SearchNotFound/SearchNotFound';

import { SvgIcon, Text } from '@/components/Common';
import { DefaultRecipeItem } from '@/components/Recipe';
import { PATH } from '@/constants/path';
import { useIntersectionObserver } from '@/hooks/common';
import { useInfiniteRecipeSearchResultsQuery } from '@/hooks/queries/search';
import { vars } from '@/styles/theme.css';
import displaySlice from '@/utils/displaySlice';

interface RecipeSearchResultPreviewListProps {
searchQuery: string;
}

const RecipeSearchResultPreviewList = ({ searchQuery }: RecipeSearchResultPreviewListProps) => {
const { data: searchResponse, fetchNextPage, hasNextPage } = useInfiniteRecipeSearchResultsQuery(searchQuery);
const scrollRef = useRef<HTMLDivElement>(null);
useIntersectionObserver<HTMLDivElement>(fetchNextPage, scrollRef, hasNextPage);

const recipes = searchResponse.pages.flatMap((page) => page.recipes);

if (recipes.length === 0) {
return <SearchNotFound />;
}

return (
<ul className={listWrapper}>
{displaySlice(false, recipes, 4).map((recipe, idx) => (
<li key={recipe.id}>
{idx < 4 ? (
<DefaultRecipeItem recipe={recipe} />
) : (
<Link to={`${PATH.SEARCH}/recipes?query=${searchQuery}`} className={linkWrapper}>
<div className={showMore}>
<SvgIcon variant="arrowRight" stroke={vars.colors.gray5} />
</div>
<Text size="caption2" weight="semiBold" color="info">
전체보기
</Text>
</Link>
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.

옹 이거 뭐죠?!

Copy link
Contributor

Choose a reason for hiding this comment

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

전체보기! 상품 상세 꿀조합 리스트에도 있슴다

)}
</li>
))}
</ul>
);
};

export default RecipeSearchResultPreviewList;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { vars } from '@/styles/theme.css';
import { style } from '@vanilla-extract/css';

export const listWrapper = style({
display: 'flex',
gap: 10,
alignItems: 'center',
overflowY: 'scroll',
});

export const showMore = style({
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: 40,
height: 40,
background: vars.colors.secondary1,
borderRadius: '50%',
});

export const linkWrapper = style({
display: 'flex',
flexDirection: 'column',
gap: 12,
alignItems: 'center',
width: 45,
});
4 changes: 2 additions & 2 deletions src/components/Search/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { default as ProductSearchResultPreviewList } from './ProductSearchResultList/ProductSearchResultPreviewList';
export { default as ProductSearchResultPreviewList } from './ProductSearchResultPreviewList/ProductSearchResultPreviewList';
export { default as RecommendList } from './RecommendList/RecommendList';
export { default as RecipeSearchResultList } from './RecipeSearchResultList/RecipeSearchResultList';
export { default as RecipeSearchResultPreviewList } from './RecipeSearchResultPreviewList/RecipeSearchResultPreviewList';
export { default as TagSearchResultList } from './TagSearchResultList/TagSearchResultList';
export { default as SearchInput } from './SearchInput/SearchInput';
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { useRef } from 'react';
import { Link } from 'react-router-dom';
import { styled } from 'styled-components';
import { useSearchParams } from 'react-router-dom';

import SearchNotFound from '../SearchNotFound/SearchNotFound';
import { listWrapper } from './recipeSearchListPage.css';

import { RecipeItem } from '@/components/Recipe';
import { PATH } from '@/constants/path';
import { PageHeader } from '@/components/Common';
import { DefaultRecipeItem } from '@/components/Recipe';
import SearchNotFound from '@/components/Search/SearchNotFound/SearchNotFound';
import { useIntersectionObserver } from '@/hooks/common';
import { useInfiniteRecipeSearchResultsQuery } from '@/hooks/queries/search';

interface RecipeSearchResultListProps {
searchQuery: string;
}
export const RecipeSearchListPage = () => {
const [searchParams, setSearchParams] = useSearchParams();
const searchQuery = searchParams.get('query') || '';

const RecipeSearchResultList = ({ searchQuery }: RecipeSearchResultListProps) => {
const { data: searchResponse, fetchNextPage, hasNextPage } = useInfiniteRecipeSearchResultsQuery(searchQuery);
const scrollRef = useRef<HTMLDivElement>(null);
useIntersectionObserver<HTMLDivElement>(fetchNextPage, scrollRef, hasNextPage);
Expand All @@ -26,24 +25,15 @@ const RecipeSearchResultList = ({ searchQuery }: RecipeSearchResultListProps) =>

return (
<>
<RecipeSearchResultListContainer>
<PageHeader title={`'${searchQuery}'이/가 포함된 꿀조합`} hasBackLink />
Copy link
Contributor

Choose a reason for hiding this comment

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

요거 TopBar랑 디자인 다른가용??

Copy link
Member Author

Choose a reason for hiding this comment

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

오오 교체 가능

<ul className={listWrapper}>
{recipes.map((recipe) => (
<li key={recipe.id}>
<Link to={`${PATH.RECIPE}/${recipe.id}`}>
<RecipeItem recipe={recipe} />
</Link>
<DefaultRecipeItem recipe={recipe} />
</li>
))}
</RecipeSearchResultListContainer>
</ul>
<div ref={scrollRef} aria-hidden />
</>
);
};

export default RecipeSearchResultList;

const RecipeSearchResultListContainer = styled.ul`
& > li + li {
margin-top: 40px;
}
`;
8 changes: 8 additions & 0 deletions src/pages/RecipeSearchListPage/recipeSearchListPage.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { style } from '@vanilla-extract/css';

export const listWrapper = style({
display: 'grid',
gridTemplateColumns: '1fr 1fr',
gap: '16px 10px',
padding: '0 20px',
});
4 changes: 2 additions & 2 deletions src/pages/SearchPage/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { badgeContainer, searchWrapper, searchResultTitle, searchSection, subTit
import { Text, Badge, ErrorBoundary, ErrorComponent, Loading, PageHeader } from '@/components/Common';
import {
ProductSearchResultPreviewList,
RecipeSearchResultList,
RecipeSearchResultPreviewList,
RecommendList,
SearchInput,
} from '@/components/Search';
Expand Down Expand Up @@ -87,7 +87,7 @@ export const SearchPage = () => {
</Text>
<ErrorBoundary fallback={ErrorComponent}>
<Suspense fallback={<Loading />}>
<RecipeSearchResultList searchQuery={searchQuery} />
<RecipeSearchResultPreviewList searchQuery={searchQuery} />
</Suspense>
</ErrorBoundary>
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ const router = createBrowserRouter([
return { Component: ProductSearchListPage };
},
},
{
path: `${PATH.SEARCH}/recipes`,
async lazy() {
const { RecipeSearchListPage } = await import(
/* webpackChunkName: "RecipeSearchListPage" */ '@/pages/RecipeSearchListPage/RecipeSearchListPage'
);
return { Component: RecipeSearchListPage };
},
},
],
},
]);
Expand Down
Loading