-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(style): 태그 버튼 팔레트 정의 * feat(utils): 태그 버튼의 색상 선택 유틸함수 구현 * feat(src): 태그 버튼, 필터 디자인 변경 및 태그 색상 적용 * refactor(utils): getTagColor 유틸함수를 컴포넌트 내부에 구현 * refactor(TagInput): 템플릿 업로드/수정 중 태그 색상 기본색으로 변경 * refactor(src): 태그 필터에서 선택된 태그 구분을 위한 디자인 수정 * fix(TemplateCard): SourceCodeViewer에 filename 전달 * refactor(TagButton): 함수 분리 및 메모이제이션 수행 * refactor(TagButton): 불필요한 useMemo 제거 --------- Co-authored-by: 헤인 <[email protected]>
- Loading branch information
Showing
10 changed files
with
75 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import { theme } from '@/style/theme'; | ||
|
||
export const TagButtonWrapper = styled.button<{ isFocused: boolean }>` | ||
export const TagButtonWrapper = styled.button<{ background: string; border: string; isFocused: boolean }>` | ||
cursor: pointer; | ||
display: flex; | ||
gap: 0.5rem; | ||
gap: 0.75rem; | ||
align-items: center; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
height: 1.75rem; | ||
margin: 0.25rem; | ||
padding: 0 0.75rem; | ||
background-color: ${({ isFocused }) => (isFocused ? theme.color.light.primary_400 : theme.color.light.tertiary_50)}; | ||
border: 1px solid ${({ isFocused }) => (isFocused ? theme.color.light.primary_600 : theme.color.light.tertiary_200)}; | ||
border-radius: 2.5rem; | ||
opacity: ${({ isFocused }) => (isFocused ? '0.99' : '0.85')}; | ||
background-color: ${({ background }) => background}; | ||
border-radius: 0.5rem; | ||
outline: ${({ isFocused }) => (isFocused ? '1.5' : '1')}px solid ${({ border }) => border}; | ||
box-shadow: ${({ isFocused }) => isFocused && '0 0 3px #00000070'}; | ||
&:disabled { | ||
cursor: text; | ||
} | ||
&:not(:disabled):hover { | ||
box-shadow: 0 1px 4px #00000030; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
import { XCircleIcon } from '@/assets/images'; | ||
import { XSignIcon } from '@/assets/images'; | ||
import { Text } from '@/components'; | ||
import { TAG_COLORS, INPUT_TAG_COLOR } from '@/style/tagColors'; | ||
import { theme } from '@/style/theme'; | ||
|
||
import * as S from './TagButton.style'; | ||
|
||
interface Props { | ||
id?: number; | ||
name: string; | ||
isFocused?: boolean; | ||
disabled?: boolean; | ||
variant?: 'default' | 'edit'; | ||
onClick?: () => void; | ||
} | ||
|
||
const TagButton = ({ name, isFocused = false, disabled = false, variant = 'default', onClick }: Props) => ( | ||
<S.TagButtonWrapper isFocused={isFocused} disabled={disabled} onClick={() => onClick && onClick()}> | ||
<Text.Medium color={isFocused ? theme.color.light.white : theme.color.light.secondary_700}>{name}</Text.Medium> | ||
{variant === 'edit' && <XCircleIcon width={16} height={16} aria-label='태그 삭제' />} | ||
</S.TagButtonWrapper> | ||
); | ||
const getTagColor = (id?: number) => (id ? TAG_COLORS[id % TAG_COLORS.length] : INPUT_TAG_COLOR); | ||
|
||
const TagButton = ({ id, name, isFocused = false, disabled = false, variant = 'default', onClick }: Props) => { | ||
const { background, border } = getTagColor(id); | ||
|
||
return ( | ||
<S.TagButtonWrapper | ||
background={background} | ||
border={border} | ||
isFocused={isFocused} | ||
disabled={disabled} | ||
onClick={() => onClick && onClick()} | ||
> | ||
<Text.Medium color={theme.color.light.secondary_800}>{name}</Text.Medium> | ||
{variant === 'edit' && <XSignIcon width={10} height={10} aria-label='태그 삭제' />} | ||
</S.TagButtonWrapper> | ||
); | ||
}; | ||
|
||
export default TagButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const TAG_COLORS = [ | ||
{ background: '#fedfa2', border: '#dbba79' }, | ||
{ background: '#fcd0a0', border: '#db9651' }, | ||
{ background: '#fac9b5', border: '#e58762' }, | ||
{ background: '#dfd1f1', border: '#9779c5' }, | ||
{ background: '#cddcfc', border: '#6a9ad2' }, | ||
{ background: '#c7eafa', border: '#57aed3' }, | ||
{ background: '#d5e9e2', border: '#73b5a3' }, | ||
{ background: '#d1e6b0', border: '#96b962' }, | ||
{ background: '#eefab9', border: '#baca60' }, | ||
{ background: '#dfceb7', border: '#bd9a69' }, | ||
]; | ||
|
||
export const INPUT_TAG_COLOR = { | ||
background: '#fcfcfc', | ||
border: '#777777', | ||
}; |