-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from notifirehq/rld-95-add-onchange-event-for…
…-all-components ✨ Add onChange and onClick events to components
- Loading branch information
Showing
5 changed files
with
55 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
import React from 'react'; | ||
import React, { ChangeEvent } from 'react'; | ||
import { Checkbox as MantineCheckbox } from '@mantine/core'; | ||
import useStyles from './Checkbox.styles'; | ||
|
||
interface CheckboxProps { | ||
checked?: boolean; | ||
disabled?: boolean; | ||
label?: string; | ||
onChange?: (event: ChangeEvent<HTMLInputElement>) => void; | ||
} | ||
|
||
/** | ||
* Checkbox Component | ||
* | ||
*/ | ||
export function Checkbox({ label = 'Default Checkbox', checked, disabled = false, ...props }: CheckboxProps) { | ||
export function Checkbox({ label = 'Default Checkbox', checked, onChange, disabled = false, ...props }: CheckboxProps) { | ||
const { classes } = useStyles(); | ||
|
||
return ( | ||
<MantineCheckbox classNames={classes} label={label} disabled={disabled} size="sm" checked={checked} {...props} /> | ||
<MantineCheckbox | ||
classNames={classes} | ||
label={label} | ||
onChange={onChange} | ||
disabled={disabled} | ||
size="sm" | ||
checked={checked} | ||
{...props} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import React from 'react'; | ||
import React, { ChangeEvent } from 'react'; | ||
import { Switch as MantineSwitch, SwitchProps } from '@mantine/core'; | ||
import useStyles from './Switch.styles'; | ||
|
||
interface ISwitchProps { | ||
label?: React.ReactNode; | ||
checked?: boolean; | ||
onChange?: () => void; | ||
onChange?: (event: ChangeEvent<HTMLInputElement>) => void; | ||
} | ||
|
||
/** | ||
* Switch component | ||
* | ||
*/ | ||
export function Switch({ ...props }: ISwitchProps) { | ||
export function Switch({ onChange, ...props }: ISwitchProps) { | ||
const { classes } = useStyles(); | ||
const defaultDesign = { radius: 'xl', size: 'md', classNames: classes } as SwitchProps; | ||
|
||
return <MantineSwitch {...defaultDesign} {...props} />; | ||
return <MantineSwitch onChange={onChange} {...defaultDesign} {...props} />; | ||
} |
32934e2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storybook – ./
notifire.vercel.app
storybook-relayed.vercel.app
storybook-git-master-relayed.vercel.app