Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { PATH } from '@router/path';
import { IconName } from '@cds/icon';
import { Modal, Tooltip } from '@cds/ui';

import SidebarItem from '../sidebar-item/sidebar-item';
import NavItem from '@shared/components/nav-item/nav-item';

import { SidebarSelection } from '../type';

import * as styles from '../sidebar.css';
Expand Down Expand Up @@ -54,11 +55,7 @@ const SidebarMenuSection = ({
<Modal>
<Modal.Trigger>
<li key="search" className={styles.pannelItem}>
<SidebarItem
iconName="ic_search"
content="검색"
onClick={onExpand}
/>
<NavItem iconName="ic_search" content="검색" onClick={onExpand} />
<div className={styles.tooltip}>
<Tooltip title="검색" />
</div>
Expand All @@ -68,7 +65,7 @@ const SidebarMenuSection = ({
</Modal>
{MENU_ITEMS.map(({ id, iconName, text, path }) => (
<li key={id} className={styles.pannelItem}>
<SidebarItem
<NavItem
iconName={iconName}
content={text}
isSelected={selectedMenuPath === path}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { TagNode } from '@shared/apis/tag/type';
import NavItem from '@shared/components/nav-item/nav-item';
import TreeLine from '@shared/components/tree-line/tree-line';
import { TreeNode } from '@shared/utils/build-tree';

import SidebarItem from '../sidebar-item/sidebar-item';

interface SidebarTagItemProps {
tag: TreeNode<TagNode>;
selectedTagId: number | null;
Expand All @@ -19,7 +18,7 @@ const SidebarTagItem = ({

return (
<TreeLine.Item>
<SidebarItem
<NavItem
iconName="ic_tag"
content={tag.name}
isSelected={selectedTagId === tag.tagId}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Tooltip } from '@cds/ui';

import { useGetTag } from '@shared/apis/tag/queries';
import NavItem from '@shared/components/nav-item/nav-item';
import TreeLine from '@shared/components/tree-line/tree-line';

import SidebarItem from '../sidebar-item/sidebar-item';
import SidebarTagItem from '../sidebar-tag-item/sidebar-tag-item';
import { SidebarSelection } from '../type';

Expand Down Expand Up @@ -48,7 +48,7 @@ const SidebarTagSection = ({
) : (
<ul className={styles.pannelList}>
<li className={styles.pannelItem}>
<SidebarItem
<NavItem
iconName="ic_tag"
isSelected={selection.type === 'tag'}
onClick={onExpand}
Expand Down
5 changes: 3 additions & 2 deletions apps/client/src/shared/components/layouts/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { useLocation, useNavigate, useSearchParams } from 'react-router';
import { Icon } from '@cds/icon';
import { Tooltip } from '@cds/ui';

import NavItem from '@shared/components/nav-item/nav-item';

import { useSidebar } from './sidebar-context';
import SidebarItem from './sidebar-item/sidebar-item';
import SidebarMenuSection from './sidebar-menu-section/sidebar-menu-section';
import SidebarTagSection from './sidebar-tag-section/sidebar-tag-section';
import { SidebarSelection } from './type';
Expand Down Expand Up @@ -89,7 +90,7 @@ const Sidebar = () => {
<section className={styles.footerSection}>
<ul className={styles.pannelList}>
<li className={styles.pannelItem}>
<SidebarItem iconName="ic_profile" content="마이페이지" disabled />
<NavItem iconName="ic_profile" content="마이페이지" disabled />
<div className={styles.tooltip}>
<Tooltip title="마이페이지" />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { style } from '@vanilla-extract/css';
import { recipe } from '@vanilla-extract/recipes';

import { themeVars } from '@cds/ui';
Expand Down Expand Up @@ -31,10 +30,17 @@ export const container = recipe({
},
});

export const text = style({
...themeVars.fontStyles.body_m_16,
color: themeVars.color.grey700,
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
export const text = recipe({
base: {
color: themeVars.color.grey700,
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
},
variants: {
type: {
sm: themeVars.fontStyles.body_m_14,
lg: themeVars.fontStyles.body_m_16,
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,37 @@ import { ButtonHTMLAttributes } from 'react';

import { Icon, IconName } from '@cds/icon';

import * as styles from './sidebar-item.css';
import * as styles from './nav-item.css';

interface SidebarItemProps extends Pick<
interface NavItemProps extends Pick<
ButtonHTMLAttributes<HTMLButtonElement>,
'onClick' | 'disabled'
> {
iconName: IconName;
content?: string;
isSelected?: boolean;
type?: 'sm' | 'lg';
}

const SidebarItem = ({
const NavItem = ({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

MenuItem 어떠신가요?
Nav의 navigation은 페이지 이동이 가능하다는 의미를 함축하고 있어서,
shared 컴포넌트로 사용한다면 Menu처럼 더 추상적인 개념으로 접근하면 좋을 것 같아요

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

어떤 컴포넌트 이름을 하게되든 이 컴포넌트 props가 ButtonHTMLAttributes를 상속받는다고 예상하기 어려워용

onClick과 disabled도 props로 직접 드러내면 좋을 것 같아요!
상속은 아예 없애구요

iconName,
content,
isSelected,
type = 'lg',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

type 대신 iconSize를 보내면 좋아보여요
NavItem이라는 컴포넌트를 사용할 때 type이 어떤 내용물을 사이즈를 말하는 건지 알기 어려워용

추가적으로 만약에 10개의 사용처에서 서로 다른 type을 요구한다면 type이 점점 커질 거에요
그래서 이럴 때는 책임을 사용처로 옮기면 코드가 편해져여

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

css 파일을 보니까 type에 따라 스타일을 다르게 적용하고 있네용
이런 경우까지 고려하면 children props로 외부에서 의존성 주입을 하는 방향을 고려해보면 좋을 것 같아요

...props
}: SidebarItemProps) => {
}: NavItemProps) => {
return (
<button
{...props}
type="button"
className={styles.container({ isSelected })}
>
<Icon name={iconName} size={32} />
{content != null && <span className={styles.text}>{content}</span>}
<Icon name={iconName} size={type === 'lg' ? 32 : 24} />
{content != null && (
<span className={styles.text({ type })}>{content}</span>
)}
</button>
);
};

export default SidebarItem;
export default NavItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { style } from '@vanilla-extract/css';

import { themeVars } from '@cds/ui';

export const container = style({
position: 'relative',
height: '100%',
maxHeight: '25.6rem',
padding: '0.4rem 1.8rem 0.4rem 0',
borderRight: `1px solid ${themeVars.color.grey200}`,
overflowY: 'auto',
overflowX: 'hidden',
});

export const list = style({
display: 'flex',
flexDirection: 'column',
gap: '0.4rem',
width: '13.2rem',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { TagNode } from '@shared/apis/tag/type';
import NavItem from '@shared/components/nav-item/nav-item';

import * as styles from './parent-tag-list.css';

interface ParentTagListProps {
tags: TagNode[];
selectedTagId: number;
onSelect: (tagId: number) => void;
}

const ParentTagList = ({
tags,
selectedTagId,
onSelect,
}: ParentTagListProps) => {
return (
<div className={styles.container}>
<ul className={styles.list}>
{tags.map(({ tagId, name }) => (
<li key={tagId}>
<NavItem
type="sm"
iconName="ic_tag"
content={name}
isSelected={selectedTagId === tagId}
onClick={() => onSelect(tagId)}
/>
</li>
))}
</ul>
</div>
);
};

export default ParentTagList;
3 changes: 3 additions & 0 deletions packages/cds-ui/src/styles/global.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ globalStyle('html, body', {
padding: 0,
fontSize: '62.5%',
fontFamily: `'Pretendard Variable', sans-serif`,
});

globalStyle('*', {
scrollbarWidth: 'thin',
scrollbarColor: `${themeVars.color.grey300} transparent`,
scrollBehavior: 'smooth',
Expand Down
Loading