Transcript
Page 1: Lessons learnt from the FontShop site relaunch

berlin amsterdam san francisco stuttgart

edenspiekermann_

Lessons from the FontShop site relaunch

UpFront talk

8th July 2014

Page 2: Lessons learnt from the FontShop site relaunch

edenspiekermann_

CSS ARCHITECTURE

Page 3: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

body {! font-size: 100%;! font-family: Georgia, serif;!}!!.o-chosen-select-box.chosen-container,.m-font-autocomplete{display:inline-block;position:relative;vertical-align:middle}.o-chosen-select-box .chosen-single,.m-font-autocomplete__input{background-color:#f9f8f3;color:#262626;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;border:4px solid #fff;display:block;cursor:pointer;height:2.5em;line-height:1.25em;padding:0 2.125em;-webkit-transition:background-color 150ms,border-color 150ms;-moz-transition:background-color 150ms,border-color 150ms;!.l-modal__tooltip__pane{z-index:30}.o-error{z-index:10}.o-pulldown-panel__list{z-index:10}.l-tryout-page__canvas{z-index:1}.l-tryout-page__header{z-index:30}.m-tryout-textblock__action{z-index:20}.m-tryout-textblock__editable{z-index:20}.m-tryout-textblock__placeholder{z-index:10}.m-font-autocomplete__dropdown,.o-chosen-select-box{z-index:40}.l-tryout-page__template-links,.l-tryout-page__bgimage-info{z-index:50}.l-tryout-page__meta-links{z-index:10000}.m-tryout-template-links—centered{z-index:10}!!#footer .left-column .article ul.links > li a img {! border-color: #0A0;!}!

CSS Architecture

Scientifically proven fact: a developer’s attention span gets diluted after 34.23 continuous lines of CSS code.*

3

* = Bullshit Researching Institute GmbH, 1999

Page 4: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture4

Page 5: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture5

Page 6: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

_config/!! extends/!! mixins/!! ! _colors.sass!! ! …!! var/!! ! _animations.sass!! ! …!! _z-index.sass!!globals/!! _typography.sass!! …!!objects/!! _o-button.sass!! …!!modules/!! _m-waterfalls.sass!! …!!layouts/!! _l-homepage.sass!! …!!vendor/!! _noone.reads.me.lol.sass!! …!!application.sass

CSS Architecture

Structure. – Vars, mixins under _config ensure consistency. – Globals folder contains non-modular global styles. – Objects folder has the smallest modular units. – Modules are combined Objects. Sometimes not exactly

modular but mapped to content entities. – Layouts contain only layout (duh) information such as

width, height, margin, padding.

6

Page 7: Lessons learnt from the FontShop site relaunch

edenspiekermann_

Douchebag scoreReferencing yourself in your presentation.

+1

Page 8: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture8

Page 9: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture9

.m-styles__families__slider__family__rail__node

Page 10: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture

Good things: – Self explanatory in both HTML & CSS. – Shields object’s scope. !

Bad things: – Can easily get carried away with underlines. – Verbal classes (but you get used to it). !

Things to remember: – Never nest selectors (to ensure specificity == 1). – Always & only, use classes.

10

Page 11: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture11

117CSS Objects in the project

Page 12: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture12

Page 13: Lessons learnt from the FontShop site relaunch

edenspiekermann_

The form - functionality paradox

https://www.flickr.com/photos/astrid/2583356797

Page 14: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture14

1

Page 15: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture15

2

Page 16: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture16

3

Page 17: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture17

Same Functionality ≠ Modularity –Elements that serve the same functionality don’t have

to be the same CSS objects. –Otherwise it’s a game of show, hide, absolute position

elements. –More info: http://www.edenspiekermann.com/blog/

oocss-and-the-pagification-of-modules

1 2

3

Douchebag scoreSorry, did it again!+1

Page 18: Lessons learnt from the FontShop site relaunch

edenspiekermann_

Living Styleguides

Page 19: Lessons learnt from the FontShop site relaunch

Hardboiled Front End Development 10.06.2014edenspiekermann_

CSS Architecture

Requirements-Challenges: –Auto-maintained. No duplicate views in production &

styleguide. –CSS Refactoring at the same time, to normalise objects. !

Advantages: –Nice overview of all your objects. –Enforces good practices. –Enhances developer — designer collaboration. –Helps you scale your project. !

Tool: –https://github.com/kneath/kss

19

Page 20: Lessons learnt from the FontShop site relaunch

Hardboiled Front End Development 10.06.2014edenspiekermann_

gem install kss

CSS Architecture

Setting up KSS. – Install gem.

20

Page 21: Lessons learnt from the FontShop site relaunch

Hardboiled Front End Development 10.06.2014edenspiekermann_

@styleguides = Kss::Parser.new(“/public/css“)!

CSS Architecture

Setting up KSS. – Install gem. – Parse CSS folder into an object.

21

Page 22: Lessons learnt from the FontShop site relaunch

Hardboiled Front End Development 10.06.2014edenspiekermann_

CSS Architecture

Setting up KSS. – Install gem. – Parse CSS folder into an object. – Iterate object in view.

22

- @styleguides.each do |styleguide|! - [...]!

Page 23: Lessons learnt from the FontShop site relaunch

Hardboiled Front End Development 10.06.2014edenspiekermann_

/*!The global button object.!!.button - Primary button.!.button--green - Green variation.!!Styleguide 1.0 Button!*/!!.button {! height: 20px;! text-align: center;! width: 100px;!}!!.button--green {! background-color: green;!}!

CSS Architecture

Setting up KSS. – Install gem. – Parse CSS folder into an object. – Iterate object in view. – Use the magic KSS syntax.

23

Page 24: Lessons learnt from the FontShop site relaunch

edenspiekermann_

http://next.fontshop.com/styleguide/objects

Page 25: Lessons learnt from the FontShop site relaunch

edenspiekermann_

Sass

Page 26: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture26

Page 27: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_ 27

Page 28: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_ 28

Page 29: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

.o-logo__block--left! +fs-color(secondary, background-color)!

CSS Architecture

Using Sass to create themes: – Too much labor to create theme variations for each

selector. – Created Sass function to do that automatically. !

Problems: – Specificity issues in overriding styles (trying to

convince myself that using “!important” is ok). – Slow compilation times.

29

body.theme--white .o-logo__block--left {! background-color: yellow;!}!body.theme--yellow .o-logo__block--left {! background-color: white;!}!body.theme--black .o-logo__block--left{! background-color: yellow;!}!

Page 30: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture30

Page 31: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture31

~12secCSS loading time during development

Page 32: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture32

~12secCSS loading time during development

On a frickin’ 2.8Ghz, 16GB Ram, SSD Machine.

Page 33: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

CSS Architecture

Tips: – Helpful to prefix classes (“o-“, “l-“, “m-“), that way you recognize their

type in markup. – Prefix JS hooks with “js-“. That way HTML/CSS restructuring doesn’t

affect javascript functionality. – Put all rushed code in shame.css. Always write reason of inclusion in

comments. – Keep all z-index values in z-index.css and always use increments of 10 or

more.

33

Page 34: Lessons learnt from the FontShop site relaunch

edenspiekermann_

JAVASCRIPT

Page 35: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules35

Page 36: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules36

AMD FTW!

Page 37: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules37

AMD FTW!Module Structure

Page 38: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules38

AMD FTW!Module Structure r.js wrapper -> .min.js

Page 39: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules39

AMD FTW!Module Structure r.js wrapper -> .min.js

Page 40: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules40

AMD FTW!Module Structure r.js wrapper -> .min.js

Page 41: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules41

AMD FTW!Module Structure r.js wrapper -> .min.js?

Page 42: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules42

AMD FTW!Module Structure r.js wrapper -> .min.js?

Page 43: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules43

AMD FTW!Module Structure r.js wrapper -> .min.js?

Page 44: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules44

AMD FTW!Module Structure r.js wrapper -> .min.jsHAHAHAHA!

Page 45: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules45

AMD FTW!Module Structure r.js wrapper -> .min.js

Page 46: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules46

Module Structure r.js wrapper -> .min.js

Page 47: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules47

Module Structure

Page 48: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript Modules48

//= require xxx.js //= require_tree /js/JS Modules

Tryout

Site

Buy

Page 49: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

//= require jquery!!(function (win) {!! var GlobalLikes = {};!! GlobalLikes = Backbone.View.extend({!! initialize: function () {! this.options = _.extend({}, ! this.defaults, this.$el.data());! this.getLikes();! },!! ! ! …! …! …!!! ! ! });!! win.fs.Modules.GlobalLikes = GlobalLikes;!!})(window);!!

Javascript

Working well with Sprockets. Eventually. – Declare dependencies with “//=require xxx”. – Scope everything to window.fs (and pray we don’t ever

need Node’s FS module). – Expose modules to global window.fs.Modules object. – Using bower-rails gem for dependencies.

49

Page 50: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_

Javascript50

JS Mike = Finally Happy

Page 51: Lessons learnt from the FontShop site relaunch

Lessons from the FontShop site relaunch 08.07.2014edenspiekermann_ 51

FontShop is always looking for new dev talent!

Contact Ivo Gabrowitsch: [email protected]. Mention this awesome presentation.

Page 52: Lessons learnt from the FontShop site relaunch

berlin amsterdam san francisco stuttgart

edenspiekermann_

Thank you.

Spiros Martzoukos, Web Developer

tw @martzoukos

T +49 157 84340808

!

[email protected]

www.edenspiekermann.com