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

feat: display note path in search modal #121

Merged
merged 2 commits into from
Oct 29, 2021
Merged
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
22 changes: 20 additions & 2 deletions components/portal/search-modal/search-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import MarkText from 'components/portal/filter-modal/mark-text'
import PortalState from 'libs/web/state/portal'
import classNames from 'classnames'
import useScrollView from 'libs/web/hooks/use-scroll-view'
import NoteTreeState from 'libs/web/state/tree'
import { Breadcrumbs } from '@material-ui/core'

const SearchItem: FC<{
note: NoteCacheItem
Expand All @@ -15,8 +17,9 @@ const SearchItem: FC<{
const {
search: { close },
} = PortalState.useContainer()
const ref = useRef<HTMLLIElement>(null)
const { getPaths } = NoteTreeState.useContainer()

const ref = useRef<HTMLLIElement>(null)
useScrollView(ref, selected)

return (
Expand All @@ -31,10 +34,25 @@ const SearchItem: FC<{
<h4 className="text-sm font-bold">
<MarkText text={note.title} keyword={keyword} />
</h4>
<Breadcrumbs
maxItems={4}
itemsBeforeCollapse={2}
itemsAfterCollapse={2}
className="text-gray-600 leading-none -mx-0.5"
aria-label="breadcrumb"
>
{getPaths(note)
.reverse()
.map((path) => (
<span key={path.id} className="px-0.5 py-0.5 text-xs truncate">
{path.title}
</span>
))}
</Breadcrumbs>
<p className="mt-1">
<MarkText text={note.rawContent} keyword={keyword} />
</p>
<time className="text-gray-300 mt-2 block" dateTime={note.date}>
<time className="text-gray-500 mt-2 block" dateTime={note.date}>
{dayjs(note.date).format('DD/MM/YYYY HH:mm')}
</time>
</a>
Expand Down