Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This work adds forms and form elements to the pattern library. It consists of:
Form control replacements
For certain
inputs
andselects
we're offering options to use either the default browser-rendered control or a replaced control, either rendered by JS or CSS or both. The idea for the radio buttons and checkboxes came from Heydon Pickering and an article on Sitepoint. The form controls with options are:radio
buttonscheckbox
buttonsselect
menusRadio buttons and checkboxes
To enable the enhanced version of a radio button or a checkbox, do the following:
<input type="radio" class="replace-radio">
<input type="checkbox" class="replace-checkbox">
Replacing radio buttons and checkboxes uses an accessible CSS-only approach that hides the default control, replacing it with a CSS rendered one. Interactions with the control still happen on the default control which maintains full accessibility and browser methods.
Select boxes
To enable the enhanced version of a select menu, do the following:
<select class="replace-select">
Replacing select menus uses an accessible JavaScript and CSS approach. JavaScript hides the default control, replacing it with a styled wrapper using the selected value. Interaction still happens with the default control which maintains complete accessibility and compliance.
States
For each of the form input controls we've created and demonstrated the following states:
normal
active
,checked
,selected
, andhovered
disabled
required
User feedback, message handling
This piece of work also includes user feedback messages for form field validation. The cases included are:
warning
error
success
Nested styles
In many cases we're using nested styles. The aim here is to slightly reduce modularity but promote a semantic structure.
Form control heights and widths
To provide a nice set of options both for us internally and the Open edX community, I've created various sizes for form controls.
Height
Height primarily relates to
textareas
. To use a height, choose one of the following:short
base
our default heighttall
Width
Width can be set for any form control. To use a width, choose one of the following:
short
base
our default widthwide
block
which fills the entire width of the parent containerRange slider and Progress bars
The visual UI included a slider, but it was a hybrid of a progress bar and a range slider. Since nothing like that is available natively I created two different elements:
input type="range"
andprogress
and created styles for these as I found fit.Slider/Range
The slider control allows "notched" or fixed selections along a track. There is no "before/after" or "complete/incomplete" which was the discrepancy in the UI. I've included styles for this that makes the handle increase in size when it's hovered over, making the click target/control more usable.
Progress
Unlike slider controls, progress bars do have a "before/after" or a "complete/incomplete" state. This matches the UI a little closer, but progress bars don't have drag handles.
Browser testing
This work has been tested in the following browsers:
Reviewers:
This PR replaces #75. For history, comment, etc. please see it for details.