Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(form): update label alignment #2200

Merged
merged 14 commits into from Sep 5, 2019
1 change: 1 addition & 0 deletions src/patternfly/components/Form/docs/code.md
Expand Up @@ -28,4 +28,5 @@
| `.pf-m-inactive` | `.pf-c-form__helper-text`| Modifies display of helper text to none. |
| `.pf-m-border` | `.pf-c-form__section` | Modifies form element border-bottom. |
| `.pf-m-disabled` | `.pf-c-form__label` | Modifies form label to show disabled state. |
| `.pf-m-align-top` | `.pf-c-form__label` | Modifies form label to align to the top of its parent. |
| `.pf-m-inline` | `.pf-c-form__group` | Modifies form group children to be inline (this is primarily for radio buttons and checkboxes). |
Expand Up @@ -9,3 +9,18 @@
{{/horizontal-form-group}}
{{/form-group}}
{{/form}}

<br>

{{#> form form--modifier="pf-m-horizontal" form--id="horizontal-align-labels"}}
Copy link
Contributor

Choose a reason for hiding this comment

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

form--id needs to be unique

{{#> form-group}}
{{#> form-label form-label--attribute=(concat 'for="' form--id '-horizontal-form-name"') form-label--modifier="pf-m-align-top"}}
Info (.pf-m-align-top)
{{/form-label}}
{{#> horizontal-form-group}}
{{#> form-control controlType="textarea" form-control--attribute=(concat 'type="text" id="' form--id '-horizontal-form-name-2" name="' form--id '-horizontal-form-name-2" aria-label="textarea example"')}}
{{/form-control}}
{{/horizontal-form-group}}
{{/form-group}}
{{/form}}

11 changes: 9 additions & 2 deletions src/patternfly/components/Form/form.scss
Expand Up @@ -69,10 +69,18 @@
grid-template-columns: var(--pf-c-form--m-horizontal--md__group--GridTemplateColumns);
}

/* stylelint-disable */
.pf-c-form__group .pf-c-form__label {
padding-top: var(--pf-c-form__label--PaddingTop);
display: flex;
align-items: center;
padding-top: 0; // remove this after breaking change period
padding-bottom: 0;

&.pf-m-align-top {
align-items: flex-start;
}
}
/* stylelint-enable */

.pf-c-form-control,
.pf-c-form__horizontal-group,
Expand Down Expand Up @@ -144,7 +152,6 @@
.pf-c-form__label-required {
margin-left: var(--pf-c-form__label-required--MarginLeft);
font-size: var(--pf-c-form__label-required--FontSize);
line-height: 0;
color: var(--pf-c-form__label-required--Color);
}

Expand Down
@@ -1,6 +1,6 @@
{{#> form form--modifier="pf-m-horizontal"}}
{{#> form-group}}
{{#> form-label form-label--attribute='for="horizontal-form-name"' required="true"}}Name{{/form-label}}
{{#> form-label form-label--modifier="pf-m-align-top" form-label--attribute='for="horizontal-form-name"' required="true"}}Name{{/form-label}}
{{#> horizontal-form-group}}
{{#> form-control controlType="input" input="true" form-control--attribute='required type="text" id="horizontal-form-name" name="horizontal-form-name" aria-describedby="horizontal-form-name-helper2"'}}
{{/form-control}}
Expand Down Expand Up @@ -29,7 +29,7 @@
{{/horizontal-form-group}}
{{/form-group}}
{{#> form-group}}
{{#> form-label form-label--attribute='for="horizontal-form-exp"'}}Your experience{{/form-label}}
{{#> form-label form-label--modifier="pf-m-align-top" form-label--attribute='for="horizontal-form-exp"'}}Your experience{{/form-label}}
{{#> horizontal-form-group}}
{{#> form-control controlType="textarea" form-control--attribute='name="horizontal-form-exp" id="horizontal-form-exp"'}}
{{/form-control}}
Expand Down