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-no-padding` | `.pf-c-form__label` | Removes top padding from the label element for labels adjacent to an element that isn't a form control. |
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be .pf-m-no-padding-top?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

| `.pf-m-inline` | `.pf-c-form__group` | Modifies form group children to be inline (this is primarily for radio buttons and checkboxes). |
@@ -1,4 +1,4 @@
{{#> form form--modifier="pf-m-horizontal" form--id="horizontal-align-labels"}}
{{#> form form--modifier="pf-m-horizontal" form--id="horizontal-align-labels-1"}}
{{#> form-group}}
{{#> form-label form-label--attribute=(concat 'for="' form--id '-horizontal-form-name"') required="true"}}
Name
Expand All @@ -7,5 +7,47 @@
{{#> form-control controlType="input" input="true" form-control--attribute=(concat 'type="text" id="' form--id '-horizontal-form-name" name="' form--id '-horizontal-form-name" required')}}
{{/form-control}}
{{/horizontal-form-group}}
{{#> form-helper-text form-helper-text--modifier="pf-m-error" form-helper-text--attribute=(concat 'id="' form--id '-simple-form-name-helper" aria-live="polite"')}}
This is helper text for an invalid input
{{/form-helper-text}}
{{/form-group}}
{{/form}}

<br>

{{#> form form--modifier="pf-m-horizontal" form--id="horizontal-align-labels-2"}}
{{#> form-group}}
{{#> form-label form-label--attribute=(concat 'for="' form--id '-horizontal-form-name"')}}
Information
{{/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-helper-text form-helper-text--modifier="pf-m-error" form-helper-text--attribute=(concat 'id="' form--id '-simple-form-info-helper" aria-live="polite"')}}
This is helper text for an invalid input
{{/form-helper-text}}
{{/form-group}}
{{/form}}

<br>

{{#> form form--modifier="pf-m-horizontal" form--id="horizontal-align-labels-top"}}
{{#> form-group}}
{{#> form-label form-label--modifier="pf-m-no-padding" form-label--attribute=(concat 'for="' form--id '-horizontal-form-name"')}}
No padding label
{{/form-label}}
{{#> horizontal-form-group}}
{{#> check}}
{{#> check-input check-input--attribute='type="checkbox" id="alt-form-checkbox1" name="alt-form-checkbox1"'}}{{/check-input}}
{{#> check-label check-label--attribute='for="alt-form-checkbox1"'}}Follow up via email{{/check-label}}
{{/check}}
{{/horizontal-form-group}}
{{#> horizontal-form-group}}
{{#> check}}
{{#> check-input check-input--attribute='type="checkbox" id="alt-form-checkbox2" name="alt-form-checkbox2"'}}{{/check-input}}
{{#> check-label check-label--attribute='for="alt-form-checkbox2"'}}Remember my password for 30 days{{/check-label}}
{{/check}}
{{/horizontal-form-group}}
{{/form-group}}
{{/form}}
7 changes: 6 additions & 1 deletion src/patternfly/components/Form/form.scss
Expand Up @@ -69,10 +69,16 @@
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);
padding-bottom: 0;

&.pf-m-no-padding {
padding-top: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
padding-top: 0;
--pf-c-form__label--PaddingTop: 0;

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

}
}
/* stylelint-enable */

.pf-c-form-control,
.pf-c-form__horizontal-group,
Expand Down Expand Up @@ -144,7 +150,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