refactor: repo (#1070)

This commit is contained in:
Mo
2022-06-07 07:18:41 -05:00
committed by GitHub
parent 4c65784421
commit f4ef63693c
1102 changed files with 5786 additions and 3366 deletions

View File

@@ -0,0 +1,36 @@
import VisuallyHidden from '@reach/visually-hidden'
import { observer } from 'mobx-react-lite'
import { FunctionComponent, useCallback } from 'react'
import Icon from '@/Components/Icon/Icon'
import { NotesController } from '@/Controllers/NotesController'
type Props = {
className?: string
notesController: NotesController
onClickPreprocessing?: () => Promise<void>
}
const PinNoteButton: FunctionComponent<Props> = ({ className = '', notesController, onClickPreprocessing }: Props) => {
const notes = notesController.selectedNotes
const pinned = notes.some((note) => note.pinned)
const togglePinned = useCallback(async () => {
if (onClickPreprocessing) {
await onClickPreprocessing()
}
if (!pinned) {
notesController.setPinSelectedNotes(true)
} else {
notesController.setPinSelectedNotes(false)
}
}, [onClickPreprocessing, pinned, notesController])
return (
<button className={`sn-icon-button border-contrast ${pinned ? 'toggled' : ''} ${className}`} onClick={togglePinned}>
<VisuallyHidden>Pin selected notes</VisuallyHidden>
<Icon type="pin" className="block" />
</button>
)
}
export default observer(PinNoteButton)