refactor: migrate checkbox from reach-ui

This commit is contained in:
Aman Harwara
2023-04-21 14:58:35 +05:30
parent 0d235ed1d2
commit a5d536b5f2
8 changed files with 55 additions and 101 deletions

View File

@@ -4,13 +4,12 @@ import { PlatformedKeyboardShortcut } from '@standardnotes/ui-services'
import { ComponentPropsWithoutRef, ForwardedRef, forwardRef, ReactNode } from 'react'
import { KeyboardShortcutIndicator } from '../KeyboardShortcutIndicator/KeyboardShortcutIndicator'
import Switch from '../Switch/Switch'
import { SwitchProps } from '../Switch/SwitchProps'
import MenuListItem from './MenuListItem'
type Props = {
checked: boolean
children: ReactNode
onChange: NonNullable<SwitchProps['onChange']>
onChange: (checked: boolean) => void
shortcut?: PlatformedKeyboardShortcut
} & Omit<ComponentPropsWithoutRef<'button'>, 'onChange'>
@@ -42,7 +41,7 @@ const MenuSwitchButtonItem = forwardRef(
<span className="flex flex-grow items-center">{children}</span>
<div className="flex items-center">
{shortcut && <KeyboardShortcutIndicator className="mr-2" shortcut={shortcut} />}
<Switch disabled={disabled} className="px-0" checked={checked} />
<Switch disabled={disabled} className="pointer-events-none px-0" checked={checked} onChange={onChange} />
</div>
</button>
</MenuListItem>