Skip to content

Commit 9f695e7

Browse files
authored
Merge pull request #138 from 2020-NAVER-CAMPUS-HACKDAY/develop
2 parents de0041a + d40a0a6 commit 9f695e7

24 files changed

+161
-52
lines changed

β€Žclient/components/CategoryHeader/ChildrenCard/index.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
import React, { FC } from 'react';
22
import useStyles from 'components/CategoryHeader/ChildrenCard/styles';
33
import { Category } from 'interfaces/category';
4+
import Router from 'next/router';
5+
import clsx from 'clsx';
46

57
interface ChildrenCardProps {
6-
childreanData: Category[];
8+
childrenData: Category[];
79
}
810
const ChildrenCard: FC<ChildrenCardProps> = (props) => {
9-
const { childreanData } = props;
11+
const { childrenData } = props;
1012
const classes = useStyles();
1113

14+
// TODO(jominjimail): duplicated function
15+
const setCategory = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>): void => {
16+
const categoryId: string = event.currentTarget.value;
17+
Router.push(`/tempCategoryDetail/${categoryId}`);
18+
};
19+
1220
return (
1321
<section className={classes.card}>
14-
{childreanData.map((child) => (
15-
<button key={child.categoryId} className={classes.cardContent}>
22+
{childrenData.map((child) => (
23+
<button
24+
key={child.categoryId}
25+
className={clsx(classes.button, classes.cardContent)}
26+
onClick={setCategory}
27+
value={child.categoryId}
28+
>
1629
{child.value.categoryName}
1730
</button>
1831
))}

β€Žclient/components/CategoryHeader/ChildrenCard/styles.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import { makeStyles } from '@material-ui/core/styles';
2+
import { AppColor } from 'constant';
23

34
const useStyles = makeStyles({
45
card: {
56
display: 'flex',
6-
backgroundColor: '#fff',
7+
backgroundColor: AppColor.GREY,
78
minWidth: '100%',
8-
height: '3rem',
9+
height: '2.5rem',
910
overflowX: 'auto',
1011
'&::-webkit-scrollbar': {
1112
display: 'none',
1213
},
1314
},
1415
cardContent: {
15-
display: 'flex',
1616
padding: '0 11px',
1717
whiteSpace: 'nowrap',
1818
},
19-
text: {
20-
width: '100%',
19+
button: {
20+
background: 'none',
21+
border: 'none',
22+
font: 'inherit',
23+
cursor: 'pointer',
24+
outline: 'inherit',
2125
},
2226
});
2327

β€Žclient/components/CategoryHeader/WholeCategoryName/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { FC } from 'react';
22
import useStyles from 'components/CategoryHeader/WholeCategoryName/styles';
33
import Router from 'next/router';
4+
import clsx from 'clsx';
45

56
interface CategoryBoxProps {
67
names: string;
@@ -13,16 +14,27 @@ const WholeCategoryName: FC<CategoryBoxProps> = (props) => {
1314
const idArray = ids.split('>');
1415
const lastIndex = nameArray.length - 1;
1516

17+
// TODO(jominjimail): duplicated function
1618
const setCategory = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>): void => {
1719
const categoryId: string = event.currentTarget.value;
1820
Router.push(`/tempCategoryDetail/${categoryId}`);
1921
};
2022

2123
const makeElement = (name, index): React.ReactElement => (
2224
(index === lastIndex)
23-
? <button className={classes.active} onClick={setCategory} value={idArray[index]}>
25+
? <button
26+
key={index}
27+
className={clsx(classes.button, classes.active)}
28+
onClick={setCategory}
29+
value={idArray[index]}
30+
>
2431
{name}</button>
25-
: <button className={classes.inactive} onClick={setCategory} value={idArray[index]}>
32+
: <button
33+
key={index}
34+
className={clsx(classes.button, classes.inactive)}
35+
onClick={setCategory}
36+
value={idArray[index]}
37+
>
2638
{name}</button>
2739
);
2840

β€Žclient/components/CategoryHeader/WholeCategoryName/styles.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const useStyles = makeStyles({
55
container: {
66
background: AppColor.WHITE,
77
display: 'flex',
8-
height: '3rem',
8+
height: '2.5rem',
99
color: 'black',
1010
},
1111
inactive: {
@@ -14,6 +14,13 @@ const useStyles = makeStyles({
1414
active: {
1515
color: AppColor.BLACK,
1616
},
17+
button: {
18+
background: 'none',
19+
border: 'none',
20+
font: 'inherit',
21+
cursor: 'pointer',
22+
outline: 'inherit',
23+
},
1724
});
1825

1926
export default useStyles;

β€Žclient/components/CategoryHeader/index.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
import React, { FC } from 'react';
22
import { Category } from 'interfaces/category';
33
import Router from 'next/router';
4+
import useStyles from 'components/CategoryHeader/styles';
5+
import { PublicImageCategoryPath, ImageArray, ImageExtension } from 'constant';
46

57
interface CategoryHeaderProps {
68
categoryData: Category[];
79
}
810

911
const CategoryHeader: FC<CategoryHeaderProps> = (props) => {
1012
const { categoryData } = props;
13+
const classes = useStyles();
1114

1215
const setCategory = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>): void => {
1316
const categoryId: string = event.currentTarget.value;
1417
Router.push(`/tempCategoryDetail/${categoryId}`);
1518
};
1619

17-
const categoryElements = categoryData.map((category) => {
20+
const categoryElements = categoryData.map((category, index) => {
1821
const { categoryId } = category;
1922
return (
20-
<button
21-
key={categoryId}
22-
onClick={setCategory}
23-
value={categoryId}>{category.value.categoryName}
24-
</button>
23+
<div className={classes.content} key={categoryId}>
24+
<button
25+
className={classes.button}
26+
onClick={setCategory}
27+
value={categoryId}
28+
>
29+
<img src={`${PublicImageCategoryPath}${ImageArray[index]}${ImageExtension.PNG}`}
30+
className={classes.image}
31+
></img>
32+
<div>{category.value.categoryName}</div>
33+
</button>
34+
</div>
2535
);
2636
});
2737

2838
return (
29-
<div>
39+
<div className={classes.container}>
3040
{categoryElements}
3141
</div>
3242
);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { makeStyles } from '@material-ui/core/styles';
2+
3+
const useStyles = makeStyles({
4+
container: {
5+
display: 'flex',
6+
flexWrap: 'wrap',
7+
justifyContent: 'flex-start',
8+
maxWidth: '375',
9+
padding: '0 0.5rem',
10+
},
11+
content: {
12+
display: 'flex',
13+
flexDirection: 'column',
14+
height: '5rem',
15+
justifyContent: 'center',
16+
margin: '0 0.3rem',
17+
width: '5rem',
18+
},
19+
button: {
20+
background: 'none',
21+
border: 'none',
22+
cursor: 'pointer',
23+
font: '8rem',
24+
outline: 'inherit',
25+
whiteSpace: 'nowrap',
26+
},
27+
image: {
28+
height: '2.5rem',
29+
width: '2.5rem',
30+
},
31+
});
32+
33+
export default useStyles;

β€Žclient/components/LikeList/LikeGridView/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const LikeGridView: FC<LikeGridViewProps> = (props) => {
1919

2020
const GridViewItem = categoryArray.map((category) => (
2121
<li className={classes.root} id={Category[category]} key={category} onClick={handleItemClick}>
22-
<div className={clsx(classes.images)}>
22+
<div id={Category[category]} className={clsx(classes.images)}>
2323
{itemArray[category]
2424
.map((item, index) => <ImageItem
2525
id={Category[category]}

β€Žclient/components/LikeList/LikeGridView/styles.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { AppColor } from 'constant';
33

44
const useStyles = makeStyles({
55
root: {
6-
display: 'inline-flex',
7-
justifyContent: 'flex-start',
8-
flexDirection: 'column',
6+
display: 'inline-block',
97
backgroundColor: AppColor.WHITE,
108
},
119
data: {

β€Žclient/constant.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,24 @@ export const LikePropsInitialValue = {
108108
lifeLike: [],
109109
dutyFreeLike: [],
110110
};
111+
112+
export const PublicImageCategoryPath = '/images/category/';
113+
114+
// TODO(jominjimail): replace this array with enum type
115+
export const ImageArray = [
116+
'icon_all_108x108',
117+
'icon_distilled_108x108',
118+
'icon_etc_108x108',
119+
'icon_fruit_liquor_108x108',
120+
'icon_gift_set_108x108',
121+
'icon_liqueur_108x108',
122+
'icon_raspberry_108x108',
123+
'icon_soju_108x108',
124+
'icon_takju_108x108',
125+
'icon_wine_108x108',
126+
'icon_yakju_108x108',
127+
];
128+
129+
export const ImageExtension = {
130+
PNG: '.png',
131+
};

β€Žclient/pages/tempCategoryDetail/[CategoryID].tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { GetServerSideProps } from 'next';
44
import { CategoryProps } from 'redux/ducks/category';
55
import { Category } from 'interfaces/category';
66
import { CATEGORY_API, CATEGORY_CHILDREN_API } from 'constant';
7-
import Router from 'next/router';
87
import ChildrenCard from 'components/CategoryHeader/ChildrenCard';
98
import WholeCategoryName from 'components/CategoryHeader/WholeCategoryName';
109

@@ -16,20 +15,14 @@ interface DetailCategoryProps extends CategoryProps {
1615
const DetailCategory: FC<DetailCategoryProps> = (props) => {
1716
const { categoryData, categoryChildrenData } = props;
1817

19-
const setCategory = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>): void => {
20-
const categoryId: string = event.currentTarget.value;
21-
Router.push(`/tempCategoryDetail/${categoryId}`);
22-
};
23-
2418
return (
2519
<MainHeader>
26-
<div>μΉ΄ν…Œκ³ λ¦¬ 상세 νŽ˜μ΄μ§€</div>
2720
<WholeCategoryName
2821
names={categoryData.value.wholeCategoryName}
2922
ids={categoryData.value.wholeCategoryId}
3023
>
3124
</WholeCategoryName>
32-
<ChildrenCard childreanData={categoryChildrenData}></ChildrenCard>
25+
<ChildrenCard childrenData={categoryChildrenData}></ChildrenCard>
3326
</MainHeader>
3427
);
3528
};

0 commit comments

Comments
Β (0)