Skip to content
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

Merged
merged 10 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/assets/images/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export { default as TrashcanIcon } from './trashcan.svg';
export { default as UserCircleIcon } from './userCircle.svg';
export { default as ChevronIcon } from './chevron.svg';
export { default as Chevron2Icon } from './chevron2.svg';
export { default as XCircleIcon } from './xCircle.svg';
export { default as XSignIcon } from './xSign.svg';
export { default as EyeIcon } from './eye.svg';
export { default as ArrowUpIcon } from './arrowUp.svg';
export { default as SettingIcon } from './setting.svg';
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/assets/images/xCircle.svg

This file was deleted.

3 changes: 3 additions & 0 deletions frontend/src/assets/images/xSign.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 8 additions & 11 deletions frontend/src/components/TagButton/TagButton.style.ts
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')};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opacity 를 1로 하면 주변까지 다 리랜더링되어서 0.99로 해주신거였군요! 디테일👍👍

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;
}
`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변경사항

  • 태그 버튼의 색상이 생긴 후, 포커싱 되었을 때 강조 효과를 위한 스타일 수정입니다.
  • 포커싱 전/후 스타일 차이는 opacity, outline 입니다.

29 changes: 22 additions & 7 deletions frontend/src/components/TagButton/TagButton.tsx
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;
6 changes: 3 additions & 3 deletions frontend/src/components/TemplateCard/TemplateCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ const TemplateCard = ({ template }: Props) => {
</S.EllipsisTextWrapper>
</Flex>

<SourceCodeViewer mode='thumbnailView' content={thumbnail.content} />
<SourceCodeViewer mode='thumbnailView' filename={thumbnail.filename} content={thumbnail.content} />

<Flex justify='space-between' onClick={blockMovingToDetailPage}>
<S.TagListContainer>
{tags.map((tag: Tag) => (
<Flex key={tag.id}>
<TagButton name={tag.name} disabled={true} />
<TagButton id={tag.id} name={tag.name} disabled={true} />
</Flex>
))}
</S.TagListContainer>
Expand All @@ -92,7 +92,7 @@ const TemplateCard = ({ template }: Props) => {
{tags.length !== 0 && showAllTagList && (
<S.AllTagListContainer>
{tags.map((tag: Tag) => (
<TagButton key={tag.id} name={tag.name} disabled={true} />
<TagButton key={tag.id} id={tag.id} name={tag.name} disabled={true} />
))}
</S.AllTagListContainer>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변경사항

태그 버튼이 포커싱 되었을 때, outline과 shadow가 잘리는 현상을 해결하기 위한 변경사항 입니다.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변경사항

태그 버튼이 잘리는 것을 해결하기 위한 변경사항입니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이게 태그 메뉴 스켈레톤에도 반영되고 있는 값이라, 상수로 관리되면 좋을 것 같다는 생각이 드네요!

어딘가 스타일적인 요소에 대한 상수도 정의해두어도 좋을 것 같아요!!


interface Props {
tagList: Tag[];
Expand Down Expand Up @@ -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 && (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/TemplatePage/TemplatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const TemplatePage = () => {

<Flex gap='0.25rem' wrap='wrap'>
{template.tags.map((tag) => (
<TagButton key={tag.id} name={tag.name} disabled></TagButton>
<TagButton key={tag.id} id={tag.id} name={tag.name} disabled />
))}
</Flex>
<div
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/style/tagColors.ts
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변경사항

태그 버튼 포커싱 스타일을 위하여 회의 시점 색상보다 border의 색상이 진해졌습니다. (채도+, 명도-)


export const INPUT_TAG_COLOR = {
background: '#fcfcfc',
border: '#777777',
};