Skip to content

Commit

Permalink
refactor(Categories): 패딩, 갭 등 바로잡고 약간의 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
joojjang committed Nov 17, 2024
1 parent 52ea3a4 commit 807fc1b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/constants/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const CATEGORY_LIST: Category[] = [
{
id: 1,
src: 'https://images.unsplash.com/photo-1580136608079-72029d0de130?w=800&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8NHx8JUVCJThGJTk5JUVDJTk2JTkxJUVBJUI3JUI4JUVCJUE2JUJDfGVufDB8fDB8fHww',
des: '동양화/ 한국화',
des: '동양화/한국화',
},
{
id: 2,
Expand Down
16 changes: 6 additions & 10 deletions src/pages/Categories/components/CategoryItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
import { Image } from '@chakra-ui/react';
import styled from '@emotion/styled';

interface CategoryItemProps {
des: string;
src: string;
des: string;
}

const CategoryItem = ({ des, src }: CategoryItemProps) => {
des = des.replace('/', '/\n');

const CategoryItem = ({ src, des }: CategoryItemProps) => {
return (
<Wrapper>
<RoundImage src={src} alt="CategoryImage" />
<CategoryThumbnail src={src} alt="Category thumbnail" />
<DesWrapper>{des}</DesWrapper>
</Wrapper>
);
};

export default CategoryItem;

const Wrapper = styled.div`
const Wrapper = styled.button`
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
gap: 8px;
`;

const RoundImage = styled(Image)`
const CategoryThumbnail = styled.img`
aspect-ratio: 1/1;
width: 80%;
width: 64px;
border-radius: 100%;
object-fit: cover;
background-color: var(--color-gray-lt);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Categories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import FakeSearchBar from '@/components/common/FakeSearchBar';
import SearchModal from '@/components/common/SearchModal';
import { CATEGORY_LIST } from '@/constants/categories';
import * as G from '@/styles/globalStyles';
import Category from './components/CategoryItem';
import CategoryItem from './components/CategoryItem';

const Categories = () => {
const [isModalOpen, setIsModalOpen] = useState(false);
Expand All @@ -21,7 +21,7 @@ const Categories = () => {
{isModalOpen && <SearchModal modalClose={() => setIsModalOpen(false)} />}
<G.Grid col={4}>
{CATEGORY_LIST.map((category) => (
<Category key={category.id} src={category.src} des={category.des} />
<CategoryItem key={category.id} src={category.src} des={category.des} />
))}
</G.Grid>
<G.Gap height={18} />
Expand Down
6 changes: 3 additions & 3 deletions src/styles/globalStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const HorizontalLine = styled.hr`

export const Grid = styled.div<{ col: number; justifyItems?: string }>`
display: grid;
grid-template-columns: ${({ col }) => (col === 2 ? 'repeat(2, 1fr)' : 'repeat(4, 1fr)')};
grid-template-columns: ${({ col }) => `repeat(${col}, 1fr)`};
justify-items: ${({ justifyItems }) => justifyItems || 'center'};
padding: ${({ col }) => (col === 2 ? '16px' : '24px 16px 32px 16px;')};
gap: ${({ col }) => (col === 2 ? '8px' : '40px 12px')};
padding: ${({ col }) => (col === 2 ? '16px' : '16px 16px 32px 16px;')};
gap: ${({ col }) => (col === 2 ? '8px' : '24px')};
`;

0 comments on commit 807fc1b

Please sign in to comment.