Skip to content

Commit

Permalink
fix: enhance alignment on form components, incl. #toggle-button group…
Browse files Browse the repository at this point in the history
… + #switch enhancements on semantics on a status
  • Loading branch information
tujoworker committed Dec 2, 2019
1 parent 5a4a2f0 commit aeb8d0b
Show file tree
Hide file tree
Showing 30 changed files with 152 additions and 185 deletions.
10 changes: 0 additions & 10 deletions packages/dnb-ui-lib/src/components/button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,6 @@ class Content extends PureComponent {
{text}
</span>
)
} else {
ret.push(
<span
key="button-helper"
className="dnb-button__helper"
aria-hidden
>
&zwnj;
</span>
)
}

if (icon) {
Expand Down
4 changes: 0 additions & 4 deletions packages/dnb-ui-lib/src/components/button/style/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
font-size: var(--font-size-small); // has to be 16px
line-height: var(--button-height--small);

&__helper {
@include helper();
}

&__icon {
svg:not([width]):not([height]) {
width: var(--button-icon-size);
Expand Down
5 changes: 2 additions & 3 deletions packages/dnb-ui-lib/src/components/checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import keycode from 'keycode'
import AlignmentHelper from '../../shared/AlignmentHelper'
import {
isTrue,
makeUniqueId,
Expand Down Expand Up @@ -269,9 +270,7 @@ export default class Checkbox extends Component {
/>
)}

<span className="dnb-checkbox__helper" aria-hidden>
&zwnj;
</span>
<AlignmentHelper className="dnb-checkbox__helper" />

<span className="dnb-checkbox__inner">
{label_position === 'left' && statusComp}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
flex-direction: column;
align-self: center;
}
&__helper {
@include helper();

// since we don't have a vertical state, we set it to vertical by default
@include helperVertical();
}

&__shell {
user-select: none;
Expand Down
10 changes: 4 additions & 6 deletions packages/dnb-ui-lib/src/components/date-picker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

import AlignmentHelper from '../../shared/AlignmentHelper'
import {
isTrue,
makeUniqueId,
Expand Down Expand Up @@ -425,8 +425,8 @@ export default class DatePicker extends PureComponent {
)
if (
hidePicker &&
(!isTrue(this.props.show_submit_button) &&
!isTrue(this.props.show_cancel_button))
!isTrue(this.props.show_submit_button) &&
!isTrue(this.props.show_cancel_button)
) {
this.hidePicker(args)
}
Expand Down Expand Up @@ -719,9 +719,7 @@ export default class DatePicker extends PureComponent {
/>
)}

<span className="dnb-date-picker__helper" aria-hidden>
&zwnj;
</span>
<AlignmentHelper className="dnb-date-picker__helper" />

<span
className="dnb-date-picker__inner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@

// if no label is provided, then make sure we have some text to align the button
&__helper {
@include helper();
line-height: var(--date-picker-input-height);
}
&--vertical &__helper {
@include helperVertical();
}

&__shell {
position: relative;
Expand Down
10 changes: 6 additions & 4 deletions packages/dnb-ui-lib/src/components/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import keycode from 'keycode'
import AlignmentHelper from '../../shared/AlignmentHelper'
import {
isTrue,
makeUniqueId,
Expand Down Expand Up @@ -799,7 +800,10 @@ export default class Dropdown extends PureComponent {
}, {})
const counts = Object.keys(itemSpots)
const findClosest = (arr, val) =>
Math.max.apply(null, arr.filter(v => v <= val))
Math.max.apply(
null,
arr.filter(v => v <= val)
)
let closestToTop = null,
closestToBottom = null,
tmpToTop,
Expand Down Expand Up @@ -1066,9 +1070,7 @@ export default class Dropdown extends PureComponent {
/>
)}

<span className="dnb-dropdown__helper" aria-hidden>
&zwnj;
</span>
<AlignmentHelper className="dnb-dropdown__helper" />

<span className="dnb-dropdown__inner" ref={this._ref}>
{showStatus && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@
color: inherit;
}

// if no label is provided, then make sure we have some text to align the button
&__helper {
@include helper();
}
&--vertical &__helper {
@include helperVertical();
}

&__shell {
position: relative;

Expand Down
3 changes: 2 additions & 1 deletion packages/dnb-ui-lib/src/components/form-label/FormLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import AlignmentHelper from '../../shared/AlignmentHelper'
import {
extendPropsWithContext,
isTrue,
Expand Down Expand Up @@ -142,7 +143,7 @@ export default class FormLabel extends PureComponent {
if (isTrue(sr_only)) {
return (
<Element is={element} aria-label={content} {...params}>
<span aria-hidden>&zwnj;</span>
<AlignmentHelper className="dnb-form-label__helper" />
</Element>
)
}
Expand Down
5 changes: 2 additions & 3 deletions packages/dnb-ui-lib/src/components/form-row/FormRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import AlignmentHelper from '../../shared/AlignmentHelper'
import {
extend,
extendPropsWithContext,
Expand Down Expand Up @@ -241,9 +242,7 @@ export default class FormRow extends PureComponent {
<Context.Provider value={context}>
<Fieldset useFieldset={useFieldset}>
<div {...params}>
<span className="dnb-form-row__helper" aria-hidden>
&zwnj;
</span>
<AlignmentHelper className="dnb-form-row__helper" />

{label && (
<FormLabel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
width: 100%; // to help #input stretch
}

&__helper {
@include helper();
}
&--vertical &__helper {
@include helperVertical();
}

// for hoizontal direction
&:not(#{&}--vertical) {
& > .dnb-form-row__content {
Expand Down
2 changes: 0 additions & 2 deletions packages/dnb-ui-lib/src/components/icon/style/_icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
justify-content: center;
}

p &,
blockquote &,
h1 &,
h2 &,
h3 &,
Expand Down
7 changes: 3 additions & 4 deletions packages/dnb-ui-lib/src/components/input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import AlignmentHelper from '../../shared/AlignmentHelper'
import Button from '../button/Button'
import FormLabel from '../form-label/FormLabel'
import FormStatus from '../form-status/FormStatus'
Expand Down Expand Up @@ -382,7 +383,7 @@ export default class Input extends PureComponent {
}

// we may considder using: aria-details
if (showStatus || (suffix || description)) {
if (showStatus || suffix || description) {
inputParams['aria-describedby'] = `${
showStatus ? id + '-status' : ''
} ${suffix || description ? id + '-description' : ''}`
Expand Down Expand Up @@ -428,9 +429,7 @@ export default class Input extends PureComponent {
/>
)}

<span className="dnb-input__helper" aria-hidden>
&zwnj;
</span>
<AlignmentHelper className="dnb-input__helper" />

<span {...innerParams}>
{showStatus && (
Expand Down
8 changes: 0 additions & 8 deletions packages/dnb-ui-lib/src/components/input/style/_input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@
font-size: var(--input-font-small);
line-height: var(--input-height);

// if no label is provided, then make sure we have some text to align the button
&__helper {
@include helper();
}
&--vertical &__helper {
@include helperVertical();
}

&__inner {
display: inline-flex;
flex-direction: column;
Expand Down
5 changes: 2 additions & 3 deletions packages/dnb-ui-lib/src/components/radio/Radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import keycode from 'keycode'
import AlignmentHelper from '../../shared/AlignmentHelper'
import {
isTrue,
makeUniqueId,
Expand Down Expand Up @@ -360,9 +361,7 @@ export default class Radio extends Component {
/>
)}

<span className="dnb-radio__helper" aria-hidden>
&zwnj;
</span>
<AlignmentHelper className="dnb-radio__helper" />

<span className="dnb-radio__inner">
{label_position === 'left' && statusComp}
Expand Down
7 changes: 2 additions & 5 deletions packages/dnb-ui-lib/src/components/radio/RadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import AlignmentHelper from '../../shared/AlignmentHelper'
import {
extendPropsWithContext,
makeUniqueId,
Expand Down Expand Up @@ -230,11 +231,7 @@ export default class RadioGroup extends PureComponent {
return (
<RadioGroupContext.Provider value={context}>
<div className={classes}>
{!label && (
<span className="dnb-radio-group__helper" aria-hidden>
&zwnj;
</span>
)}
<AlignmentHelper className="dnb-radio-group__helper" />
<FormRow {...formRowParams}>
<span
id={id}
Expand Down
12 changes: 2 additions & 10 deletions packages/dnb-ui-lib/src/components/radio/style/_radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
flex-direction: column;
align-self: center;
}
&__helper {
@include helper();

// since we don't have a vertical state, we set it to vertical by default
@include helperVertical();
}

&__shell {
position: relative;
Expand Down Expand Up @@ -181,13 +175,11 @@
// because of our bottom margins we have on the componens
margin-bottom: calc(1px - 1px - var(--radio-margin-bottom));
}
.dnb-form-row--vertical & {
display: flex;
}

// if no label is given
&__helper {
@include helper();
font-size: var(--font-size-basis);
line-height: var(--radio-height);
}
}

Expand Down
5 changes: 2 additions & 3 deletions packages/dnb-ui-lib/src/components/slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import PropTypes from 'prop-types'
import classnames from 'classnames'
import keycode from 'keycode'
import Context from '../../shared/Context'
import AlignmentHelper from '../../shared/AlignmentHelper'
import {
isTrue,
makeUniqueId,
Expand Down Expand Up @@ -621,9 +622,7 @@ export default class Slider extends PureComponent {
/>
)}

<span className="dnb-slider__helper" aria-hidden>
&zwnj;
</span>
<AlignmentHelper className="dnb-slider__helper" />

<span className="dnb-slider__wrapper">
{showStatus && (
Expand Down
8 changes: 0 additions & 8 deletions packages/dnb-ui-lib/src/components/slider/style/_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
font-size: var(--font-size-small);
line-height: var(--line-height-basis);

&__helper {
// NB: this is not the same kind of helper than we have for the button!
@include helper();
}
&__label--vertical &__helper {
@include helperVertical();
}

&--vertical {
display: flex;
width: auto;
Expand Down
Loading

0 comments on commit aeb8d0b

Please sign in to comment.