Skip to content

Commit 414dc6c

Browse files
authored
Merge pull request #116 from DevKor-github/feat/#106/no-results
2 parents 8c16d8c + 54b699f commit 414dc6c

File tree

6 files changed

+102
-12
lines changed

6 files changed

+102
-12
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { cx } from '@styled-system/css';
2+
3+
import * as s from './style.css';
4+
5+
interface Props {
6+
type: 'search' | '404';
7+
}
8+
const NoResult = ({ type }: Props) => {
9+
const icon = type === 'search' ? 'mgc_alert_fill' : 'mgc_puzzled_fill';
10+
const title = type === 'search' ? '๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ์—†์–ด์š”!' : '์•—, ์ž˜๋ชป๋œ ์ ‘๊ทผ์ด์—์š”!';
11+
const description = type === 'search' ? '๋‹ค๋ฅธ ํ‚ค์›Œ๋“œ๋กœ ๋‹ค์‹œ ๊ฒ€์ƒ‰ํ•ด ์ฃผ์„ธ์š”.' : '๋‹ค๋ฅธ ๊ฒฝ๋กœ๋กœ ์ ‘์†ํ•ด ์ฃผ์„ธ์š”.';
12+
return (
13+
<div className={s.Container}>
14+
<div
15+
className={cx(icon, s.Icon)}
16+
role="img"
17+
aria-label={type === 'search' ? '์•Œ๋ฆผ ์•„์ด์ฝ˜' : '๋‹นํ™ฉ ์•„์ด์ฝ˜'}
18+
/>
19+
<div className={s.Text}>
20+
<p>{title}</p>
21+
<p className={s.Description}>{description}</p>
22+
</div>
23+
</div>
24+
);
25+
};
26+
export default NoResult;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { css } from '@styled-system/css';
2+
3+
export const Container = css({
4+
display: 'flex',
5+
flexDir: 'column',
6+
gap: '1rem',
7+
alignItems: 'center',
8+
});
9+
10+
export const Icon = css({
11+
fontSize: '3rem',
12+
color: 'main',
13+
});
14+
15+
export const Text = css({
16+
display: 'flex',
17+
flexDir: 'column',
18+
alignItems: 'center',
19+
gap: '0.375rem',
20+
color: '100',
21+
fontSize: '1.25rem',
22+
fontWeight: 600,
23+
lineHeight: 1.4,
24+
letterSpacing: '-0.05rem',
25+
});
26+
27+
export const Description = css({
28+
color: '80',
29+
fontSize: '1rem',
30+
fontWeight: 400,
31+
letterSpacing: '-0.04rem',
32+
});

โ€Žsrc/features/home/components/ItemList/index.tsxโ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import NoResult from '@/common/components/NoResult';
12
import ItemCard from '@/features/home/components/ItemCard';
23
import type { ItemInterface } from '@/features/home/types';
34

@@ -7,11 +8,10 @@ interface Props {
78
itemList: ItemInterface[];
89
}
910
const ItemList = ({ itemList }: Props) => {
11+
const isEmpty = itemList.length === 0;
1012
return (
11-
<div className={s.Container}>
12-
{itemList.map(item => (
13-
<ItemCard key={item.itemId} data={item} />
14-
))}
13+
<div className={s.Container({ isEmpty })}>
14+
{isEmpty ? <NoResult type="search" /> : itemList.map(item => <ItemCard key={item.itemId} data={item} />)}
1515
</div>
1616
);
1717
};
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { css } from '@styled-system/css';
1+
import { cva } from '@styled-system/css';
22

3-
export const Container = css({
4-
display: 'flex',
5-
flexDir: 'column',
6-
gap: '1rem',
3+
export const Container = cva({
4+
base: {
5+
display: 'flex',
6+
flexDir: 'column',
7+
gap: '1rem',
8+
},
9+
variants: {
10+
isEmpty: {
11+
true: {
12+
justifyContent: 'center',
13+
alignItems: 'center',
14+
height: '100%',
15+
},
16+
},
17+
},
718
});

โ€Žsrc/pages/NotFoundPage/index.tsxโ€Ž

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import { useNavigate } from 'react-router';
22

3-
import Chip from '@/common/components/Chip';
43
import SafeArea from '@/common/components/SafeArea';
4+
import NoResult from '@/common/components/NoResult';
5+
import Btn from '@/common/components/Button';
6+
import * as s from './style.css';
57

68
const NotFoundPage = () => {
79
const navigate = useNavigate();
810

911
return (
1012
<SafeArea>
11-
<Chip onClick={() => navigate('/')}>ํ™ˆ์œผ๋กœ ๊ฐ€๊ธฐ</Chip>
12-
<h1>ํŽ˜์ด์ง€๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์–ด์š” . . .</h1>
13+
<div className={s.Container}>
14+
<NoResult type="404" />
15+
<Btn mode="main" className={s.Button} onClick={() => navigate('/')}>
16+
ํ™ˆ์œผ๋กœ ๋Œ์•„๊ฐ€๊ธฐ
17+
</Btn>
18+
</div>
1319
</SafeArea>
1420
);
1521
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { css } from '@styled-system/css';
2+
3+
export const Container = css({
4+
display: 'flex',
5+
width: 'full',
6+
height: 'full',
7+
alignItems: 'center',
8+
justifyContent: 'center',
9+
flexDir: 'column',
10+
gap: '2.25rem',
11+
});
12+
13+
export const Button = css({
14+
width: '17rem',
15+
});

0 commit comments

Comments
ย (0)