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

refactor: 기초 recipe item 컴포넌트 구현 #83

Merged
merged 17 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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: 1 addition & 2 deletions src/components/Members/MemberRecipeList/MemberRecipeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useRef } from 'react';
import { Link as RouterLink } from 'react-router-dom';
import styled from 'styled-components';

import { RecipeItem } from '@/components/Recipe';
import { PATH } from '@/constants/path';
import { useIntersectionObserver } from '@/hooks/common';
import { useInfiniteMemberRecipeQuery } from '@/hooks/queries/members';
Expand Down Expand Up @@ -50,7 +49,7 @@ const MemberRecipeList = ({ isPreview = false }: MemberRecipeListProps) => {
{recipeToDisplay?.map((recipe) => (
<li key={recipe.id}>
<Link as={RouterLink} to={`${PATH.RECIPE}/${recipe.id}`}>
<RecipeItem recipe={recipe} isMemberPage={isPreview} />
{/* <RecipeItem recipe={recipe} isMemberPage={isPreview} /> */}
</Link>
</li>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Link } from 'react-router-dom';
import { container, moreIcon, moreIconWrapper, moreItem, moreLink } from './productRecipeList.css';

import { SvgIcon, Text } from '@/components/Common';
import { RecipeItem } from '@/components/Recipe';
import { DefaultRecipeItem } from '@/components/Recipe';
import RecipeItemProvider from '@/contexts/RecipeItemContext';
import { useInfiniteProductRecipesQuery } from '@/hooks/queries/product';
import { vars } from '@/styles/theme.css';
import displaySlice from '@/utils/displaySlice';
Expand All @@ -27,7 +28,9 @@ const ProductRecipeList = ({ productId }: ProductRecipeListProps) => {
<ul className={container}>
{recipeToDisplay.map((recipe) => (
<li key={recipe.id}>
<RecipeItem recipe={recipe} hasFavoriteButton />
<RecipeItemProvider recipe={recipe}>
<DefaultRecipeItem />
</RecipeItemProvider>
</li>
))}
{recipeToDisplay.length < recipes.length && (
Expand Down

This file was deleted.

33 changes: 0 additions & 33 deletions src/components/Rank/RecipeRankingItem/RecipeRankingItem.tsx

This file was deleted.

31 changes: 0 additions & 31 deletions src/components/Rank/RecipeRankingItem/recipeRankingItem.css.ts

This file was deleted.

7 changes: 5 additions & 2 deletions src/components/Rank/RecipeRankingList/RecipeRankingList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Link } from 'react-router-dom';

import { container } from './recipeRankingList.css';
import RecipeRankingItem from '../RecipeRankingItem/RecipeRankingItem';

import { DefaultRecipeItem } from '@/components/Recipe';
import { PATH } from '@/constants/path';
import RecipeItemProvider from '@/contexts/RecipeItemContext';
import { useGA } from '@/hooks/common';
import { useRecipeRankingQuery } from '@/hooks/queries/rank';

Expand All @@ -22,7 +23,9 @@ const RecipeRankingList = () => {
{recipeResponse.recipes.map((recipe) => (
<li key={recipe.id}>
<Link to={`${PATH.RECIPE}/${recipe.id}`} onClick={handleRecipeRankingLinkClick}>
<RecipeRankingItem recipe={recipe} />
<RecipeItemProvider recipe={recipe}>
<DefaultRecipeItem />
</RecipeItemProvider>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<RecipeItemProvider recipe={recipe}>
<DefaultRecipeItem />
</RecipeItemProvider>
<DefaultRecipeItem recipe={recipe} />

props로 내려주고

</Link>
</li>
))}
Expand Down
1 change: 0 additions & 1 deletion src/components/Rank/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ export { default as ReviewRankingItem } from './ReviewRankingItem/ReviewRankingI
export { default as ReviewRankingList } from './ReviewRankingList/ReviewRankingList';
export { default as ProductRankingItem } from './ProductRankingItem/ProductRankingItem';
export { default as ProductRankingList } from './ProductRankingList/ProductRankingList';
export { default as RecipeRankingItem } from './RecipeRankingItem/RecipeRankingItem';
export { default as RecipeRankingList } from './RecipeRankingList/RecipeRankingList';
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ import { style } from '@vanilla-extract/css';

export const container = style({
display: 'flex',
gap: 6,
alignItems: 'center',
});
42 changes: 37 additions & 5 deletions src/components/Recipe/RecipeItem/RecipeItem.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
import type { Meta, StoryObj } from '@storybook/react';

import RecipeItem from './RecipeItem';
import RecipeItem, {
DefaultRecipeItem,
RecipeItemWithDiskIcon,
RecipeItemWithDiskIconAndContent,
RecipeItemWithProductDetailImage,
} from './RecipeItem';

import RecipeItemProvider from '@/contexts/RecipeItemContext';
import mockRecipe from '@/mocks/data/recipes.json';

const meta: Meta<typeof RecipeItem> = {
title: 'recipe/RecipeItem',
component: RecipeItem,
args: {
recipe: mockRecipe.recipes[0],
},
decorators: [
(Story) => (
<RecipeItemProvider recipe={mockRecipe.recipes[1]}>
<Story />
</RecipeItemProvider>
),
],
};

export default meta;
type Story = StoryObj<typeof RecipeItem>;

export const Default: Story = {};
export const Default: Story = {
render: () => {
return <DefaultRecipeItem />;
},
};

export const Recipe: Story = {
render: () => {
return <RecipeItemWithDiskIconAndContent />;
},
};

export const MyPage: Story = {
render: () => {
return <RecipeItemWithProductDetailImage />;
},
};

export const Search: Story = {
render: () => {
return <RecipeItemWithDiskIcon />;
},
};
Loading
Loading