diff --git a/.storybook/main.js b/.storybook/main.js index 4d229235..da352958 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -30,6 +30,8 @@ module.exports = { loader: require.resolve('@svgr/webpack'), }); + config.resolve.modules = [path.resolve(__dirname, '..'), 'node_modules']; + return config; }, }; diff --git a/src/components/common/CheckBox.stories.tsx b/src/components/common/CheckBox.stories.tsx new file mode 100644 index 00000000..58b0cb85 --- /dev/null +++ b/src/components/common/CheckBox.stories.tsx @@ -0,0 +1,17 @@ +import type { ComponentMeta, ComponentStory } from '@storybook/react'; + +import CheckBox from './CheckBox'; + +export default { + title: 'CheckBox', + component: CheckBox, +} as ComponentMeta; + +const Template: ComponentStory = (args) => { + return ; +}; + +export const Default = Template.bind({}); +Default.args = { + label: 'Text label', +}; diff --git a/src/components/common/CheckBox.tsx b/src/components/common/CheckBox.tsx new file mode 100644 index 00000000..3425420d --- /dev/null +++ b/src/components/common/CheckBox.tsx @@ -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 { + 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 ( +
onChange(!checked)} + > + + + {label && ( + + )} +
+ ); +}; + +export default memo(CheckBox); diff --git a/src/components/common/icons/Check.tsx b/src/components/common/icons/Check.tsx new file mode 100644 index 00000000..24a68771 --- /dev/null +++ b/src/components/common/icons/Check.tsx @@ -0,0 +1,14 @@ +const Check = ({ color }: { color: 'gray' | 'black' | 'white' }) => { + return ( + + + + ); +}; + +export default Check; diff --git a/src/components/common/icons/index.ts b/src/components/common/icons/index.ts index b6769f0c..09ca2203 100644 --- a/src/components/common/icons/index.ts +++ b/src/components/common/icons/index.ts @@ -1,3 +1,4 @@ +export { default as CheckIcon } from './Check'; export { ProfileIcon } from './ProfileIcon'; export { TalentRegisterIcon } from './TalentRegisterIcon'; export { TalentSearchIcon } from './TalentSearchIcon'; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 271df1e4..b203405f 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -13,3 +13,7 @@ export const formatQueryString = (url: string, queryObject?: Record { + return id + Math.random().toString(16).slice(2); +};