Skip to content

Commit

Permalink
Feat: RankIcon 컴포넌트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
se0kcess committed Oct 1, 2024
1 parent 00cb2af commit 37e6789
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/components/RankIcon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useTheme } from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faBookmark } from '@fortawesome/free-solid-svg-icons';
import * as S from './styles';

interface RankIconProps {
rank: 1 | 2 | 3;
}

const RankIcon = ({ rank }: RankIconProps) => {
const theme = useTheme();
const color = S.getRankColor(rank, theme);

return (
<S.RankIconWrapper color={color}>
<FontAwesomeIcon icon={faBookmark} />
<S.RankNumber>{rank}</S.RankNumber>
</S.RankIconWrapper>
);
};

export default RankIcon;
31 changes: 31 additions & 0 deletions src/components/RankIcon/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { H20 } from '@/components/Text';
import styled from 'styled-components';
import { DefaultTheme } from 'styled-components';

export const RankIconWrapper = styled.div<{ color: string }>`
position: relative;
display: inline-block;
color: ${props => props.color};
font-size: 48px;
`;

export const RankNumber = styled(H20)`
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: ${({ theme }) => theme.colors.white};
`;

export const getRankColor = (rank: number, theme: DefaultTheme) => {
switch (rank) {
case 1:
return theme.colors.yellow;
case 2:
return theme.colors.silver;
case 3:
return theme.colors.bronze;
default:
return theme.colors.black;
}
};

0 comments on commit 37e6789

Please sign in to comment.