feat: Replaced margin resizers with "Editor width" options. You can set it globally from Preferences > Appearance or per-note from the note options menu (#2324)

This commit is contained in:
Aman Harwara
2023-05-04 17:42:16 +05:30
committed by GitHub
parent 488142683c
commit 9fbb845b1d
18 changed files with 403 additions and 84 deletions

View File

@@ -0,0 +1,41 @@
import { VisuallyHidden, Radio, RadioGroup, useRadioStore } from '@ariakit/react'
import { classNames } from '@standardnotes/utils'
type Props = {
items: { label: string; value: string }[]
value: string
onChange: (value: string) => void
}
const RadioButtonGroup = ({ value, items, onChange }: Props) => {
const radio = useRadioStore({
value,
orientation: 'horizontal',
setValue(value) {
onChange(value as string)
},
})
return (
<RadioGroup store={radio} className="flex divide-x divide-border rounded border border-border">
{items.map(({ label, value: itemValue }) => (
<label
className={classNames(
'flex-grow select-none py-1.5 px-3.5 text-center',
'first:rounded-tl first:rounded-bl last:rounded-tr last:rounded-br',
itemValue === value &&
'bg-info-backdrop font-medium text-info ring-1 ring-inset ring-info focus-within:ring-2',
)}
key={itemValue}
>
<VisuallyHidden>
<Radio value={itemValue} />
</VisuallyHidden>
{label}
</label>
))}
</RadioGroup>
)
}
export default RadioButtonGroup