-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
태그 버튼 색상 적용 #765
태그 버튼 색상 적용 #765
Changes from 7 commits
8e8b8ab
b09514b
f63354b
ef32ae9
566c538
5d7268c
2dd0d29
753b9cb
4a2f047
7ef2a62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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; | ||
} | ||
`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 변경사항
|
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 TagButton = ({ id, name, isFocused = false, disabled = false, variant = 'default', onClick }: Props) => { | ||
const getTagColor = (id?: number) => (id ? TAG_COLORS[id % TAG_COLORS.length] : INPUT_TAG_COLOR); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,11 @@ import { theme } from '@/style/theme'; | |
|
||
export const TagFilterMenuContainer = styled.div` | ||
display: flex; | ||
gap: 1rem; | ||
gap: 0.5rem; | ||
align-items: flex-start; | ||
|
||
width: 100%; | ||
padding: 1rem; | ||
padding: 0.75rem 0.75rem 0 0.75rem; | ||
|
||
border: 1px solid ${theme.color.light.secondary_300}; | ||
border-radius: 8px; | ||
|
@@ -19,10 +19,11 @@ export const TagButtonsContainer = styled.div<{ height: string }>` | |
display: flex; | ||
flex-wrap: wrap; | ||
gap: 0.5rem; | ||
align-items: flex-start; | ||
align-items: center; | ||
|
||
width: 100%; | ||
height: ${({ height }) => height}; | ||
margin-bottom: 0.75rem; | ||
|
||
transition: height 0.3s ease-in-out; | ||
`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 변경사항태그 버튼이 포커싱 되었을 때, outline과 shadow가 잘리는 현상을 해결하기 위한 변경사항 입니다. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { remToPx } from '@/utils'; | |
|
||
import * as S from './TagFilterMenu.style'; | ||
|
||
const LINE_HEIGHT_REM = 1.875; | ||
const LINE_HEIGHT_REM = 2.25; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 변경사항태그 버튼이 잘리는 것을 해결하기 위한 변경사항입니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이게 태그 메뉴 스켈레톤에도 반영되고 있는 값이라, 상수로 관리되면 좋을 것 같다는 생각이 드네요! 어딘가 스타일적인 요소에 대한 상수도 정의해두어도 좋을 것 같아요!! |
||
|
||
interface Props { | ||
tagList: Tag[]; | ||
|
@@ -69,10 +69,23 @@ const TagFilterMenu = ({ tagList, selectedTagIds, onSelectTags }: Props) => { | |
<S.TagFilterMenuContainer data-testid='tag-filter-menu'> | ||
<S.TagButtonsContainer ref={containerRef} height={height}> | ||
{selectedTags.map((tag) => ( | ||
<TagButton key={tag.id} name={tag.name} isFocused={true} onClick={() => handleButtonClick(tag.id)} /> | ||
<TagButton | ||
key={tag.id} | ||
id={tag.id} | ||
name={tag.name} | ||
isFocused={true} | ||
variant='edit' | ||
onClick={() => handleButtonClick(tag.id)} | ||
/> | ||
))} | ||
{unselectedTags.map((tag) => ( | ||
<TagButton key={tag.id} name={tag.name} isFocused={false} onClick={() => handleButtonClick(tag.id)} /> | ||
<TagButton | ||
key={tag.id} | ||
id={tag.id} | ||
name={tag.name} | ||
isFocused={false} | ||
onClick={() => handleButtonClick(tag.id)} | ||
/> | ||
))} | ||
</S.TagButtonsContainer> | ||
{showMoreButton && ( | ||
|
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' }, | ||
]; | ||
Comment on lines
+1
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 변경사항태그 버튼 포커싱 스타일을 위하여 회의 시점 색상보다 border의 색상이 진해졌습니다. (채도+, 명도-) |
||
|
||
export const INPUT_TAG_COLOR = { | ||
background: '#fcfcfc', | ||
border: '#777777', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opacity 를 1로 하면 주변까지 다 리랜더링되어서 0.99로 해주신거였군요! 디테일👍👍