Skip to content

Commit 9168151

Browse files
Merge pull request #542 from PolymathNetwork/chore/formitem-lineheight
chore(new-ui): change line height of form item
2 parents 0451ffe + 0d0da61 commit 9168151

2 files changed

Lines changed: 38 additions & 29 deletions

File tree

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

packages/new-polymath-ui/src/components/inputs/Checkbox/styles.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import styled from 'styled-components';
22
import { Icon } from '~/components/Icon';
3+
import { InlineFlex } from '~/components/InlineFlex';
4+
import { Label } from './Label';
35

46
export 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+
1727
export 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};

0 commit comments

Comments
 (0)