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

Elements - Forms #91

Merged
merged 1 commit into from Jun 22, 2015
Merged

Elements - Forms #91

merged 1 commit into from Jun 22, 2015

Conversation

downzer0
Copy link
Contributor

This work adds forms and form elements to the pattern library. It consists of:

  • input, select, and textarea styles
  • scripts that visually replace select, radio, and checkbox controls giving us more control over the UI
  • suggested, semantic markup structure
  • styling for form elements in general

Form control replacements

For certain inputs and selects 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 buttons
  • checkbox buttons
  • select menus

Radio 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, and hovered
  • 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 height
  • tall

Width

Width can be set for any form control. To use a width, choose one of the following:

  • short
  • base our default width
  • wide
  • block which fills the entire width of the parent container

Range 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" and progress 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:

Platform Browser Version Passes
Mac Chrome 44 Yes
Firefox 24.3 Yes
Safari 8 Yes
PC Chrome 43 Yes
Firefox 37 Yes
IE 10 Yes *
11 Yes *

Reviewers:


This PR replaces #75. For history, comment, etc. please see it for details.

border-width: rem($baseline/2); // the handle is clipped without this
border-color: transparent; // the handle is clipped without this
background: transparent; // the handle is clipped without this
color: transparent; // hides the notches along the track; remove if you want them

Choose a reason for hiding this comment

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

Nice notes.

@frrrances
Copy link

Thanks for the good work @clrux! One small question, but not a blocker. 👍

@downzer0
Copy link
Contributor Author

@frrrances Good catch on that duplicate id/for, thanks. I've changed them to match the field appropriately and be unique.

downzer0 pushed a commit that referenced this pull request Jun 22, 2015
@downzer0 downzer0 merged commit 4b32a7a into master Jun 22, 2015
@downzer0 downzer0 deleted the clrux/elements-forms branch June 22, 2015 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants