Skip to content
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
2 changes: 1 addition & 1 deletion src/components/Card/Card.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const typeCss = {
height: 50vw;
}
${media.desktop} {
height: rem(200px);
height: ${pxToRem(200)};
@media (max-width: 1547px) {
height: 20vw;
}
Expand Down
7 changes: 1 addition & 6 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ export const Card = ({
<CardContainer $type={type} $background={background}>
<figure>
<CardFigureImgContainer $type={type}>
<Image
src={'https://spoonacular.com/recipeImages/Chopped-Kale-Salad-with-Pomegranate---Avocado-584495.jpg'}
title={title}
layout="fill"
priority
/>
<Image src={imgSrc} title={title} layout="fill" priority />
</CardFigureImgContainer>
<CardFigcaption $headingPosition={headingPosition}>{title}</CardFigcaption>
</figure>
Expand Down
8 changes: 4 additions & 4 deletions src/components/HotRecipes/HotRecipes.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export const HotRecipesCardItem = styled.li`
text-align: center;
width: ${pxToRem(290)};

@media (max-width: 1547px) {
width: 50%;
@media (max-width: 1100px) {
width: 100%;
text-align: center;
}

@media (max-width: 1100px) {
width: 100%;
@media (max-width: 2500px) {
width: 50%;
text-align: center;
}
`;
5 changes: 3 additions & 2 deletions src/components/HotRecipes/HotRecipes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const HotRecipes = () => {
if (loading) {
return <SkeletonCard type="square" background="none" hasSummary={false} headingPosition="bottomCenter" />;
}

return (
<Card
id={recipeId}
Expand All @@ -27,8 +28,8 @@ export const HotRecipes = () => {
<HotRecipesSection>
<HotRecipesHeader as="h2">Hot Recipes</HotRecipesHeader>
<HotRecipesCardList>
{hotRecipes.map((recipe, idx) => {
return <HotRecipesCardItem key={idx}>{renderCards(recipe)}</HotRecipesCardItem>;
{hotRecipes.map((recipe) => {
return <HotRecipesCardItem key={recipe.title}>{renderCards(recipe)}</HotRecipesCardItem>;
})}
</HotRecipesCardList>
</HotRecipesSection>
Expand Down
18 changes: 9 additions & 9 deletions src/hooks/useHotRecipes.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { getHotRecipes } from 'api/customApi';
import { useEffect, useState } from 'react';

export const useHotRecipes = () => {
const [hotRecipes, setHotRecipes] = useState([]);
const [loading, setLoading] = useState(true);

// 이 부분 custom API 완료후 적용!
// useEffect(() => {
// (async () => {
// setHotRecipes(await getHotRecipes());
// })();
// setTimeout(() => {
// setLoading(false);
// }, 1200);
// }, []);
useEffect(() => {
(async () => {
setHotRecipes(await getHotRecipes());
})();
setTimeout(() => {
setLoading(false);
}, 1200);
}, []);

return { hotRecipes, loading };
};
23 changes: 22 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
import type { NextPage } from 'next';
import Head from 'next/head';
import { HotRecipes, RandomRecipe } from 'components';
import { media } from 'utils';
import { css } from '@emotion/react';

const Home: NextPage = () => {
return <div>Home</div>;
return (
<>
<Head>
<title>Home - HanSpoon</title>
</Head>
<div
css={css`
${media.desktop} {
display: flex;
flex-direction: row;
}
`}
>
<RandomRecipe />
<HotRecipes />
</div>
</>
);
};

export default Home;