File tree Expand file tree Collapse file tree
packages/new-polymath-ui/src/components/inputs/Checkbox Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import React , { FC , useState , Fragment } from 'react' ;
1+ import React , { FC , useState } from 'react' ;
22import { uniqueId } from 'lodash' ;
33import { InlineFlex } from '~/components/InlineFlex' ;
44import { SvgCheckmark } from '~/images/icons/Checkmark' ;
55import { FormikProxy , EnhancedComponentProps } from '../FormikProxy' ;
66import * as sc from './styles' ;
7- import { Label } from './Label' ;
87
98interface 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
Original file line number Diff line number Diff line change 11import styled from 'styled-components' ;
22import { Icon } from '~/components/Icon' ;
3+ import { InlineFlex } from '~/components/InlineFlex' ;
4+ import { Label } from './Label' ;
35
46export const Input = styled . input `
57 position: absolute;
@@ -14,6 +16,14 @@ export const Input = styled.input`
1416 white-space: nowrap;
1517` ;
1618
19+ export const CheckboxInlineFlex = styled ( InlineFlex ) `
20+ line-height: 18px;
21+ ` ;
22+
23+ export const CheckboxLabel = styled ( Label ) `
24+ align-items: flex-start;
25+ ` ;
26+
1727export const CheckIcon = styled ( Icon ) `
1828 display: block;
1929 transition: ${ ( { theme } ) => theme . transitions . hover . ms } ms;
@@ -34,6 +44,7 @@ export const CheckboxInput = styled.label`
3444 height: 1.125rem;
3545 background-color: #fff;
3646 user-select: none;
47+ align-items: flex-start;
3748
3849 ${ Input } :focus + & {
3950 border-color: ${ ( { theme } ) => theme . colors . secondary } ;
You can’t perform that action at this time.
0 commit comments