Skip to content

Commit

Permalink
feat: display note path in search modal (#121)
Browse files Browse the repository at this point in the history
Co-authored-by: cinwell.li <cinwell.li@gmail.com>
  • Loading branch information
tuur29 and QingWei-Li authored Oct 29, 2021
1 parent 8c20dac commit 4314e6c
Showing 1 changed file with 20 additions and 2 deletions.
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

0 comments on commit 4314e6c

Please sign in to comment.