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 {
109 onChange : ( e : any ) => void ;
@@ -38,34 +37,31 @@ export const CheckboxPrimitive: FC<Props> = ({
3837 }
3938
4039 return (
41- < Fragment >
42- < sc . CheckboxInlineFlex >
43- < sc . Input
44- { ...other }
45- { ...checkedProps }
46- type = "checkbox"
47- id = { name || id }
48- name = { name || id }
49- onChange = { e => {
50- onChange ( e . target . checked ) ;
51- } }
52- style = { { border : 'red' } }
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+ height = "0.85em"
5357 />
54- < sc . CheckboxInput htmlFor = { name || id } >
55- < sc . CheckIcon
56- Asset = { SvgCheckmark }
57- color = "white"
58- width = "0.85em"
59- height = "0.85em"
60- />
61- </ sc . CheckboxInput >
62- { label && (
63- < InlineFlex ml = { 2 } >
64- < Label htmlFor = { name || id } > { label } </ Label >
65- </ InlineFlex >
66- ) }
67- </ sc . CheckboxInlineFlex >
68- </ Fragment >
58+ </ sc . CheckboxInput >
59+ { label && (
60+ < InlineFlex ml = { 2 } >
61+ < sc . CheckboxLabel htmlFor = { name || id } > { label } </ sc . CheckboxLabel >
62+ </ InlineFlex >
63+ ) }
64+ </ sc . CheckboxInlineFlex >
6965 ) ;
7066} ;
7167
Original file line number Diff line number Diff line change 11import styled from 'styled-components' ;
22import { Icon } from '~/components/Icon' ;
33import { InlineFlex } from '~/components/InlineFlex' ;
4+ import { Label } from './Label' ;
45
56export const Input = styled . input `
67 position: absolute;
@@ -19,6 +20,10 @@ export const CheckboxInlineFlex = styled(InlineFlex)`
1920 line-height: 18px;
2021` ;
2122
23+ export const CheckboxLabel = styled ( Label ) `
24+ align-items: flex-start;
25+ ` ;
26+
2227export const CheckIcon = styled ( Icon ) `
2328 display: block;
2429 transition: ${ ( { theme } ) => theme . transitions . hover . ms } ms;
@@ -39,7 +44,7 @@ export const CheckboxInput = styled.label`
3944 height: 1.125rem;
4045 background-color: #fff;
4146 user-select: none;
42- vertical- align: top ;
47+ align-items: flex-start ;
4348
4449 ${ Input } :focus + & {
4550 border-color: ${ ( { theme } ) => theme . colors . secondary } ;
You can’t perform that action at this time.
0 commit comments