Newsfeeds

Advomatic: Responsive & adaptive grids with Susy, Sass & Compass in Drupal 7

Planet Drupal - 10 May 2013 - 9:06am

Here at Advomatic we've experimented with several approaches to responsive design over the past few years. I think the "mobile first" philosophy became popular right in the nick of time. There was a point when we'd detect if the user was on a mobile device and then deliver a separate mobile theme. This meant two instances of a site to develop for and maintain. I can't imagine doing that now, given the amount of device width/height possibilities and device-specific bugs that exist out there. So, now we work on layout with the goal of accommodating the content rather than the device. To accommodate a responsive and flexible layout, it's best to get your site on a grid. There are tons of options out there, but we've found one in particular helps you quickly get rolling and set up with a column layout that can adjust to whatever device you need your site to display on (and is fun to work with, too). Lately, it's been part of our holy trinity for responsive theming: Sass, Compass and Susy.

First things first: ditch pixels

One big first step to responsiveness in your site is to stop using pixel units for measurements. We use em units because they are proportional to any parent measurement, and therefore flexible and responsive. If we have a base font-size set on the body element of 16px, and our #footer is set to 1.6em, that #footer font-size will automatically scale up or down accordingly if the body's (or any parent element to #footer, for that matter) font-size changes.

To manually figure out exactly what em value you should be using for an element, you can use a commonly used formula: target ÷ context = result... or you could do it the easy way with a Sass function:

// Create em() for setting font-sizes in pixels.
@function em($target, $context: $base-font-size) {
   @if $target == 0 { @return 0 }
   @return $target / $context + 0em;
}

// Example usage: font-size: em(21px);
// This will set the font-size to 21px in relation to the browser's base font size if it has not been established in any parent element, or in relation to $base-font-size which is a variable you can set in your Sass.

// Example usage 2: font-size: em(12px, 10px);
// This will set the font-size to 12px in relation to a parent element's font-size of 10px.

Get on the grid

If you're doing front end development these days, you're probably familiar with the concept of grid-based design and translating a comp into a fully fluid or adaptive layout via HTML/CSS. We frequently use Zen 5 as a base theme and have been big fans over the years because it comes loaded with many of the best tools for front end/theme development, while also pretty lean as far as bloat goes. While it's important to be able to build themes for browsers that can handle fancy bells and whistles, we also need to support older browsers that don't. Zen 5 already has Sass and Compass integrated. As far as a grid framework goes, we use Susy instead of Zen Grids... this has just come down to personal preference. Zen Grids is also a great system.

Susy is a responsive grid framework/plugin for Compass, and it allows you to build on top of either a "magic", static or completely fluid grid.

  • "Magic" grids are the default - they have an elastic container that responds to font sizes when set with em units, and is fluid on the inside. It's container size gets calculated according to the widths of your columns and gutters.
  • Static grids are just that - all containers and column widths are not flexible and this is the traditional grid style. As such, it does not collapse when the viewport is smaller than the grid is wide. Even though you may specify pixel values for the column sizes, Susy converts to a percentage of the container size. The container size, like the magic grid, gets calculated according to the widths of your columns and gutters.
  • Fluid grids are truly flexible layouts that respond to the width of the viewport. By default the container width is 100%. However, as with any grid type you choose, you can specify this with the $container-width variable (such as "$container-width: 70%").
Set it all up

To add Susy to your theme, there are a few things you'll need to do.

  1. If you haven't already, install Sass and Compass. sudo apt-get install rubygems
    sudo gem update
    sudo gem install sass sudo gem install compass
  2. Set up a Compass project in your theme directory.

    This is already done for you with Zen 5. If you're not using Zen 5 or a contrib theme that has this done already (look for a config.rb file in the theme directory), then set up your Compass project by going to your theme directory in your favorite command line interface and run:

    compass create nameofyourtheme

    This will add a "config.rb" file to your theme, and is where the Compass project settings are located.

  3. Then, install Susy. sudo gem install susy
  4. Require Susy in your Compass project.

    Open up the config.rb file and add the following (wherever "requires" are located):

    require "susy"
  5. @include susy and add grid settings to your _base.scss (or equivalent "global" Sass file).

    We usually stick any of our grid settings in the _base.scss file that comes with Zen so that the grid variables set there are available to any other Sass stylesheet in the theme (because Zen's base gets @imported in them all). You'll also want to place them in whatever Sass file you're using that gets imported into any file where you'll be doing responsive styling/layout. For example:

    @import "susy";
    $total-columns: 12;             // a 12-column grid
    $column-width: 4em;            // each column is 4em wide
    $gutter-width: 1em;            // 1em gutters between columns
    $grid-padding: $gutter-width;  // grid-padding equal to gutters

After installing Susy, and getting your Compass project set up properly for the theme, you'll want to tweak those default grid settings that you just added (total columns, column width, grid padding, etc...) for the purpose of your own design. Using those settings, Susy will automatically figure out the math and put percentage widths on internal grid elements, as well as a max-width on the container (should you use a non-fluid grid). By default, all Susy grids are "magic." If you want to use one of the other types of grids, you would do that by setting the $container-style variable. For example, to build a 5 column-wide mobile first "magic" layout, we can do something like this:

$total-columns: 5;
$column-width: 3em;
$gutter-width: .75em;
$grid-padding: $gutter-width; Making things happen at different viewport sizes

Another handy part of Susy is its at-breakpoint() mixin. This can be used in replacement of a long and drawn out media query that targets specific pixel-based min-width or max-width values of the viewport. Something we do frequently for adaptive/responsive layouts (where there are established, comp-determined breakpoints for mobile, tablet, desktop), is set variables for different numbers of grid columns.

$mobile   : 5;
$tablet   : 11;
$desktop  : 16;

So if you're building in a mobile first manner like this, and you want something to happen at a certain breakpoint in your Sass, you can use at-breakpoint() with your column count variables as an argument.

#content {
  @include span-columns(5);
  @include at-breakpoint($desktop) {
    @include span-columns(13, $desktop);
    @include prefix(3, $desktop);
  }
}

In this situation, #content normally spans 5 columns wide, which is the default/mobile width of the grid in this example. When the viewport is at the desktop breakpoint (16 columns can fit in the viewport), the width of #content will change. span-columns(13, $desktop) means "make this 13 columns wide, out of 16 total columns". prefix(3, $desktop) means "add 3 columns of empty space beforehand." So #content becomes 16 columns wide in total, however only 13 columns of space are usable and contain content, since we added 3 columns of padding to the start.

A different, non-layout related way of using at-breakpoint() is to maybe change some kind of style at a given breakpoint.

padding-bottom: em(15px);
@include at-breakpoint($desktop) {
  padding-bottom: em(85px);
  background: url("bg-content.png") 162px 100% no-repeat;
}

Having at-breakpoint() at the ready is a great way of releasing yourself of the mindset and clutter of maintaining several pixel-based breakpoints in your site, and helps future-proof things since device sizes are fluctuating so wildly as time goes on. Since Sass supports code nesting, it has become standard operating procedure for us to use at-breakpoint() at the end of things in a selector's nested styles, so that they override any established defaults (which are usually the mobile version styles if we are building mobile-first).

Alternatively, Aurora

While we normally use Zen and add Susy in manually (replacing Zen Grids), some themes have Susy, Sass and Compass (and other front end goodies) baked in already. Aurora is also a Sass & Compass-powered minimalist theme with a focus on best practices for HTML5 and front end development within Drupal. It has a number of cool features like Google Chrome Frame and Typekit integration. Aurora encourages the use of Panels' HTML5 Sections layout instead of using the standard Drupal left/right sidebar block regions for sidebars. Aurora also suggests you use the Blockify module to turn all the little things on the page that normally get rendered in a page template variable into blocks that you can assign to regions via Drupal's block admin page. There are a number of features in Aurora which have been pulled out and put into a separate module, so that any theme can make use of them. That module is called Magic and some of it's best features are the ability to exclude certain CSS/JS from being included, exporting of theme settings, enhancement of CSS aggregation and adding a viewport width indicator - which is very helpful when developing a responsive site to check all your breakpoints and everything in between.

Conclusion

Susy provides a great way of quickly getting your site layout blocked out and can produce any kind of grid you need. What has your experience been like using Susy in Drupal?

Categories: Drupal

Feeds: Media Internet Files

New Drupal Modules - 10 May 2013 - 8:40am

The result of this module is the same as Feeds: Files, but instead of using a custom Feeds Processor we use the file_presave hook to convert URL -> URI when using the Entity Processor for Files in the unpublished Entity Processor Branch of the Feeds module.

Like Feeds: Files, the hope is that this module will become obsolete and the Entity Files Processor would support Media directly.

Categories: Drupal

Lullabot: Insert Content Here, Episode 13: Jason Scott talks Digital History and Content Preservation

Planet Drupal - 10 May 2013 - 8:32am

Jeff Eaton and Jason Scott discuss digital preservation, the historical importance of the web, and the utility of large hard drives.

The web is a part of our culture now, and perserving its history has value
Categories: Drupal

DaCast Streaming as a Service Integration

New Drupal Modules - 10 May 2013 - 8:10am
DaCast Video Module for Drupal

The DaCast Streaming as a Service video platform allows broadcasters to offer live and on demand streaming content directly to their website, through using a robust CDN (Content Delievery Network) and optional, integrated monetization features, including Pay Per View and Subscriptions. The video platform gives business and website owners total control of their online video through a white label platform, easy site integration and advanced restriction and protection features to secure content.

The DaCast module integrates these professional services into Drupal. Through using it, you can add DaCast video streams to your content and access video information entered from your DaCast account

For Drupal 7

The current module is for Drupal 7.
Development for other versions of the CMS are coming.

Support

For additional support using the module, please login to your DaCast account and open a support ticket (clicking HELP and then SUPPORT) mentioning Drupal Module in the subject line.

Download

The latest release for Drupal 7 is found below:

Release 05-03-2013

Categories: Drupal

Ubercart Googlebasse RSS Feed

New Drupal Modules - 10 May 2013 - 8:00am

This Module creates a Googlebase compliant product RSS feed.
A 'hard copy' .XML file with your products will be created which can then be read by the googlebase googlebots.
A few extra fields to the standard Ubercart installation are required, see module help once installed.

Categories: Drupal

Scald Gallery

New Drupal Modules - 10 May 2013 - 7:57am

Scald Gallery is a gallery provider for Scald.

  • The 1.x branch was started by slashrsm and is feature complete. It uses plupload for file upload, Galleria for gallery display, and only images can be used in a gallery. It needs a few clean up and will be released in the next few days.
  • The 2.x branch, based on and is backward compatible with 1.x, leverages multiple upload types (soon to be available in Scald), supports any atom types, has better UI etc. and will be available in the next few weeks.

Scald Gallery is sponsored by Open Web Solutions and Le Figaro.

Categories: Drupal

Fútbol

New Drupal Modules - 10 May 2013 - 7:32am

Fútbol is a module for recording football (association football/soccer) statistics. It is intended to be all encompassing, so users can record things such as:

  • Clubs/teams
  • Fixtures
  • Results
  • Competitions
  • Staff (players/managers/coaches etc)
  • Officials (referees, assistant referees etc)
  • Associations (such as UEFA or the FA)
  • Stadia

It also provides deep Views integration so that all data can be displayed in the correct format, such as league tables.

Categories: Drupal

Marek Sotak: Revolution in end-user documentation! Say hello to Inline Manual

Planet Drupal - 10 May 2013 - 6:18am

Let's face it. Making documentation for end-users (content editors, administrators, etc...) is the most painful process of all the processes when it comes to handing over a project to the client. Hard to estimate, time consuming to create, never up to date, almost impossible to re-use, change one thing and you have to rebuild all the screenshots, realisation that nobody reads it, etc... Sounds familiar?

Categories: Drupal

VideoJS Filter

New Drupal Modules - 10 May 2013 - 5:33am

This is really simple module.
It requires VideoJS module to be installed before.
It replaces [videojs:{video_file}|poster:{poster_file}|width:{width}|height:{height}] to video with VideoJS player. {video_file} is required argument.

Instillation & setup.

Turn on module, go to text formats page and turn on filter.
Put you videos in some separate folder in Drupal files directory,
align settings on admin/config/media/videojs

Categories: Drupal

Paddle Panel Layouts

New Drupal Modules - 10 May 2013 - 4:57am

Panel layouts for the Paddle distribution.

Categories: Drupal

Commerce VAT

New Drupal Modules - 10 May 2013 - 4:11am

Commerce VAT module replaces the Tax module supplied with Commerce for use with conditional VAT rates.

Will be used by:

  • Commerce European Union VAT (2.x)
  • Commerce Iceland VAT
  • Commerce Norway VAT
  • Commerce Switzerland VAT
Categories: Drupal

comm-press | Drupal in Hamburg: OMG! Drupalcon Porland! So many sprinters!

Planet Drupal - 10 May 2013 - 1:46am
Knowledge Language English OMG! Drupalcon Porland! So many sprinters!Cathy Theys05/10/2013 - 10:46350 people! Will any of the 350 new contributors work on any issues you are passionate about?

We are estimating 350 participants at the mentored Get Involved with Core Sprint on Friday May 24, 2013 at Drupalcon Portland. That's a lot of people, and we will need a lot of tasks for them to work on during the sprint. One of the things we know about a successful sprint is that creating a task list in advance is critical. But we do not want to make the task list too far in advance. Because if made too far in advance, it will get out of date and some tasks become not relevant. Mentors will be meeting on Tuesday May 21, 2013 at 4:30 to do task selection. That will be right after the session about being a mentor and sprint planning: Running coaches wanted! Contribution sprints and trainings.

Categories: Drupal

Diversity Enricher

New Drupal Modules - 10 May 2013 - 1:40am

This extension utilizes several technologies from the RENDER technology stack (see RENDER project). In enables the user to browse through diversity aware information extracted from the articles stored in DRUPAL. A demo can be found at the Demo page.

Categories: Drupal

Web Omelette: Cool Module: Maxlength

Planet Drupal - 10 May 2013 - 12:20am

Maxlength is a cool module that allows you to set maximum character limits for your Drupal form text fields. Not only that users who fill in these forms can see the maximum number of characters they can write but they will also be prevented from writing more than they should.

Categories: Drupal

Recipe feature sandbox

New Drupal Modules - 9 May 2013 - 11:46pm

This is a rough WIP prototype of a recipe feature, using configuration for as much functionality as possible. Let me know if you are interested in collaborating on this.

Categories: Drupal

Twig Filter

New Drupal Modules - 9 May 2013 - 9:52pm

Allow the Use of Twig as a action in Rules.

Categories: Drupal

Typical Entity Examples

New Drupal Modules - 9 May 2013 - 9:30pm

This module provides a pack of typical example entities.

First entity created in this module is the smallest possible entity. Every next entity is gradually improved version of the previous one. The last entity from this module is the rather complex entity with the user interface for creating entity bundles.

This module can be useful for people who want to learn how to develop entities step-by-step.

Development of this module was sponsored by the OITS Co. Ltd.

How to use

Sub-modules typical_entity_example_1, typical_entity_example_2 and typical_entity_example_3 don't have user interface, but they can be tested with "Testing" module.

Sub-modules typical_entity_example_4 and typical_entity_example_5 available at the following pathes:

  • /typical_entity_4
  • /typical_entity_5

Sub-module typical_entity_example_6 provides the following URIs:

  • Manage typical_entity_6 bundles:/admin/structure/typical_entity_6
  • Manage typical_entity_6 entities: /typical_entity_6
Categories: Drupal

LAKELET Qrigo

New Drupal Modules - 9 May 2013 - 9:06pm

LAKELET Qrigo

Categories: Drupal

Sandy's Soapbox: Grading and Scoring

RPGNet - 9 May 2013 - 9:00pm
Gradeable questions and how to grade them.
Categories: Game Theory & Design

Fartscroll

New Drupal Modules - 9 May 2013 - 8:31pm

Give your website the ability to fart on command!

Categories: Drupal
Syndicate content