Ceci est une ancienne révision du document !
Last month I mentioned the Zurb Foundation when discussing bower. For a long while it was my go-to grid system, regardless of my opinion towards using divs for rows and the strict formatting guidelines. Very recently, however, I have found a new framework which does not require those sorts of divs (or even pre-defined classes). It is called Jeet, and after using it on only one project, I don’t see myself using Foundation for the grid any more.
Example Files
I’ve created a github repository containing all my example files. For anyone interested in them, they can either be viewed on the web, or cloned. The repository is here: https://github.com/lswest/FCM91.
Jeet - What is it?
Jeet is a so-called “Ratio Grid”. It features functions in SASS or Stylus to generate the CSS required to create columns on any element. The website linked to in Further Reading (below) does an excellent job describing what exactly Jeet is. So instead, I will focus on an example of how it differs from Foundation.
Emmet? Who?
Emmet is essentially the spiritual successor to Zen Coding. It enables you to enter a series of selectors (based off the CSS selectors), which then auto-completes into HTML code when you hit tab. There are plugins available for the vast majority of text editors, so you should have no problem finding one.
The Emmet example
For the illustration between the differences of Jeet and Foundation, I will use the same three statements in Emmet, and work from there. After each statement, I’ll hit tab and have emmet complete it, then move onto the next. They are:
html:5 This generates the basic HTML5 page structure (doctype, html tags, head and body). link[href=”css/foundation.css”]:css This generates a <link rel=”stylesheet” href=”css/foundation.css”> line. Replace foundation.css for app.css for the Jeet example
header+section>article+aside^footer This creates a set of header tags, followed by (“+” adjacent sibling selector) a section element with two children (“>”, an article and an aside), and then a following (“^“ up one level) footer tag.
After running these commands, I will have a basic HTML5 page. To see what the end result was, look in the emmet.html file in the example code.
The Example
Assuming you wanted to create a two-column layout that spans the whole width of the webpage, you’d need to do the following for Foundation: • Create a div with class “row” within the body tags. • Create an extra style to expand the width of the row to 100%. • Add your column classes to every element. • Add a div with class “row” around the article and the aside elements within section.
The same steps for Jeet (starting after the emmet file was created): • Run the cf() function on header, footer and section (Not strictly necessary, but it definitely doesn’t hurt). • Run the column function on article and aside (col(0.75) and col(0.25) respectively). • Compile the scss or stylus file.
In both cases, I’ve added a few extra styles to help illustrate the end layout, but as they aren’t necessary, I haven’t included them.
Note: The functions for Jeet can be run in scss, but that requires the format @include col(0.75); The format I use above is for Stylus.
Note #2: If you want to work on the stylus file, you’ll first need to install jeet (most easily done via npm).
The conclusion
As you can see, the configuration of the columns occurs in a stylesheet, meaning you can focus on creating a basic html structure, and then only edit it as you add extra styles that you may need. You’re not forced to adjust the columns by editing the element tags, which is great when you’re working with a CMS and won’t necessarily be able to easily edit an HTML file to make your changes. Another benefit is that the compiled CSS file contains literally only the styles you use. While Foundation does let you pick and choose different modules to compile, there is very often a large amount of unnecessary code.
Hopefully this will help bring Jeet to the attention of those just starting out, so they can focus more on good formatting and being succinct rather than conforming to the Zurb Foundation format. That isn’t to say Foundation isn’t useful for certain aspects, as it offers more than just a grid (such as pre-defined styles for buttons or menus), and it can easily be mixed with the Jeet grid.
Final note: If you want Jeet to work in older versions of Internet Explorer, you’ll need to use something like selectivzr, modernizr, or HTML5shiv, or a combination.
I hope this article has been helpful to anyone starting out with web programming. If you have any questions, or have used either Emmet or Jeet for an interesting project, feel free to email me at lswest34+fcm@gmail.com. Also, anyone who has a request for an article is also welcome to email me.
Further Reading
http://jeet.gs/ - The Jeet Framework https://github.com/mojotech/jeet/tree/master/stylus - The Jeet Framework Stylus github repository with useful stylus projects (listed under Protips). http://emmet.io/ - The Emmet website https://github.com/lswest/FCM91 - Github repository with examples.