0.0.2 • Published 8 years ago

SkyLabels.js v0.0.2

Weekly downloads
12
License
MIT
Repository
github
Last release
8 years ago

SkyLabels.js

Fun, Compact & Accessible Forms

Try out a live demo

Why SkyLabels.js?

  • Customizable through CSS. Changes animations, styles, etc.
  • Accessible (uses a label element).
  • Doesn't require that you change your layout. The labels slide above all other content.
  • Easy to read the labels even when the input is focused.

Getting Started

If you are using Rails, check out sky-labels-rails. Otherwise, read the following.

  1. Download JavaScript & CSS files. Get them from /dist/sky-labels.min.js and /dist/sky-labels.css.
  2. Put JavaScript & CSS files in your CSS and JavaScript directories.
  3. Link to the JavaScript in your <head> tag or near the end of the <body> tag. Be sure to add sky-labels.min.js below jQuery.
  4. Wrap inputs & labels in a <section>, <div> or other block level element with the class sky-label. Be sure the label has a for that matches the input.
  5. Call setupSkyLabels() during the domready event or right after you include the sky-labels.min.js.
  6. Customize the CSS to your liking! You can change how it animates, colors, size, etc.

Example HTML

<!-- Put the stylesheet in the <head> -->
<link rel="stylesheet" type="text/css" href="css/sky-labels.css">
<!-- In your <head> or just before the </body> tag -->
<script src="js/sky-labels.js"></script>
<!-- Setup events for slide labels -->
<script type="text/javascript">
setupSkyLabels();
</script>
<!-- Wrap the input and label in a block element with the class "sky-label" -->
<section class="sky-label">
  <!-- Be sure the for matches the input so that when the label is clicked the
input is focused -->
  <label for="first-name">First name</label>
  <input name="first-name" id="first-name" type="text">
</section>

Check out the example HTML from the SkyLabels.js website

Styling and animating your SkyLabels

SkyLabels.js adds and removes styles from the element with the class sky-label so that you can customize every step of the slide.

The class are applied as follows

  • sky-label-focused when the input has been focused
  • sky-label-has-text when the input has text

You can apply styles and animations based on these two classes. See the example CSS from the SkyLabels.js website.

For Developers

You need node. Then, in your shell:

git clone https://github.com/thoughtbot/sky-labels.git
cd sky-labels
npm install -g grunt-cli
npm install
grunt # This compiles and minifies the JavaScript and Sass into dist/

Using Tests

Sky Labels uses Jasmine for testing. Add new specs to the spec folder.

To run tests: open spec/runner.html

0.0.2

8 years ago