Skip to content

Commit

Permalink
refactor: 공통 컴포넌트 style 파일 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
se0kcess committed Dec 1, 2024
1 parent 8e6de57 commit 96d0005
Show file tree
Hide file tree
Showing 35 changed files with 635 additions and 552 deletions.
31 changes: 31 additions & 0 deletions src/components/ui/BackButton/BackButton.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import styled from '@emotion/styled';

interface BackButtonProps {
width?: string;
height?: string;
}

export const Button = styled.button<BackButtonProps>`
cursor: pointer;
border: none;
background: transparent;
width: ${(props) => props.width};
height: ${(props) => props.height};
display: flex;
align-items: center;
justify-content: center;
padding: 0;
svg {
width: 70%;
height: 70%;
transition: all 0.3s ease-in-out;
}
&:hover {
svg {
color: gray;
transform: translateX(-5px);
}
}
`;
27 changes: 1 addition & 26 deletions src/components/ui/BackButton/BackButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useNavigate } from 'react-router-dom';
import { IoIosArrowBack } from 'react-icons/io';
import styled from '@emotion/styled';
import { Button } from '@/components/ui/BackButton/BackButton.styles';

interface BackButtonProps {
width?: string;
Expand All @@ -21,29 +21,4 @@ const BackButton = ({ width = '2.5rem', height = '2.5rem' }: BackButtonProps) =>
);
};

const Button = styled.button<BackButtonProps>`
cursor: pointer;
border: none;
background: transparent;
width: ${(props) => props.width};
height: ${(props) => props.height};
display: flex;
align-items: center;
justify-content: center;
padding: 0;
svg {
width: 70%;
height: 70%;
transition: all 0.3s ease-in-out;
}
&:hover {
svg {
color: gray;
transform: translateX(-5px);
}
}
`;

export default BackButton;
22 changes: 22 additions & 0 deletions src/components/ui/CategoryButtons/CategoryButton.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import theme from '@/styles/theme';
import styled from '@emotion/styled';

export const StyledTag = styled.button<{ isSelected?: boolean }>`
padding: 0.5rem 1.25rem;
border-radius: 50px;
border: 1px solid ${theme.colors.gray[300]};
background-color: ${(props) => (props.isSelected ? theme.colors.primary : theme.colors.white)};
color: ${(props) => (props.isSelected ? theme.colors.white : theme.colors.gray[500])};
font-family: ${theme.typography.body1.fontFamily};
font-size: ${theme.typography.body1.size};
font-weight: ${theme.typography.body1.weight};
line-height: ${theme.typography.body1.lineHeight};
cursor: pointer;
transition: all 0.2s ease-in-out;
flex-shrink: 0;
&:hover {
background-color: ${(props) =>
props.isSelected ? theme.colors.primary : theme.colors.gray[100]};
}
`;
23 changes: 1 addition & 22 deletions src/components/ui/CategoryButtons/CategoryButton.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
import { StyledTag } from '@/components/ui/CategoryButtons/CategoryButton.styles';
import { useState, useEffect } from 'react';
import styled from '@emotion/styled';
import theme from '@/styles/theme';

interface CategoryTagProps {
label: string;
initialSelected?: boolean;
onChange?: (isSelected: boolean) => void;
}

const StyledTag = styled.button<{ isSelected?: boolean }>`
padding: 0.5rem 1.25rem;
border-radius: 50px;
border: 1px solid ${theme.colors.gray[300]};
background-color: ${(props) => (props.isSelected ? theme.colors.primary : theme.colors.white)};
color: ${(props) => (props.isSelected ? theme.colors.white : theme.colors.gray[500])};
font-family: ${theme.typography.body1.fontFamily};
font-size: ${theme.typography.body1.size};
font-weight: ${theme.typography.body1.weight};
line-height: ${theme.typography.body1.lineHeight};
cursor: pointer;
transition: all 0.2s ease-in-out;
flex-shrink: 0;
&:hover {
background-color: ${(props) =>
props.isSelected ? theme.colors.primary : theme.colors.gray[100]};
}
`;

const CategoryButton = ({ label, initialSelected = false, onChange }: CategoryTagProps) => {
const [isSelected, setIsSelected] = useState(initialSelected);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import styled from '@emotion/styled';
import theme from '@/styles/theme';

export const Grid = styled.div`
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1rem;
`;

export const CategoryCard = styled.button<{ isSelected: boolean }>`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: ${theme.colors.white};
border-radius: 1rem;
padding: 1rem 0.5rem;
cursor: pointer;
border: 3px solid ${(props) => (props.isSelected ? theme.colors.primary : 'transparent')};
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
transition: all 0.2s ease-in-out;
aspect-ratio: 1;
width: 100%;
&:hover {
transform: translateY(-2px);
}
`;

export const IconWrapper = styled.div`
width: 2rem;
height: 2rem;
margin-bottom: 0.5rem;
display: flex;
align-items: center;
justify-content: center;
`;

export const CategoryIcon = styled.img`
width: 100%;
height: 100%;
object-fit: contain;
`;

export const TextContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
margin-top: 0.25rem;
`;

export const KoreanName = styled.span`
color: ${theme.colors.primary};
font-size: 1rem;
font-weight: ${theme.typography.weights.bold};
`;

export const EnglishName = styled.span`
color: ${theme.colors.gray[400]};
font-size: 0.6rem;
`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import styled from '@emotion/styled';
import theme from '@/styles/theme';
import { useState } from 'react';

// 이미지 import
Expand All @@ -9,6 +7,15 @@ import fashionImg from '@/assets/images/fashion.jpg';
import cultureImg from '@/assets/images/culture.jpg';
import matzipImg from '@/assets/images/matzip.jpg';
import etcImg from '@/assets/images/etc.jpg';
import {
CategoryCard,
CategoryIcon,
EnglishName,
Grid,
IconWrapper,
KoreanName,
TextContainer,
} from '@/components/ui/CategorySelectContainer/CategorySelectContainer.styles';

interface CategoryItem {
id: string;
Expand Down Expand Up @@ -61,63 +68,4 @@ const CategorySelectContainer = ({ onCategorySelect }: CategorySelectContainerPr
);
};

const Grid = styled.div`
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1rem;
`;

const CategoryCard = styled.button<{ isSelected: boolean }>`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: ${theme.colors.white};
border-radius: 1rem;
padding: 1rem 0.5rem;
cursor: pointer;
border: 3px solid ${(props) => (props.isSelected ? theme.colors.primary : 'transparent')};
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
transition: all 0.2s ease-in-out;
aspect-ratio: 1;
width: 100%;
&:hover {
transform: translateY(-2px);
}
`;

const IconWrapper = styled.div`
width: 2rem;
height: 2rem;
margin-bottom: 0.5rem;
display: flex;
align-items: center;
justify-content: center;
`;

const CategoryIcon = styled.img`
width: 100%;
height: 100%;
object-fit: contain;
`;

const TextContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
margin-top: 0.25rem;
`;

const KoreanName = styled.span`
color: ${theme.colors.primary};
font-size: 1rem;
font-weight: ${theme.typography.weights.bold};
`;

const EnglishName = styled.span`
color: ${theme.colors.gray[400]};
font-size: 0.6rem;
`;

export default CategorySelectContainer;
63 changes: 63 additions & 0 deletions src/components/ui/CommentList/CommentList.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import styled from '@emotion/styled';
import theme from '@/styles/theme';
import { Avatar } from '@chakra-ui/react';

export const Container = styled.div`
display: flex;
flex-direction: column;
`;

export const CommentItem = styled.div`
display: flex;
gap: 1rem;
border-bottom: 1px solid ${theme.colors.gray[300]};
cursor: pointer;
&:hover {
background: ${theme.colors.sub};
}
padding: 0.75rem 0;
`;

export const StyledAvatar = styled(Avatar)`
width: 3rem !important;
height: 3rem !important;
border-radius: 100% !important;
& > img {
border-radius: 100% !important;
}
`;

export const CommentContent = styled.div`
flex: 1;
`;

export const AuthorInfo = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.25rem;
`;

export const AuthorName = styled.span`
color: ${theme.colors.gray[400]};
font-weight: ${theme.typography.weights.medium};
font-size: ${theme.typography.body2.size};
`;

export const CreatedAt = styled.span`
color: ${theme.colors.gray[200]};
font-size: ${theme.typography.body3.size};
`;

export const Content = styled.p`
color: ${theme.colors.black};
font-size: ${theme.typography.body2.size};
font-weight: ${theme.typography.weights.regular};
`;

export const ActionButtons = styled.div`
display: flex;
margin-top: 0.5rem;
`;
Loading

0 comments on commit 96d0005

Please sign in to comment.