refactor: note options tag selection menu

This commit is contained in:
Aman Harwara
2022-11-27 23:33:26 +05:30
parent 3c91b0cb17
commit 2026d8b936

View File

@@ -9,6 +9,7 @@ import { IconType } from '@standardnotes/snjs'
import { getTitleForLinkedTag } from '@/Utils/Items/Display/getTitleForLinkedTag' import { getTitleForLinkedTag } from '@/Utils/Items/Display/getTitleForLinkedTag'
import { useApplication } from '../ApplicationView/ApplicationProvider' import { useApplication } from '../ApplicationView/ApplicationProvider'
import MenuItem from '../Menu/MenuItem' import MenuItem from '../Menu/MenuItem'
import Menu from '../Menu/Menu'
type Props = { type Props = {
navigationController: NavigationController navigationController: NavigationController
@@ -53,30 +54,32 @@ const AddTagOption: FunctionComponent<Props> = ({ navigationController, notesCon
align="start" align="start"
className="py-2" className="py-2"
> >
{navigationController.tags.map((tag) => ( <Menu a11yLabel="Tag selection menu" isOpen={isOpen}>
<MenuItem {navigationController.tags.map((tag) => (
key={tag.uuid} <MenuItem
onClick={() => { key={tag.uuid}
notesController.isTagInSelectedNotes(tag) onClick={() => {
? notesController.removeTagFromSelectedNotes(tag).catch(console.error) notesController.isTagInSelectedNotes(tag)
: notesController.addTagToSelectedNotes(tag).catch(console.error) ? notesController.removeTagFromSelectedNotes(tag).catch(console.error)
}} : notesController.addTagToSelectedNotes(tag).catch(console.error)
> }}
{tag.iconString && (
<Icon
type={tag.iconString as IconType}
size={'custom'}
className={'ml-0.5 mr-1.5 h-7 w-7 text-2xl text-neutral lg:h-6 lg:w-6 lg:text-lg'}
/>
)}
<span
className={`overflow-hidden overflow-ellipsis whitespace-nowrap
${notesController.isTagInSelectedNotes(tag) ? 'font-bold' : ''}`}
> >
{getTitleForLinkedTag(tag, application)?.longTitle} {tag.iconString && (
</span> <Icon
</MenuItem> type={tag.iconString as IconType}
))} size={'custom'}
className={'ml-0.5 mr-1.5 h-7 w-7 text-2xl text-neutral lg:h-6 lg:w-6 lg:text-lg'}
/>
)}
<span
className={`overflow-hidden overflow-ellipsis whitespace-nowrap
${notesController.isTagInSelectedNotes(tag) ? 'font-bold' : ''}`}
>
{getTitleForLinkedTag(tag, application)?.longTitle}
</span>
</MenuItem>
))}
</Menu>
</Popover> </Popover>
</div> </div>
) )