-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
83 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
||
import CheckBox from './CheckBox'; | ||
|
||
export default { | ||
title: 'CheckBox', | ||
component: CheckBox, | ||
} as ComponentMeta<typeof CheckBox>; | ||
|
||
const Template: ComponentStory<typeof CheckBox> = (args) => { | ||
return <CheckBox {...args} />; | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
label: 'Text label', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { memo, useEffect, useRef, useState } from 'react'; | ||
import { uniqueId } from 'src/lib/utils'; | ||
|
||
import { CheckIcon } from './icons'; | ||
|
||
interface Props extends Omit<DefaultProps, 'value'> { | ||
label?: string; | ||
checked: boolean; | ||
onChange: (checked: boolean) => void; | ||
} | ||
|
||
const CheckBox = ({ disabled, checked, label, onChange, ...props }: Props) => { | ||
const id = useRef(''); | ||
|
||
useEffect(() => { | ||
id.current = uniqueId('radio'); | ||
}, []); | ||
|
||
return ( | ||
<div | ||
className={`flex items-center gap-3 p-3 border cursor-pointer w-fit rounded-3xl ${ | ||
checked ? 'border-gray-500' : 'border-gray-200 ' | ||
}`} | ||
onClick={() => onChange(!checked)} | ||
> | ||
<input | ||
type="checkbox" | ||
className={`hidden ${props.className}`} | ||
checked={checked} | ||
disabled={disabled} | ||
id={id.current} | ||
readOnly | ||
{...props} | ||
/> | ||
<CheckIcon color={checked ? 'black' : 'gray'} /> | ||
{label && ( | ||
<label htmlFor={id.current} onClick={(e) => e.stopPropagation()} className="cursor-pointer select-none"> | ||
{label} | ||
</label> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(CheckBox); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const Check = ({ color }: { color: 'gray' | 'black' | 'white' }) => { | ||
return ( | ||
<svg width="14" height="10" viewBox="0 0 14 10" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path | ||
d="M1.16675 5.00098L5.05564 8.88987L12.8334 1.11209" | ||
stroke={color === 'gray' ? '#CBCBCB' : color === 'white' ? '#ffffff' : '#474747'} | ||
strokeWidth="1.6" | ||
strokeLinejoin="round" | ||
/> | ||
</svg> | ||
); | ||
}; | ||
|
||
export default Check; |
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,3 +1,4 @@ | ||
export { default as CheckIcon } from './Check'; | ||
export { ProfileIcon } from './ProfileIcon'; | ||
export { TalentRegisterIcon } from './TalentRegisterIcon'; | ||
export { TalentSearchIcon } from './TalentSearchIcon'; |
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