Skip to content

Commit 0d0da61

Browse files
committed
chore(new-ui): finalize changes to checkbox component
1 parent ae27e18 commit 0d0da61

1 file changed

Lines changed: 27 additions & 29 deletions

File tree

  • packages/new-polymath-ui/src/components/inputs/Checkbox

packages/new-polymath-ui/src/components/inputs/Checkbox/Checkbox.tsx

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import React, { FC, useState, Fragment } from 'react';
1+
import React, { FC, useState } from 'react';
22
import { uniqueId } from 'lodash';
33
import { InlineFlex } from '~/components/InlineFlex';
44
import { SvgCheckmark } from '~/images/icons/Checkmark';
55
import { FormikProxy, EnhancedComponentProps } from '../FormikProxy';
66
import * as sc from './styles';
7-
import { Label } from './Label';
87

98
interface Props {
10-
onChange: (e: boolean) => void;
9+
onChange: (e: any) => void;
1110
/**
1211
* Specify whether the toggle should be on by default
1312
*/
@@ -38,33 +37,32 @@ export const CheckboxPrimitive: FC<Props> = ({
3837
}
3938

4039
return (
41-
<Fragment>
42-
<InlineFlex>
43-
<sc.Input
44-
{...other}
45-
{...checkedProps}
46-
type="checkbox"
47-
id={name || id}
48-
name={name || id}
49-
onChange={e => {
50-
onChange(e.currentTarget.checked);
51-
}}
40+
<sc.CheckboxInlineFlex>
41+
<sc.Input
42+
{...other}
43+
{...checkedProps}
44+
type="checkbox"
45+
id={name || id}
46+
name={name || id}
47+
onChange={e => {
48+
onChange(e.target.checked);
49+
}}
50+
/>
51+
<sc.CheckboxInput htmlFor={name || id}>
52+
<sc.CheckIcon
53+
Asset={SvgCheckmark}
54+
color="white"
55+
width="0.85em"
56+
cd
57+
height="0.85em"
5258
/>
53-
<sc.CheckboxInput htmlFor={name || id}>
54-
<sc.CheckIcon
55-
Asset={SvgCheckmark}
56-
color="white"
57-
width="0.85em"
58-
height="0.85em"
59-
/>
60-
</sc.CheckboxInput>
61-
{label && (
62-
<InlineFlex ml={2}>
63-
<Label htmlFor={name || id}>{label}</Label>
64-
</InlineFlex>
65-
)}
66-
</InlineFlex>
67-
</Fragment>
59+
</sc.CheckboxInput>
60+
{label && (
61+
<InlineFlex ml={2}>
62+
<sc.CheckboxLabel htmlFor={name || id}>{label}</sc.CheckboxLabel>
63+
</InlineFlex>
64+
)}
65+
</sc.CheckboxInlineFlex>
6866
);
6967
};
7068

0 commit comments

Comments
 (0)