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: 중복 디자인 수정 #167

Merged
merged 5 commits into from
Jul 27, 2024
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
Binary file added src/assets/heart-empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Common/CategoryItem/CategoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const CategoryItem = ({
>
<div>
<img
className={cx(category, { [circle]: isCircular })}
className={cx(categoryImage, { [circle]: isCircular })}
src={image}
width={width}
height={height}
Expand Down
1 change: 1 addition & 0 deletions src/components/Common/CategoryItem/categoryItem.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const imageWrapper = style({

export const categoryImage = style({
objectFit: 'cover',
borderRadius: 4,
});

export const circle = style({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { container } from './recipeFavoriteButton.css';
import { container, countWrapper } from './recipeFavoriteButton.css';

import HeartEmpty from '@/assets/heart-empty.png';
import { SvgIcon, Text } from '@/components/Common';
import { useTimeout } from '@/hooks/common';
import { useMemberQuery } from '@/hooks/queries/members';
Expand Down Expand Up @@ -27,16 +28,25 @@ const RecipeFavoriteButton = ({ recipeId, favorite, favoriteCount }: RecipeFavor
<div className={container}>
{member ? (
<button type="button" onClick={debouncedToggleFavorite}>
<SvgIcon variant={favorite ? 'heartFilled' : 'heartEmpty'} width={24} height={24} />
{favorite ? (
<SvgIcon variant="heartFilled" width={24} height={24} />
) : (
<img src={HeartEmpty} alt="좋아요" width={24} height={24} />
)}
</button>
) : (
<div>
<SvgIcon variant="heartEmpty" width={24} height={24} />
<img src={HeartEmpty} alt="좋아요" width={24} height={24} />
</div>
)}

{favoriteCount && (
<div className={countWrapper}>
<Text as="span" size="caption1" weight="medium" color="sub">
{favoriteCount}
</Text>
</div>
)}
<Text as="span" size="caption1" weight="medium" color="sub">
{favoriteCount}
</Text>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ import { style } from '@vanilla-extract/css';
export const container = style({
display: 'flex',
alignItems: 'center',
gap: 6,
});

export const countWrapper = style({
marginLeft: 6,
});
2 changes: 1 addition & 1 deletion src/mocks/data/recipeDetail.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
],
"totalPrice": 7000,
"favoriteCount": 153,
"favorite": true,
"favorite": false,
"createdAt": "2023-08-02T13:43:06.379389"
}
8 changes: 4 additions & 4 deletions src/mocks/handlers/recipeHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import mockRecipes from '../data/recipes.json';

export const recipeHandlers = [
rest.get('/api/recipes/:recipeId', (req, res, ctx) => {
const { mockSessionId } = req.cookies;
// const { mockSessionId } = req.cookies;

if (!mockSessionId) {
return res(ctx.status(401));
}
// if (!mockSessionId) {
// return res(ctx.status(401));
// }

return res(ctx.status(200), ctx.json(recipeDetail), ctx.delay(1000));
}),
Expand Down
Loading