Whilst sUPL had served the department well for a number of projects I wanted to update it to reflect recent changes in the front-end development world and also to put the emphasis back on the “simple” in sUPL. After reading around and trying out a number of existing front-end frameworks (e.g. as Blueprint, YUI, HTML5 Boilerplate, OOCSS and 320 and Up) I felt our own framework should be updated along the following lines:
- Be written it in HTML5, to make use of new structural elements and prepare the ground for the use of HTML5 APIs;
- Move away from terse class names to longer but more “human readable” ones;
- Employ the Object Oriented CSS (OCSS) methodology of maximising the reuse of CSS code by only applying CSS styles to classes, not IDs;
Welcome to SPIL: the Simple Presentation and Interface Library
There are quite a few frameworks out there so why create another one? Most of the existing frameworks have been created for highly specific purposes (e.g. YUI) or they are more generic (e.g. the HTML5 Boilerplate). SUPL’s successor, SPIL (Simple Presentation and Interface Library) can be thought of as a toolkit (or Lego!) for constructing web pages and applications, providing both a generic structure for page layout and the ability to “plug in” interface design patterns which will work “out of the box”.
<nav class=”primary”> …. </nav>
But should we want to stick with XHTML we could use:
<div class=”nav primary”> … </div>
The development of SPIL has been heavily influenced by Object Oriented CSS (OOCSS) — both the concept and the CSS library. OOCSS encourages the reuse of code in order to enhance performance and keep down CSS file size (also approximating the DRY — Do Not Repeat Yourself — concept in software engineering). One way to do this is to only style on classes — which can be used any number of times on a page — and not IDs — which can only be used once and also interfere with style inheritance. Class names can be chained together to combine styling effects, reusing predefined styles.
A useful concept in OOCSS is that of “modules”. Although SPIL’s implementation differs from that of the OOCSS library, the ideas are very similar. For instance, we can create a module object for a common design pattern, a tabbed display that can be plugged straight into a page template:
<div class=”mod tabs”> <ul class=”tabControls inline”> <li class=”tabControlHeader”><a href=”#tab1”>Tab 1</a></li> <li class=”tabControlHeader”><a href=”#tab2”>Tab 2</a></li> </ul> <div class=”tabPanes”> <section class=”tabPaneItem” id=”tab1”>Tab 1 content</section> <section class=”tabPaneItem” id=”tab2”>Tab 2 content</section> </div> </div>
$(".tabControls").tabs(".tabPanes > section");
An advantage of taking a modularised approach to code is we can start to build a library of predefined code snippets that can be slotted in place by anyone involved in interface building, from UI designers and programmers wanting to create a functional prototype through to front-end developers working on the final site build.
Development of SPIL
SPIL is being developed iteratively alongside new web projects within DDH. We’re feeding the work straight into an open source project which we hope will be available for release soon. If you have any comments or if there’s anything you’d like to see in the framework, why not less us know via the comments?