Skip to content

Commit

Permalink
refactor: improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackGlory committed Jan 1, 2024
1 parent f35a7e0 commit 6d90eeb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/components/advanced-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function AdvancedOptions({ rule, ruleIndex }: IAdvancedOptionsProps) {
<section>
<Checkbox
value={rule.matchersEnabled}
onClick={enabled => updateConfig(config => {
onChange={enabled => updateConfig(config => {
config.rules![ruleIndex].matchersEnabled = enabled
})}
>
Expand All @@ -39,7 +39,7 @@ export function AdvancedOptions({ rule, ruleIndex }: IAdvancedOptionsProps) {
<section>
<Checkbox
value={rule.fontWeightEnabled}
onClick={enabled => updateConfig(config => {
onChange={enabled => updateConfig(config => {
config.rules![ruleIndex].fontWeightEnabled = enabled
})}
>
Expand All @@ -58,7 +58,7 @@ export function AdvancedOptions({ rule, ruleIndex }: IAdvancedOptionsProps) {
<section>
<Checkbox
value={rule.unicodeRangeEnabled}
onClick={enabled => updateConfig(config => {
onChange={enabled => updateConfig(config => {
config.rules![ruleIndex].unicodeRangeEnabled = enabled
})}
>
Expand Down
7 changes: 4 additions & 3 deletions src/components/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
interface ICheckboxProps {
value: boolean
children: React.ReactNode
onClick: (value: boolean) => void

onChange: (value: boolean) => void
}

export function Checkbox({ value, children, onClick }: ICheckboxProps) {
export function Checkbox({ value, children, onChange }: ICheckboxProps) {
return (
<label className='flex space-x-1 cursor-pointer'>
<input
className='border accent-gray-700'
type='checkbox'
checked={value}
onChange={e => onClick(e.target.checked)}
onChange={e => onChange(e.target.checked)}
/>
<div>{children}</div>
</label>
Expand Down

0 comments on commit 6d90eeb

Please sign in to comment.