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
@@ -1,30 +1,21 @@
import { Icon } from '@cds/icon';
import { Tag } from '@cds/ui';

import { TagDisplayInfo } from '@shared/types/tag';
import { formatTodayTimeOrDate } from '@shared/utils/format-date';

import { MemoSearchItemData } from '../../types';

import * as styles from './memo-search-list-item.css';

const MAX_TAG_COUNT = 4;

interface MemoSearchListItemProps {
memoId: number;
title: string;
content: string;
openedAt: string;
tags?: TagDisplayInfo[];
memo: MemoSearchItemData;
onClickMemo: (memoId: number) => void;
}

const MemoSearchListItem = ({
memoId,
title,
content,
openedAt,
tags = [],
onClickMemo,
}: MemoSearchListItemProps) => {
const MemoSearchListItem = ({ memo, onClickMemo }: MemoSearchListItemProps) => {
const { memoId, title, content, openedAt, tags = [] } = memo;
const visibleTags = tags.slice(0, MAX_TAG_COUNT);

const handleClickMemo = () => {
Expand All @@ -40,7 +31,7 @@ const MemoSearchListItem = ({
onClick={handleClickMemo}
aria-label={`${title} 메모 상세 보기`}
/>
<div className={styles.header}>
<div className={styles.header} aria-hidden="true">
<div className={styles.mainInfo}>
<div className={styles.titleGroup}>
<Icon
Expand All @@ -66,7 +57,9 @@ const MemoSearchListItem = ({
{formatTodayTimeOrDate(openedAt)}
</time>
</div>
<p className={styles.content}>{content}</p>
<p className={styles.content} aria-hidden="true">
{content}
</p>
</article>
);
};
Expand Down
1 change: 1 addition & 0 deletions apps/client/src/features/memo-search-modal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as MemoSearchModal } from './memo-search-modal';
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { style } from '@vanilla-extract/css';

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

export const content = style({
overflow: 'hidden',
width: '82rem',
height: '62rem',
border: `1px solid ${themeVars.color.grey400}`,
borderRadius: '16px',
boxShadow: '0 0 24px 8px rgba(0, 0, 0, 0.08)',
});

export const container = style({
display: 'flex',
flexDirection: 'column',
width: '100%',
height: '100%',
backgroundColor: themeVars.color.white,
});

export const body = style({
display: 'flex',
flexDirection: 'column',
gap: '0.4rem',
flex: 1,
minHeight: 0,
padding: '1.8rem 0.8rem 1.8rem 2rem',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
padding: '1.8rem 0.8rem 1.8rem 2rem',
padding: '1.8rem 2rem'

body에 상하좌우 동일하게 패딩 넣고 list에서 패딩 설정하지 않아도 될 것 같은데 나눠서 스타일 적용한것이 궁금합니da🎃

});

export const sectionTitle = style({
padding: '0 1.4rem',
...themeVars.fontStyles.body_m_14,
color: themeVars.color.grey600,
});

export const list = style({
display: 'flex',
flexDirection: 'column',
gap: '0.4rem',
flex: 1,
minHeight: 0,
overflowY: 'auto',
paddingRight: '1.2rem',
paddingLeft: '0.4rem',
scrollbarWidth: 'thin',
scrollbarColor: `${themeVars.color.grey300} transparent`,

selectors: {
'&::-webkit-scrollbar': {
width: '0.8rem',
},
'&::-webkit-scrollbar-track': {
backgroundColor: 'transparent',
},
'&::-webkit-scrollbar-thumb': {
border: 'none',
borderRadius: '999px',
backgroundColor: themeVars.color.grey300,
backgroundClip: 'border-box',
},
},
});

export const emptyText = style({
...themeVars.fontStyles.body_m_14,
padding: '4rem 0',
color: themeVars.color.grey500,
textAlign: 'center',
});
75 changes: 75 additions & 0 deletions apps/client/src/features/memo-search-modal/memo-search-modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Modal } from '@cds/ui';

import MemoSearchListItem from './components/memo-search-list-item/memo-search-list-item';
import SearchBar from './components/search-bar/search-bar';
import { MemoSearchItemData } from './types';

import * as styles from './memo-search-modal.css';

const getSearchResultSectionTitle = (count: number) => {
return `검색 결과(${count}개)`;
};

interface MemoSearchModalProps {
open: boolean;
searchValue: string;
recentMemos: MemoSearchItemData[];
searchResultMemos?: MemoSearchItemData[];
onOpenChange: (open: boolean) => void;
onChangeSearchValue: (value: string) => void;
onSearch: (value: string) => void;
onClickMemo: (memoId: number) => void;
}

const MemoSearchModal = ({
open,
searchValue,
recentMemos,
searchResultMemos,
onOpenChange,
onChangeSearchValue,
onSearch,
onClickMemo,
}: MemoSearchModalProps) => {
const isSearchResult = searchResultMemos !== undefined;
const memos = searchResultMemos ?? recentMemos;
const resultCount = searchResultMemos?.length ?? 0;
const sectionTitle = isSearchResult
? getSearchResultSectionTitle(resultCount)
: '최근 열람한 메모';
Comment on lines +37 to +39

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

isSearchResult, resultCountsectionTitle에만 쓰이니 인라인으로 처리해도 좋을 것 같아엽떡
⚰️🦇🧛🏼

Suggested change
const sectionTitle = isSearchResult
? getSearchResultSectionTitle(resultCount)
: '최근 열람한 메모';
const sectionTitle = searchResultMemos
? getSearchResultSectionTitle(searchResultMemos.length)
: '최근 열람한 메모';


return (
<Modal open={open} onOpenChange={onOpenChange}>
<Modal.Content className={styles.content} ariaLabel="메모 검색">
<div className={styles.container}>
<SearchBar
value={searchValue}
onChange={onChangeSearchValue}
onSearch={onSearch}
/>
<div className={styles.body}>
{memos.length > 0 ? (
<>
<span className={styles.sectionTitle}>{sectionTitle}</span>
<div className={styles.list}>
{memos.map((memo) => (
<MemoSearchListItem
key={memo.memoId}
memo={memo}
onClickMemo={onClickMemo}
/>
))}
</div>
</>
) : (
// TODO: empty view 컴포넌트 디자인 확정되는 대로 교체 예정
<p className={styles.emptyText}>표시할 메모가 없습니다.</p>
)}
</div>
</div>
</Modal.Content>
</Modal>
);
};

export default MemoSearchModal;
9 changes: 9 additions & 0 deletions apps/client/src/features/memo-search-modal/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { TagDisplayInfo } from '@shared/types/tag';

export interface MemoSearchItemData {
memoId: number;
title: string;
content: string;
openedAt: string;
tags?: TagDisplayInfo[];
}
Loading