less js-&-wp

20
LESS, JS & WP for #WPN12

Upload: rfair404

Post on 13-Jan-2015

948 views

Category:

Technology


0 download

DESCRIPTION

Examples of using LESS in WordPress, prepared for WordCamp Nashville 2012 #wcn12

TRANSCRIPT

Page 1: Less js-&-wp

LESS, JS & WPfor #WPN12

Page 2: Less js-&-wp

RUSSELL FAIRdeveloper / open source code junkie [email protected]

Page 3: Less js-&-wp

use-LESS links

http://lesscss.org/

https://github.com/rfair404/LESS-theme-demo

http://lesselements.com/https://github.com/juanghurtado/less-elements.tmbundlehttp://incident57.com/codekit/http://incident57.com/less/WINDOWS: http://wearekiss.com/simplesshttp://lessframework.com/http://coding.smashingmagazine.com/2011/09/09/an-introduction-to-less-and-comparison-to-sass/

Page 4: Less js-&-wp

1 LESS joke

LESS != 'more';

LESS $beer != 'happy coder';LESS $money != 'happy coder';

LESS $time_writing_css == 'happy coder';

Page 5: Less js-&-wp

what's LESS

Serverside ClientsidePreCompiled

Valid CSS3

Page 6: Less js-&-wp

add LESS (bad code) to wp

<link rel="stylesheet/less" type="text/css" href="<?php echo THEME_URL; ?>/less/example.less">

<script src="<?php echo THEME_URL; ?>/js/less-1.2.0.min.js" type="text/javascript"></script>

Page 7: Less js-&-wp

doing LESS work is good

saves timeeasier to navigate

#!watch

drawbacks? slow,

Page 8: Less js-&-wp

more variables = LESS code

@color1: #e4e9c2;@padding1: 1%;

body { background: @color1; }

.hfeed {background:@color1;padding:@padding1;

}

Page 9: Less js-&-wp

nested rules = LESS confusing

body.blog { .hfeed { background: @color3; }

}

body.archive {.hfeed { background: @color2; }

}

Page 10: Less js-&-wp

LESS mixins

.minimal-padding { padding:@padding1; }

body.blog {.minimal-padding;

}

Page 11: Less js-&-wp

fancy mixins (parametric)

.box-shadow(@bscolor, @bsoffsety, @bsoffsetx, @bsblur) {

box-shadow: @bscolor @bsoffsety @bsoffsetx @bsblur;}

body .hfeed {.box-shadow(pink, -5px, -5px, 30px);

}

Page 12: Less js-&-wp

custom LESS functions

.recolor( @color4:purple ) {body.blog {

.hfeed {background:@color4;

}}

}

.recolor();

Page 13: Less js-&-wp

native LESS functions

body.blog {background: saturate(@color2, 90%);

}

.hfeed a {color: spin(@color2, 20);

}

Page 14: Less js-&-wp

more native LESS functions

.hentry:nth-child(3n+1) {background: lighten( @color2 , 20% );

}.hentry:nth-child(3n+2) {

background: darken( @color2 , 5% );}.hentry:nth-child(3n+3) {

background: saturate( spin( @color3, -50 ), 30% );}

Page 15: Less js-&-wp

LESS math

.multiplication { margin: @padding1 * 2; }

.division { margin: @padding2 / 2; }

.addition(@width1, @width2) {width: @width1 + @width2;

}.subtraction(@width1, @width2) {

width: @width1 - @width2;}

Page 16: Less js-&-wp

JS Funtime

Lettering.jsFitText.jsFitVids.js

Page 17: Less js-&-wp

lettering.JS

Adds <span>things</span>

Works on lines, words and letters

All JS so no SEO impact

Use no-JS fallback

http://letteringjs.com/

Page 18: Less js-&-wp

fittext.JS

Adjust font sizes to fit words into boxes on responsive views

All JS so no SEO impact

Use no-JS fallback

http://fittextjs.com/

Page 19: Less js-&-wp

fitvids.JS

Adjusts video widths dynamically (responsive)

Works with some* of the built in oEmbed providers

http://fitvidsjs.com/

Page 20: Less js-&-wp

Questions?