CSS Skills Garden

A presentation at SydCSS in December 2014 in Sydney NSW, Australia by Ben Buchanan (200ok)

Slide 1

Slide 1

CSS Skills Garden SydCSS, 2014.12.04 Ben Buchanan / @200okpublic

Slide 2

Slide 2

WARNING This presentation simplistically conflates a range of programming concepts. This is a known issue.

Slide 3

Slide 3

A tale of the web, evolution and freaking out.

Slide 4

Slide 4

Slide 5

Slide 5

Slide 6

Slide 6

Slide 7

Slide 7

A little look back

Slide 8

Slide 8

<body background=”#000000” text=”#D5D5D5” link=”#FFFFFF” vlink=”#C0C0C0”> <font size=”3” face=”OCR A Extended”>

Slide 9

Slide 9

A:link {text-decoration: none; color:#0000FF;} A:visited {text-decoration: none; color:#0055AA;} A:active {text-decoration: none; color:#ff9900;} A:hover {text-decoration: none; color:#990000;} TD {font-family:helvetica,arial,sans serif;} body {background-color: #FFFFFF}

Slide 10

Slide 10

Slide 11

Slide 11

Slide 12

Slide 12

Slide 13

Slide 13

// flipper V2.0 // must have associated init() call in <HEAD> of page to assign loaded=true and var selected; function flipper(name,image) { if (loaded!=”true”) return; name=name+”;selected=selected+”; // required for NS3 if (name==selected) return; if (document.images) { document[name].src=eval(image+”.src”); } } function click(name) { if (loaded!=”true”) return; oldselected=selected; selected=name; if (document.images) { if (oldselected==”option1”) flipper(‘option1’,’image1b’); if (oldselected==”option2”) flipper(‘option2’,’image2b’); if (oldselected==”option3”) flipper(‘option3’,’image3b’); if (oldselected==”option4”) flipper(‘option4’,’image4b’); if (oldselected==”option5”) flipper(‘option5’,’image5b’); if (oldselected==”option6”) flipper(‘option6’,’image6b’); if (oldselected==”option7”) flipper(‘option7’,’image7b’); if (oldselected==”option8”) flipper(‘option8’,’image8b’); if (oldselected==”option9”) flipper(‘option9’,’image9b’); if (oldselected==”option10”) flipper(‘option10’,’image10b’); if (oldselected==”option11”) flipper(‘option11’,’image11b’); if (oldselected==”option12”) flipper(‘option12’,’image12b’); if (oldselected==”option13”) flipper(‘option13’,’image13b’); if (oldselected==”option14”) flipper(‘option14’,’image14b’); } }

Slide 14

Slide 14

<a href=”option1.html” target=”picture” onMouseOver=”flipper(‘option1’,’image1a’);return true;” onMouseOut=”flipper(‘option1’,’image1b’);return true;” onClick=”click(‘option1’);”><img src=”img/option1b.gif” border=0 name=”option1” alt=”news at Griffith Uni” vspace=3></a><br>

Slide 15

Slide 15

Evolution

Slide 16

Slide 16

Slide 17

Slide 17

JavaScript improved ● jQuery took out the drudgery ● ARIA enabled accessibility ● New browsers made it faster ● Debugging tools made it easier

Slide 18

Slide 18

Slide 19

Slide 19

Slide 20

Slide 20

Slide 21

Slide 21

Slide 22

Slide 22

Slide 23

Slide 23

Then and now ● HTML ● ● CSS ● ● Javascript (maybe) ● FTP ● SVN (maybe) ● ● Templating Preprocessors, media queries, typefaces, vectors jQuery, plugins, libraries, frameworks, transcompilers, client-side MVC Dependency managers, build & deploy pipelines ● Cloud hosting ● DVCS ● Tests and builds ● Powerful debugging and performance testing tools

Slide 24

Slide 24

These days frontenders are “engineers”.

Slide 25

Slide 25

If you know templating and CSS preprocessors, you know fundamental programming concepts.

Slide 26

Slide 26

Slide 27

Slide 27

SCSS vs JS: basics

Slide 28

Slide 28

Variables // SCSS // JS $foo: “bar”; var foo = ‘bar’;

Slide 29

Slide 29

Types // SCSS // JavaScript Numbers Numbers Strings Strings Colors Booleans Booleans Nulls Null Lists 1,2,3 Arrays [1,2,3] Maps 1:foo, 2:bar Objects { 1:’foo’, 2:’bar’ } Undefined Function object

Slide 30

Slide 30

Functions // SCSS // JavaScript @mixin myMixin($bar) { function myFunction(bar){ property: $bar; return bar; } } @include myMixin(foo); myFunction(“foo”);

Slide 31

Slide 31

String and maths methods // SCSS strings // JS strings to-upper-case(str) str.toUpperCase() str-length(str) str.length // SCSS numbers // JS numbers round(1.1) Math.round(1.1) ceil(1.1) Math.ceil(1.1) floor(1.1) Math.floor(1.1) max(1,2,3) Math.max(1,2,3) random() Math.random()

Slide 32

Slide 32

SCSS vs JS: a little harder

Slide 33

Slide 33

Scope // SCSS $width: 10em; #main { $width: 5em; width: $width; } #sidebar { width: $width; // what is $width? }

Slide 34

Slide 34

Scope // SCSS // CSS output $width: 10em; #main { #main { $width: 5em; width: 5em; } width: $width; } #sidebar { #sidebar { width: $width; } width: 10em; }

Slide 35

Slide 35

Scope // SCSS $width: 10em; #main { $width: 5em !global; width: $width; } #sidebar { width: $width; // now what? }

Slide 36

Slide 36

Scope // SCSS // CSS output $width: 10em; #main { width: 5em; #main { $width: 5em !global; } #sidebar { width: $width; } } #sidebar { width: $width; // now what? } width: 5em;

Slide 37

Slide 37

Javascript scope ● A little more complex than SCSS ● Look up “hoisting” and “closures” ● …on MDN, not W3Schools

Slide 38

Slide 38

Tip: learn scope, closures and hoisting and you will get 87% of JavaScript meetup puzzle code. - source: australian bureau of made-up statistics

Slide 39

Slide 39

It’s not just Javascript

Slide 40

Slide 40

More vars $foo: ‘bar’; // SCSS @link-color: ‘bar’; // LESS var foo = ‘bar’; // JS foo = ‘bar’

Ruby

foo = ‘spam’

Python

foo=’bar’

Shell

String foo = “bar”; // Java

Slide 41

Slide 41

More functions // SCSS

Python

// Shell @mixin baz($bar) { def ham(eggs): function baz { property: $bar; print eggs } @include baz(foo); echo “$1” } ham(‘spam’) baz “foo”

Slide 42

Slide 42

Dependency injection // SCSS @import ‘reset’;

python import spam

// Arduino (C, really) #include <foo.h> // Java import com.domain.foobar.f.o.o.b.a.r.foo.bar.FooBar;

Slide 43

Slide 43

It’s not just languages

Slide 44

Slide 44

Dependency management // SCSS (ruby gems) $ bundle install // NodeJS (npm) $ npm install // Java (maven) $ mvn install

Slide 45

Slide 45

It can be hard to start.

Slide 46

Slide 46

There’s so much It’s too different Common worries Scared to admit I don’t know I’ll never catch the ninjas

Slide 47

Slide 47

Be inspired to start. HA!

Slide 48

Slide 48

Slide 49

Slide 49

Slide 50

Slide 50

Slide 51

Slide 51

Play your own game. Build on what you’ve done.

Slide 52

Slide 52

Step outside the stylesheet. Your skills will serve you well.