Skip to content

Commit

Permalink
Merge pull request #281 from WTTJ/fix-label-spacing-and-wrapping
Browse files Browse the repository at this point in the history
fix: label spacing and wrapping
  • Loading branch information
anucreative authored Aug 21, 2019
2 parents 9c859a6 + c4ea8df commit 93b6d05
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/components/ConnectedField/doc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ You can find additional props for each field component in [Fields](/fields/file-
placeholder="McBoatface"
label="Last name"
mb="xl"
flexDirection="row"
/>
<ConnectedField
name="telephone"
Expand Down Expand Up @@ -174,7 +175,7 @@ You can find additional props for each field component in [Fields](/fields/file-
</RadioGroup>
<ConnectedField name="hungry" component={Toggle} label="Hungry" mb="xl" />
<FieldGroup label="Animals" mb="xl">
<ConnectedField name="dogs" component={InputCheckbox} label="Dogs" />
<ConnectedField name="dogs" component={InputCheckbox} label="Dogs are particularly funny creatures due to their floppy ears" />
<ConnectedField name="cats" component={InputCheckbox} label="Cats" />
</FieldGroup>
<ConnectedField
Expand Down
2 changes: 1 addition & 1 deletion src/components/Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const Field = forwardRef(

const isShowRequired = isRadio ? null : required
const layout = flexDirection || (isCheckable ? 'row' : 'column')
const Container = layout === 'row' ? RowContainer : Fragment
const Container = flexDirection === 'row' ? RowContainer : Fragment

const handleLabelClick = () => {
if (isCheckable) return
Expand Down
1 change: 1 addition & 0 deletions src/components/Field/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const columnStyles = css`

const checkableFieldStyles = css`
${th('fields.checkablelabel.default')};
margin-bottom: sm;
`

export const Field = styled.div(
Expand Down
4 changes: 2 additions & 2 deletions src/components/Label/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getVariantStateColor, system } from '../../utils/'
export const Label = styled.label`
display: flex;
flex-shrink: 0;
align-items: center;
line-height: 1;
align-items: flex-start;
line-height: body1;
${th('fields.label')};
${system};
`
Expand Down
8 changes: 7 additions & 1 deletion src/theme/fields.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// To allow for line-height of text in label
const LINE_HEIGHT_ADJUSTMENTS = '0.15rem'

export const getFields = theme => {
const { colors, fontSizes, fontWeights, radii, shadows, space, toRem } = theme

Expand Down Expand Up @@ -73,7 +76,9 @@ export const getFields = theme => {
checkbox: {
default: {
width: toRem(15),
height: toRem(15)
height: toRem(15),
'flex-shrink': 0,
'margin-top': LINE_HEIGHT_ADJUSTMENTS
},
checked
},
Expand Down Expand Up @@ -151,6 +156,7 @@ export const getFields = theme => {
width: toRem(22),
'background-color': colors.nude[200],
'border-color': colors.nude[200],
'margin-top': `-${LINE_HEIGHT_ADJUSTMENTS}`,
'&::after': {
...defaults,
'background-color': colors.light[200],
Expand Down

1 comment on commit 93b6d05

@vercel
Copy link

@vercel vercel bot commented on 93b6d05 Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.