Skip to content

Commit ecc14f5

Browse files
committed
fix(new-ui): resolve vertical alignment
1 parent 62775d2 commit ecc14f5

2 files changed

Lines changed: 31 additions & 30 deletions

File tree

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

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
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 {
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

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from 'styled-components';
22
import { Icon } from '~/components/Icon';
33
import { InlineFlex } from '~/components/InlineFlex';
4+
import { Label } from './Label';
45

56
export 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+
2227
export 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};

0 commit comments

Comments
 (0)