Slide 1

Slide 1 text

Getting Sassy with WordPress 4.7 and Jetpack Job Thomas WooCommerce Education Lead @jobtex | job.blog

Slide 2

Slide 2 text

Languages Which languages are used 
 in WordPress on the development side?

Slide 3

Slide 3 text

Chrome Dev Tools: Inspect • Go to your site • right-click > inspect • Look at elements tab

Slide 4

Slide 4 text

HTML CSS

Slide 5

Slide 5 text

Syntax: Overview h1 {
 color: blue;
 font-size: 12px;
 } selector {
 property: value; = declaration
 property: value; = declaration
 }

Slide 6

Slide 6 text

Syntax: Selectors 


Header


Paragraph describing some important thing.


On a last note.



 • element: body, h2, p • class: .first • id: #last

Slide 7

Slide 7 text

Resources • w3schools.com/css/ • DesktopServer • unsplash.com

Slide 8

Slide 8 text

Exercise • cms.mystagingwebsite.com • Change the colour of 
 “Home” • Change the colour and font size of 
 “Welcome to the …”

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Problems with CSS • Selectors: - Too specific - Not specific enough • Repetitive

Slide 11

Slide 11 text

Insert: Sass • sass-lang.com • Some advantages: - Variables - Nesting - Mixins

Slide 12

Slide 12 text

Variables h2 {
 color: blue;
 }
 
 .entry-content p {
 color: blue;
 } $main: blue;
 
 h2 {
 color: $main;
 }
 
 .entry-content p {
 color: $main;
 }

Slide 13

Slide 13 text

Variable: Format $namevariable: value;

Slide 14

Slide 14 text

Some variable to use • Fonts
 $font-main: ‘Raleway’, sans-serif;
 (of course, you first need to @import that font) • Colours
 $grey: #eee; • Sizes
 $wide: 1024px;


Slide 15

Slide 15 text

Nesting .entry-content {
 background: red;
 }
 
 .entry-content h2 {
 padding: 2em;
 }
 
 .entry-content p {
 color: $main;
 } .entry-content {
 background: red;
 h2 {
 padding: 2em;
 }
 p {
 color: $main;
 }
 }

Slide 16

Slide 16 text

Nesting: Format selector_level_1 {
 declaration; 
 // only applies to L1
 selector_level_2 {
 declaration; 
 // only applies to L2 within L1
 }
 }

Slide 17

Slide 17 text

Mixins img {
 -webkit-border-radius: 10px;
 -moz-border-radius: 10px;
 -ms-border-radius: 10px;
 border-radius: 10px;
 }
 
 .box {
 -webkit-border-radius: 5%;
 -moz-border-radius: 5%;
 -ms-border-radius: 5%;
 border-radius: 5%;
 } @mixin border-radius($radius) {
 -webkit-border-radius: $radius;
 -moz-border-radius: $radius;
 -ms-border-radius: $radius;
 border-radius: $radius;
 }
 
 img {
 @include border-radius(10px);
 }
 
 .box {
 @include border-radius(5%);
 }

Slide 18

Slide 18 text

Mixins: Format @mixin namefunction($namevariable) {
 // ($namevariable) is optional
 declaration;
 }
 
 .selector {
 @include namefunction(arguments);
 // arguments are “values”
 // for $namevariable “properties”
 }

Slide 19

Slide 19 text

Some mixins to use Media queries @mixin wide {
 @media (min-width: 1024px) {
 @content;
 }
 }
 
 .entry-content {
 p {
 margin-left: 10px;
 @include wide {
 margin-left: 20px;
 }
 }
 } Transitions @mixin transition($args...) {
 -webkit-transition: $args;
 -moz-transition: $args;
 -ms-transition: $args;
 -o-transition: $args;
 transition: $args
 }
 
 .button {
 background: white;
 @include transition(background 1s);
 &:hover {
 background: black;
 }
 }

Slide 20

Slide 20 text

Some mixins to use Variable clusters @mixin large-text {
 font: {
 family: Arial;
 size: 20px;
 weight: bold;
 }
 color: $main;
 }
 
 p {
 @include large-text;
 } But also for: • Box shadows • Content blocks • …

Slide 21

Slide 21 text

Functions p {
 color: rgba(black, 0.8);
 } $main: black;
 
 p {
 color: lighten($main, 80%);
 }

Slide 22

Slide 22 text

Sources • developerdrive.com/2014/11/15-essential- sass-mixins/ • engageinteractive.co.uk/blog/top-10-scss- mixins • hackingui.com/front-end/10-best-scss-utilities/

Slide 23

Slide 23 text

Sass processing: Jetpack • Install and activate Jetpack • Activate Custom CSS
 Jetpack > Settings > Appearance > Custom CSS • Open Appearance > Customise > Edit CSS • Under Preprocessor, select Sass (SCSS Syntax)

Slide 24

Slide 24 text

Exercise • Set colour variables • Set font variables On the shop page • Set rounded edges for all product images • Change the font of the product titles • Make the purchase buttons look different • Use transitions on the buttons 
 (e.g. let a:hover colour change take 1 sec)

Slide 25

Slide 25 text

Inspect the code cms.mystagingwebsite.com/shop

Slide 26

Slide 26 text

Review • Go over code together • Next exercises: - Try another Sass line - Explore Grunt.js or another compiler