-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- clean-up sidebar styling (consistent headings, real tags, remove evergreen components) - more abstraction around Tag component (variants, etc) - abstract Collapse - replace Badge with Tag in documents index view
- Loading branch information
Showing
8 changed files
with
165 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
|
||
import { Icons } from "./icons"; | ||
|
||
type CollapseProps = React.PropsWithChildren<{ | ||
defaultOpen?: boolean; | ||
heading: string; | ||
}>; | ||
|
||
/** | ||
* Collapse component that can be toggled open and closed. | ||
*/ | ||
export function Collapse({ heading, defaultOpen, children }: CollapseProps) { | ||
const [isOpen, setIsOpen] = React.useState( | ||
defaultOpen == null ? false : defaultOpen, | ||
); | ||
|
||
const Icon = isOpen ? Icons.chevronDown : Icons.chevronRight; | ||
|
||
return ( | ||
<div> | ||
<div | ||
className="text-md mb-2 flex cursor-pointer items-center font-medium tracking-tight" | ||
onClick={() => setIsOpen(!isOpen)} | ||
> | ||
{heading} | ||
<Icon size={18} /> | ||
</div> | ||
{isOpen && children} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
import { Badge } from "evergreen-ui"; | ||
import React from "react"; | ||
import { SearchItem } from "./SearchStore"; | ||
import { ClickableTag } from "../../components/TagInput"; | ||
import { SearchItem, useSearchStore } from "./SearchStore"; | ||
|
||
export function DocumentItem(props: { | ||
doc: SearchItem; | ||
edit: (id: string) => any; | ||
getName: (id: string) => string; | ||
}) { | ||
const { doc, edit, getName } = props; | ||
const search = useSearchStore()!; | ||
|
||
return ( | ||
<div | ||
key={doc.id} | ||
onClick={() => edit(doc.id)} | ||
className="hover:underline-offset flex cursor-pointer hover:underline" | ||
> | ||
<div key={doc.id} className="flex items-center"> | ||
{/* Without mono font, dates won't be a uniform width */} | ||
<div className="mr-6 shrink-0 font-mono text-sm tracking-tight"> | ||
{doc.createdAt.slice(0, 10)} | ||
</div> | ||
<div className="font-sans"> | ||
<div | ||
className="hover:underline-offset mr-2 cursor-pointer font-sans hover:underline" | ||
onClick={() => edit(doc.id)} | ||
> | ||
{doc.title} | ||
<small> | ||
<Badge | ||
color="purple" | ||
fontWeight={400} | ||
textTransform="none" | ||
marginLeft={8} | ||
> | ||
{getName(doc.journalId)} | ||
</Badge> | ||
</small> | ||
</div> | ||
<ClickableTag | ||
size="xs" | ||
variant="muted" | ||
onClick={() => search.addToken(`in:${getName(doc.journalId)}`)} | ||
> | ||
in:{getName(doc.journalId)} | ||
</ClickableTag> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters