-
Notifications
You must be signed in to change notification settings - Fork 38
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
Elements: Forms and form controls #75
Conversation
5efb8ad
to
5818212
Compare
Thanks, @clrux! I walked through the work visually and have some feedback below - I'll look through the code next. Element stuff:
Pattern Library stuff:
|
--- | ||
|
||
<h3 class="hd-4 example-set-hd">Forms</h3> | ||
<h4 class="hd-5">Text inputs</h4> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to hd-6 class
Okay, I made it through all the code! Left a bunch of comments. Once you address those, I can run through again. One last request: it might be nice to have an example form from start to end at some point - maybe on a standalone page? Not sure if we're ready for that, but it would be really helpful for people using it and to get a sense how it all goes together. |
@clrux, just a heads up, locally after I use the
|
* as the pattern library should be used inside of application imports * and updating PL doc site gulp tasks to watch+compile
…ng styling tabs when appopriate
4d597df
to
05a6ac4
Compare
Replaced by #91. |
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: