21
skeleton x codekit x magento ...and the case for separate css/js files @ldn_tech_exec #magentoLDN 4 july 2012

Magento x codekit x sass x compass x skeleton responsive grid

Embed Size (px)

DESCRIPTION

A presentation by @ldn_tech_exec for #magentoLDN on extreme CSS techniques, how to set up codekit, compass and sass/scss and the skeleton responsive/adaptive framework for Magento source code: https://github.com/arush/mage-skeleton

Citation preview

Page 1: Magento x codekit x sass x compass x skeleton responsive grid

skeleton x codekit x magento

...and the case for separate css/js files

@ldn_tech_exec#magentoLDN

4 july 2012

Page 2: Magento x codekit x sass x compass x skeleton responsive grid

skeleton

● base.css● layout.css● skeleton.css

Page 3: Magento x codekit x sass x compass x skeleton responsive grid

skeleton x magento

● base.css● skeleton.css● layout.css

● no-frame.phtml● app/code/local/Mage/Page/etc/config.xml● app/etc/modules/Mage_All.xml● local.xml - add no-frame.phtml to any page

Page 4: Magento x codekit x sass x compass x skeleton responsive grid

no-frame.phtml

● removed all columns● viewport

<meta name="viewport" content="width=device-width, initial-scale=1.0">

● facebook compatibility● html IE classes

Page 5: Magento x codekit x sass x compass x skeleton responsive grid

html IE classes

● the old way (slooow)<link href="style.css" rel="stylesheet" /><!--[if lte IE7]><link href="style.ie7.css" rel="stylesheet" /><![endif]-->

● hacks (dangerous and not valid)#content { margin: 10px; _margin:20px; }

● the correct way (html5 bp)<!--[if lt IE 7]> <html class="ie ie6 lte9 lte8 lte7">

Page 6: Magento x codekit x sass x compass x skeleton responsive grid

allows you to do this.gte9 .gradient {

filter: none;}

Page 7: Magento x codekit x sass x compass x skeleton responsive grid

divs

<div class="container"><div class="one-third column">some text

</div><div class="two-thirds column">some two column text

</div></div>

Page 8: Magento x codekit x sass x compass x skeleton responsive grid

images

<img class="scale-with-grid" src="..." alt="..." title="..." />

Page 9: Magento x codekit x sass x compass x skeleton responsive grid

media queries

● always at the bottom● always in descending order

Page 10: Magento x codekit x sass x compass x skeleton responsive grid

extreme CSS & JSfast landing pages

Page 11: Magento x codekit x sass x compass x skeleton responsive grid

the case for separate CSS/JS files

● traditional thinking, vs● fast landing pages

problem: how to manage this? modpagespeed? magento? locally?

Page 12: Magento x codekit x sass x compass x skeleton responsive grid

combine CSS files & long expires

gotcha's● modpagespeed => 4095. what a cunt.● magento breaks base64

solution● combine css

○ combine locally with CodeKit & BLESS, or○ if you're not scared of 4095, use magento and

base64.phtml hack● Aoe JsCssTstamp for long expires

Page 13: Magento x codekit x sass x compass x skeleton responsive grid

bypass magento base64 bug with base64.phtml

● layout.xml<reference name="head">

<block type="page/html"name="bg_css"template="page/base64.phtml"/>

</reference>====● base64.phtml<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl(); ?>css/base64.css" media="all">

(better to just combine locally with codekit)

Page 14: Magento x codekit x sass x compass x skeleton responsive grid

codekit x magento

Page 15: Magento x codekit x sass x compass x skeleton responsive grid

ever wondered why your scripts get so damn big?

● old unused CSS and JS generally never get deleted, and is hard to manage without separating them into files

● use codekit

● e.g. @import "testing-this-layout.css";

Page 16: Magento x codekit x sass x compass x skeleton responsive grid

codekit, compass & scss

● compass gives you access to a bunch of frameworks

● @import○ combine css locally○ anywhere you have reuseable stuff, but want to keep

files organised (e.g. skeleton, fonts, typography, buttons, )

● @include○ where you have @import'd a scss/sass file where

you have declared a @mixin○ you use @include to call that @mixin

Page 17: Magento x codekit x sass x compass x skeleton responsive grid

compass examplescss

compiles to

Page 18: Magento x codekit x sass x compass x skeleton responsive grid

setting up codekit for magento

● create theme "yourtheme-ck"● mirror magento path names, e.g. "css" and

"js" etc...● ...so assets become:

○ JS - skin/frontend/default/yourtheme/js○ CSS - skin/frontend/default/yourtheme/css○ IMAGES - skin/frontend/default/yourtheme/images○ SASS - skin/frontend/default/yourtheme/css

● magento structure remains the same○ these compile to "yourtheme/css", "yourtheme/js"

etc...○ choose "default" as codekit compass project

Page 19: Magento x codekit x sass x compass x skeleton responsive grid

codekit settings for magento

Page 20: Magento x codekit x sass x compass x skeleton responsive grid

examples

● landing.css○ @import buttons.scss○ @import typography.scss○ @import forms.scss○ @import header.scss○ @import footer.scss

● styles.css○ @import checkout.scss○ @import cart.scss○ @import widget1.scss○ @import module1.scss○ @import test-module.scss

● change your xml files to reflect landing.css and styles.css

Page 21: Magento x codekit x sass x compass x skeleton responsive grid

resources

@ldn_tech_exec

● github.com/arush● adding SASS to Sublime Text 2

○ http://www.adampatterson.ca/blog/2011/05/adding-sass-scss-support-sublime-edit-2/

● http://incident57.com/codekit/● http://www.getskeleton.com/● 4095 - http://blesscss.com/● http://compass-style.org/