-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(form-legend): Add styling for compound form with a tooltip icon n…
…ext to the legend (#3151) * fix(form-legend): Add example in compound form for a tooltip icon next to the legend * fix(form-legend): export compoundForm for future use * fix(form-legend): Add tests * fix(form-legend): Attach styling to new class instead of utility * fix(form-legend-icon): Remove example * fix(form-legend-icon): Update docs to include form layout info and legend icon blockquote * fix(form-legend-icon): remove form-layout from the components list * fix(form-legend-icon): Add inline help as example in input * fix(form-legend-icon): Remove inline class * fix(form-legend): Skip test for now * Update tests
- Loading branch information
1 parent
9ed087a
commit f3c5b48
Showing
12 changed files
with
314 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...omponents/form-layout/__tests__/__snapshots__/Form_Layout_renders_a_base_form_layout.json
Large diffs are not rendered by default.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
...m-layout/__tests__/__snapshots__/Form_Layout_renders_a_base_form_layout_horizontally.json
Large diffs are not rendered by default.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
...nents/form-layout/__tests__/__snapshots__/Form_Layout_renders_a_compound_form_layout.json
Large diffs are not rendered by default.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
...ut/__tests__/__snapshots__/Form_Layout_renders_a_compound_form_layout_with_a_tooltip.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved | ||
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license | ||
/* eslint-env jest */ | ||
|
||
import React from 'react'; | ||
import createHelpers from '../../../../jest.helpers'; | ||
import { Form } from '../base/example'; | ||
import { CompoundForm } from '../compound/example'; | ||
|
||
const { matchesMarkupAndStyle } = createHelpers(__dirname); | ||
|
||
describe('Form Layout', () => { | ||
xit('renders a base form layout', () => matchesMarkupAndStyle(<Form />)); | ||
|
||
it('renders a base form layout horizontally', () => | ||
matchesMarkupAndStyle(<Form className="slds-form_horizontal" />)); | ||
|
||
it('renders a compound form layout', () => | ||
matchesMarkupAndStyle(<CompoundForm />)); | ||
|
||
it('renders a compound form layout with a tooltip', () => | ||
matchesMarkupAndStyle(<CompoundForm tooltip />)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,2 @@ | ||
// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved | ||
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license | ||
|
||
/** | ||
* To vertically stack `<label>` and `<input>` pairs, place `.slds-form--stacked` on the wrapper of the form for optimal spacing. | ||
* | ||
* To horizontally align a `<label>` and `<input>`, use the `.slds-form--horizontal` class on the wrapper around the form. A `.slds-form-element__label` takes up 33% of the width, and the `.slds-form-element__control` uses the remaining 66%. | ||
* | ||
* For optimum spacing and layout, wrap each element in `.slds-form-element`. Layout helper classes are available through the following class names, `.slds-form--stacked`, `.slds-form--horizontal` and `.slds-form--inline`. | ||
* | ||
* The read-only state is for form elements that can’t be modified. It is used for small, non-editable form fields that sit next to inputs and allows the size and height to align. It is not meant for large paragraphs of text. | ||
* | ||
* Because the read-only field state has no `<input>`, don’t use a `<label>` to provide better accessibility for screen readers and keyboard navigators. Instead, use a `<span>` with the `.slds-form-element__label` class. Instead of an `<input>`, use the `.slds-form-element__static` class inside the `.slds-form-element__control` wrapper. | ||
* | ||
* Error states alert the user when content in the form is invalid. The `.slds-has-error` class is placed on the `<div class="slds-form-element">`. Place the error message for the user in a `<span>` with the `.slds-form-element__help` class. | ||
* | ||
* The native form elements, `<input>`, `<textarea>`, `<select>`, `<input type='checkbox'>`, and `<input type='radio'>`, receive validation styling for `disabled`, `checked`, and `checked disabled`, if applicable. | ||
* | ||
* #### Accessibility | ||
* | ||
* Every field requires an associated, non-empty `<label>` element. The label should have a `for` attribute that references the `id` of the field. For example, `<label for="emailAddress">Enter email address:</label>` and `<input id="emailAddress">`. This association ensures that assistive technology informs users what information to enter where. | ||
* | ||
* If the field is required, the `<input>` element should have the HTML attribute `required` or `required=""`. Similarily, if it is disabled, it should have the `disabled` or `disabled=""` attribute. Do not use true/false values inside the `required` or `disabled` because the mere presence of these attributes signifies the field is required or disabled. | ||
* | ||
* If the field is invalid and displays an error message, the `<input>` element should have an `aria-describedby` attribute that references the `id` of the error message. This configuration allows screen readers to read the associated error message when the invalid field is focused. | ||
* | ||
* @summary An HTML form contains interactive controls to submit information to a web server. | ||
* | ||
* @base | ||
* @name form-layout | ||
* @selector .slds-form | ||
* @support dev-ready | ||
* @category structure | ||
* @type layout | ||
* @layout responsive | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters