added fake readme
[curriculum.git] / README.md
CommitLineData
e2e5940d 1# Hamburgers
2
3Hamburgers is a collection of tasty CSS-animated hamburger icons. Also included is the source as a [Sass](#sass) library. It’s modular and customizable, so cook up your own hamburger.
4
5![](http://i.imgur.com/t7cUjDu.gif)
6
7### Table of Contents
8
9- [Usage](#usage)
10- [Sass](#sass)
11- [Customization](#customization)
12- [Accessibility](#accessibility)
13- [Browser Support](#browser-support)
14
15## Usage
16
171. [Download](https://github.com/jonsuh/hamburgers/blob/master/dist/hamburgers.css) and include the CSS in the `<head>` of your site:
18
19 ```html
20 <link href="dist/hamburgers.css" rel="stylesheet">
21 ```
22
232. Add the base hamburger markup:
24
25 ```html
26 <button class="hamburger" type="button">
27 <span class="hamburger-box">
28 <span class="hamburger-inner"></span>
29 </span>
30 </button>
31 ```
32
33 You *can* use `<div>`s if you insist, but they’re not [accessible](#accessibility) as a menu button.
34
35 ```html
36 <div class="hamburger">
37 <div class="hamburger-box">
38 <div class="hamburger-inner"></div>
39 </div>
40 </div>
41 ```
42
433. Append the class name of the type of hamburger you’re craving:
44
45 ```html
46 <button class="hamburger hamburger--collapse" type="button">
47 <span class="hamburger-box">
48 <span class="hamburger-inner"></span>
49 </span>
50 </button>
51 ```
52
53 Here’s the list of hamburger-type classes you can choose from:
54
55 ```
56 hamburger--3dx
57 hamburger--3dx-r
58 hamburger--3dy
59 hamburger--3dy-r
60 hamburger--3dxy
61 hamburger--3dxy-r
62 hamburger--arrow
63 hamburger--arrow-r
64 hamburger--arrowalt
65 hamburger--arrowalt-r
66 hamburger--arrowturn
67 hamburger--arrowturn-r
68 hamburger--boring
69 hamburger--collapse
70 hamburger--collapse-r
71 hamburger--elastic
72 hamburger--elastic-r
73 hamburger--emphatic
74 hamburger--emphatic-r
75 hamburger--minus
76 hamburger--slider
77 hamburger--slider-r
78 hamburger--spin
79 hamburger--spin-r
80 hamburger--spring
81 hamburger--spring-r
82 hamburger--stand
83 hamburger--stand-r
84 hamburger--squeeze
85 hamburger--vortex
86 hamburger--vortex-r
87 ```
88
89 Note: `-r` classes are reverse variants (e.g. `hamburger--spin` spins clockwise whereas `hamburger--spin-r` spins counterclockwise.
90
914. Trigger the active state by appending class name `is-active`:
92
93 ```html
94 <button class="hamburger hamburger--collapse is-active" type="button">
95 <span class="hamburger-box">
96 <span class="hamburger-inner"></span>
97 </span>
98 </button>
99 ```
100
101 Since the class name would have to be toggled via JavaScript and implementation would differ based on the context of how you plan on using the hamburger, I’m going to leave the rest up to you.
102
103## Sass
104
105`.scss` source files are available if you use Sass as your CSS precompiler. It’s customizable and modular.
106
1071. Hamburgers is available on [npm](https://www.npmjs.com/package/hamburgers), yarn and [Bower](http://bower.io/search/?q=css-hamburgers).
108
109 ```
110 npm install hamburgers
111
112 yarn add hamburgers
113
114 bower install css-hamburgers
115 ```
116
117 Also available as a [Ruby gem](https://rubygems.org/gems/hamburgers) to use within your Rails application—see [below](#install-for-ruby-on-rails) for more information.
118
119 Or to manually install it, [download](https://github.com/jonsuh/hamburgers/archive/master.zip) and unzip the source files, then copy the files from the `_sass/hamburgers` directory into your project.
120
1212. Import the `hamburgers.scss` file in your Sass manifest file:
122
123 ```scss
124 @import "path/to/hamburgers";
125 ```
126
1273. Customize your hamburger and/or remove any types you don’t want in `hamburgers.scss`.
1284. Compile your Sass*, and voila!
129
130\* Be sure to run the CSS through [Autoprefixer](https://github.com/postcss/autoprefixer) since the Sass doesn’t account for vendor prefixes.
131
132### Install for Ruby on Rails
133
1341. Add Hamburgers to your Gemfile.
135
136 ```
137 gem 'hamburgers'
138 ```
139
1402. Run `bundle install`.
1413. Include Hamburgers by using Sass’s native `@import`**:
142
143 ```scss
144 // application.scss
145 @import "hamburgers";
146 ```
147
148 \** [More information](https://blog.pivotal.io/pivotal-labs/labs/structure-your-sass-files-with-import) on why Sass’s native `@import` + why you should ditch Sprockets directives altogether.
149
150## Customization
151
152To override default settings, declare them before importing Hamburgers:
153
154```scss
155$hamburgers-padding-x: 20px;
156$hamburgers-padding-y: 15px;
157$hamburger-types : (collapse);
158
159@import "hamburgers";
160```
161
162You can also create a separate file (e.g. `hamburgers-settings.scss`) with those declarations, then import it before Hamburgers:
163
164```scss
165@import "hamburgers-settings"
166@import "hamburgers";
167```
168
169Here is the full list of default settings (found in `_sass/hamburgers/hamburgers.scss`);
170
171```scss
172$hamburger-padding-x : 15px;
173$hamburger-padding-y : 15px;
174$hamburger-layer-width : 40px;
175$hamburger-layer-height : 4px;
176$hamburger-layer-spacing : 6px;
177$hamburger-layer-color : #000;
178$hamburger-layer-border-radius : 4px;
179$hamburger-hover-opacity : 0.7;
180$hamburger-hover-transition-duration : 0.15s;
181$hamburger-hover-transition-timing-function: linear;
182
183// To use CSS filters as the hover effect instead of opacity,
184// set $hamburger-hover-use-filter as true and
185// change the value of $hamburger-hover-filter accordingly.
186$hamburger-hover-use-filter: false;
187$hamburger-hover-filter : opacity(50%);
188
189// Remove or comment out the hamburger types you don’t want
190// or need, so they get excluded from the compiled CSS.
191$hamburger-types: (
192 3dx,
193 3dx-r,
194 3dy,
195 3dy-r,
196 3dxy,
197 3dxy-r,
198 arrow,
199 arrow-r,
200 arrowalt,
201 arrowalt-r,
202 arrowturn,
203 arrowturn-r,
204 boring,
205 collapse,
206 collapse-r,
207 elastic,
208 elastic-r,
209 emphatic,
210 emphatic-r,
211 minus,
212 slider,
213 slider-r,
214 spring,
215 spring-r,
216 stand,
217 stand-r,
218 spin,
219 spin-r,
220 squeeze,
221 vortex,
222 vortex-r
223);
224```
225
226#### `ems` or `rems`
227
228Wanna work with `ems` or `rems` instead of `px`? Just change all the `px` values to the unit of your choice. Note: Be consistent (all `px` or all `ems`), otherwise it may break—the math behind the customization will fail if it attempts to perform operations with values of different units.
229
230### Not satisfied?
231
232Dig into `_base.scss` or `types/` and customize to your heart’s content. Fair warning: It‘s pretty delicate and may break, especially if you tweak the animations themselves.
233
234## Accessibility
235
236Hamburger menu icons can be useful in the right context, but they’re not the most accessible.
237
238ARIA will help make it accessible to people with disabilities.
239
240```html
241<nav>
242 <button class="hamburger hamburger--elastic" type="button"
243 aria-label="Menu" aria-controls="navigation" aria-expanded="true/false">
244 <span class="hamburger-box">
245 <span class="hamburger-inner"></span>
246 </span>
247 </button>
248
249 <div id="navigation">
250 <!--navigation goes here-->
251 </div>
252</nav>
253```
254
255You will need JavaScript to toggle between `aria-expanded` attribute being set to `true` and `false`, as this will indicate to visually impaired users whether the menu is opened or closed.
256
257The hamburger button belongs __inside__ the `<nav>` so that assistive technologies will be able to locate the navigation, and to allow these users to easily locatate the hamburger button, without having to search up and down the DOM, once they realize they've found themselves in an empty navigation.
258
259If you insist on using `<div>`s, by default they’re not focusable (i.e. via keyboard or assistive technology). Add the `tabindex` attribute alongside ARIA. You will also need to recreate expected keyboard functionality for these `<div>`s. Using JavaScript, you will need to make sure that both <kbd>Space</kbd> and <kbd>Enter</kbd> will toggle the hamburger states.
260
261```html
262<nav id="navigation">
263
264 <div class="hamburger hamburger--elastic" tabindex="0"
265 aria-label="Menu" role="button" aria-controls="navigation" aria-expanded="true/false">
266 <div class="hamburger-box">
267 <div class="hamburger-inner"></div>
268 </div>
269 </div>
270
271 <div id="navigation">
272 <!--navigation goes here-->
273 </div>
274</nav>
275```
276
277A label will help make it more obvious that it toggles a menu.
278
279```html
280<button class="hamburger hamburger--collapse" type="button">
281 <span class="hamburger-box">
282 <span class="hamburger-inner"></span>
283 </span>
284 <span class="hamburger-label">Menu</span>
285</button>
286```
287
288Here are [some](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) [resources](https://webaccessibility.withgoogle.com/course) on [web](http://a11yproject.com/) [accessibility](http://www.html5accessibility.com/) and [ARIA](https://w3c.github.io/aria-in-html/).
289
290## Browser Support
291
292Animations use CSS3 3D transforms (`translate3d` whenever possible for GPU acceleration), which is supported by most browsers (not supported by IE9 and older and Opera Mini). For detailed browser support, check [caniuse.com](http://caniuse.com/#search=translate3d).