Skip to content

Commit

Permalink
feat: make component lable responsive and mobile friendly #input #dro…
Browse files Browse the repository at this point in the history
…pdown #slider #textarea #date-picker #form-row
  • Loading branch information
tujoworker committed Jul 24, 2019
1 parent 29c089c commit c3cfec4
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,12 @@ legend.dnb-form-label {
align-items: flex-start; }
.dnb-input[class*='__status'] > .dnb-form-label {
margin-top: 0.25rem; }
@media (max-width: 40em) {
.dnb-input {
flex-direction: column;
align-items: flex-start; }
.dnb-input > .dnb-form-label {
margin-bottom: 0.5rem; } }
@media screen and (-ms-high-contrast: none) {
.dnb-input {
vertical-align: baseline; }
Expand Down Expand Up @@ -1838,6 +1844,12 @@ legend.dnb-form-label {
align-items: flex-start; }
.dnb-date-picker[class*='__status'] > .dnb-form-label {
margin-top: 0.25rem; }
@media (max-width: 40em) {
.dnb-date-picker {
flex-direction: column;
align-items: flex-start; }
.dnb-date-picker > .dnb-form-label {
margin-bottom: 0.5rem; } }
@media screen and (-ms-high-contrast: none) {
.dnb-date-picker {
flex: none; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@
}
}

@media (max-width: 40em) {
flex-direction: column;
align-items: flex-start;
> .dnb-form-label {
margin-bottom: 0.5rem;
}
}

// IE fix
@media screen and (-ms-high-contrast: none) {
flex: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,12 @@ legend.dnb-form-label {
align-items: flex-start; }
.dnb-dropdown[class*='__status'] > .dnb-form-label {
margin-top: 0.25rem; }
@media (max-width: 40em) {
.dnb-dropdown {
flex-direction: column;
align-items: flex-start; }
.dnb-dropdown > .dnb-form-label {
margin-bottom: 0.5rem; } }
@media screen and (-ms-high-contrast: none) {
.dnb-dropdown {
flex: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@
}
}

@media (max-width: 40em) {
flex-direction: column;
align-items: flex-start;
> .dnb-form-label {
margin-bottom: 0.5rem;
}
}

// IE fix
@media screen and (-ms-high-contrast: none) {
flex: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ legend.dnb-form-label {
@media (max-width: 40em) {
.dnb-form-row:not(.dnb-form-row--vertical)[class*='__indent'] {
display: block; } }
@media (max-width: 40em) {
.dnb-form-row:not(.dnb-form-row--vertical) {
flex-direction: column;
align-items: flex-start; }
.dnb-form-row:not(.dnb-form-row--vertical) > .dnb-form-label {
margin-bottom: 0.5rem; }
.dnb-form-row:not(.dnb-form-row--vertical) > .dnb-form-row__content {
flex-direction: column; }
.dnb-form-row:not(.dnb-form-row--vertical) > .dnb-form-row__content .dnb-form-label {
margin-top: 1rem; } }
.dnb-form-row--vertical > .dnb-form-label {
margin-bottom: 0.5rem; }
.dnb-form-row--vertical > .dnb-form-row__content {
Expand Down
14 changes: 14 additions & 0 deletions packages/dnb-ui-lib/src/components/form-row/style/_form-row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@
display: block;
}
}

@media (max-width: 40em) {
flex-direction: column;
align-items: flex-start;
& > .dnb-form-label {
margin-bottom: 0.5rem;
}
& > .dnb-form-row__content {
flex-direction: column;
.dnb-form-label {
margin-top: 1rem;
}
}
}
}

// This is currently not needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,12 @@ legend.dnb-form-label {
align-items: flex-start; }
.dnb-input[class*='__status'] > .dnb-form-label {
margin-top: 0.25rem; }
@media (max-width: 40em) {
.dnb-input {
flex-direction: column;
align-items: flex-start; }
.dnb-input > .dnb-form-label {
margin-bottom: 0.5rem; } }
@media screen and (-ms-high-contrast: none) {
.dnb-input {
vertical-align: baseline; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,12 @@ legend.dnb-form-label {
align-items: flex-start; }
.dnb-input[class*='__status'] > .dnb-form-label {
margin-top: 0.25rem; }
@media (max-width: 40em) {
.dnb-input {
flex-direction: column;
align-items: flex-start; }
.dnb-input > .dnb-form-label {
margin-bottom: 0.5rem; } }
@media screen and (-ms-high-contrast: none) {
.dnb-input {
vertical-align: baseline; }
Expand Down
8 changes: 8 additions & 0 deletions packages/dnb-ui-lib/src/components/input/style/_input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@
}
}

@media (max-width: 40em) {
flex-direction: column;
align-items: flex-start;
> .dnb-form-label {
margin-bottom: 0.5rem;
}
}

// IE fix
@media screen and (-ms-high-contrast: none) {
vertical-align: baseline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,12 @@ legend.dnb-form-label {
margin-top: 0.5rem; }
.dnb-slider--vertical .dnb-form-status {
margin-top: 1rem; }
@media (max-width: 40em) {
.dnb-slider {
flex-direction: column;
align-items: flex-start; }
.dnb-slider > .dnb-form-label {
margin-bottom: 0.5rem; } }
@media screen and (-ms-high-contrast: none) {
.dnb-slider__wrapper {
flex: none; } }
Expand Down
8 changes: 8 additions & 0 deletions packages/dnb-ui-lib/src/components/slider/style/_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@
margin-top: 1rem;
}

@media (max-width: 40em) {
flex-direction: column;
align-items: flex-start;
> .dnb-form-label {
margin-bottom: 0.5rem;
}
}

// IE fix
@media screen and (-ms-high-contrast: none) {
&__wrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,12 @@ textarea.dnb-textarea {
flex: 1; }
.dnb-textarea--stretch .dnb-textarea__shell, .dnb-textarea--stretch .dnb-textarea__textarea {
width: 100%; }
@media (max-width: 40em) {
.dnb-textarea {
flex-direction: column;
align-items: flex-start; }
.dnb-textarea > .dnb-form-label {
margin-bottom: 0.5rem; } }
@media screen and (-ms-high-contrast: none) {
.dnb-textarea__inner {
margin: 0; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@
}
}

@media (max-width: 40em) {
flex-direction: column;
align-items: flex-start;
> .dnb-form-label {
margin-bottom: 0.5rem;
}
}

// IE fix
@media screen and (-ms-high-contrast: none) {
&__inner {
Expand Down
14 changes: 8 additions & 6 deletions packages/dnb-ui-lib/stories/components/FormRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default [
() => (
<Center>
<Wrapper showOverflow>
<H2 bottom="small">Combine vertical and horizontal</H2>
<Box>
<Provider
formRow={{
Expand All @@ -42,7 +41,10 @@ export default [
>
<Input />
</Provider>
</Box>

<Box>
<H2 bottom="large">Combine vertical and horizontal</H2>
<FormRow
label={
<H2 top={false} bottom="large">
Expand Down Expand Up @@ -72,13 +74,13 @@ export default [
</FormRow>
</Box>

<H2 bottom="small">Plain</H2>
<Box>
<H2 bottom="large">Plain</H2>
<AllComponents showText horizontal vertical />
</Box>

<H2 bottom="small">Horizontal label</H2>
<Box>
<H2 bottom="large">Horizontal label</H2>
<FormRow
// indent
// indent_offset="large"
Expand All @@ -89,22 +91,22 @@ export default [
</FormRow>
</Box>

<H2 bottom="small">Vertical direction</H2>
<Box>
<H2 bottom="large">Vertical direction</H2>
<FormRow label="Vertical direction:" direction="vertical">
<AllComponents showText />
</FormRow>
</Box>

<H2 bottom="small">Vertical everything</H2>
<Box>
<H2 bottom="large">Vertical everything</H2>
<FormRow label="Vertical everything:" vertical="true">
<AllComponents showText />
</FormRow>
</Box>

<H2 bottom="small">Vertical label</H2>
<Box>
<H2 bottom="large">Vertical label</H2>
<FormRow label="Vertical Legend:" label_direction="vertical">
<AllComponents showText horizontal />
</FormRow>
Expand Down

0 comments on commit c3cfec4

Please sign in to comment.