Share
Embed
Transcript
66 slides
-
Interactive Cologne 2014 Interactive Cologne 2014 Jakob Hilden Master in
Human-Computer Interaction Frontend- & Rails-Entwickler bei Railslove Organisator des Railscamps @jkwebs -
Interactive Cologne 2014 Stephan Pavlovic M.Sc in Medieninformatics Frontend-Developent and
Concepts at Railslove Lecturer at University of Applied Science Cologne -
Interactive Cologne 2014 Railslove Agile Ruby-on-Rails-Development from Cologne Guiding and
„Bootstrapping“ of startups Work with established companies -
Who are you? Where do you work? What do you
do there? Why are you here? -
Interactive Cologne 2014 Interactive Cologne 2014 General approach We show
you current best practices from our daily experience There will be no (ok a little) book knowledge The will be some hands-on parts for you to get active If something is unclear, ask! -
Interactive Cologne 2014 Interactive Cologne 2014 Schedule Problem definition CSS
specificity Separation of concerns DRY up your styles using Sass Modular CSS Living Styleguide -
Interactive Cologne 2014 Feedback We do this workshop for the
first time We don’t know what you expect We want to learn and improve: Too fast? Too slow? Too easy? -> Tell us! Feedback session at the end Interactive Cologne 2014 -
Interactive Cologne 2014 CSS is easy, right? .li{ float: left;
margin: 10px 20px; padding: 10px; } -
Interactive Cologne 2014 After a year or so ... .block{
display: block !important; } .inline{ display: inline !important; } .hide{ display: none !important; } .p{ padding: 10px !important; } .img{ border: 1px solid black !important; } .center{ margin: 0 auto !important; } -
Interactive Cologne 2014 Css is a mess Inconsistent design /
UX Tight coupling Unclear scope / applicability Refactoring?!? -
Interactive Cologne 2014 Css is a mess Inconsistent design /
UX Tight coupling Unclear scope / applicability Refactoring?!? ! => We will try to help you fix these problems today -
Interactive Cologne 2014 Css specificity Interactive Cologne 2014 Element Class
ID Inline a div p .article [attr=val] #article style=„…“ -
Interactive Cologne 2014 Css specificity Interactive Cologne 2014 Class ID
.article [attr=val] #article -
Interactive Cologne 2014 Separation of concerns Single responsibility principle We
learned: #IDs should not be used for styling Instead, we take .classes for styling IDs are for Javascript behavior, that targets one element (faster) [data-attributes] are for Javascript, that targets multiple elements -
Interactive Cologne 2014 Separation of concerns JS-Code doesn’t use any
CSS classes IDs: $(“#top-box“) Data-attributes: $(“[data-behavior=datepicker]“) ! Only exception: changeable state classes But we will see that later ... -
Interactive Cologne 2014 The dark ages One big CSS file
Everything new goes to the bottom of the file You write a comment above the new stuff -
Interactive Cologne 2014 Why Sass is „CSS with superpowers“ Who
uses a preprocessor? ———————————— Variables Mixins Nesting Extends Multiple Files -
Interactive Cologne 2014 Better structure Split code into multiple Files
and Folders Gives us the opportunity to structure code better -
Interactive Cologne 2014 Interactive Cologne 2014 Hands On Grab some
stuff out of that one big file -
Interactive Cologne 2014 Base All the setup stuff goes here
Variables Mixins Resets Element Defaults -
Interactive Cologne 2014 Why do we need modular CSS? Move
from page-centric to modular designs Reusability of elements Make refactoring possible Make real responsive design feasible -
Interactive Cologne 2014 What makes CSS modular? separation context-independence! clear
scope/applicability (CSS->markup) clear responsibility (markup->CSS) ! -
Interactive Cologne 2014 How can we achieve this? identification of
repeating/repeatable modules normalize modules/designs namespacing separation of: containers/grid <> design elements -
Interactive Cologne 2014 Basic separation Split CSS into different areas
of responsibility Single responsibility principle ! base/ modules/ shame/ -
Interactive Cologne 2014 A basic module Describes the basic look
of an element E.g. a button Color / Backgroundcolor Text Style Border-Radius .m-button -
Interactive Cologne 2014 Sub component Describes a part of a
module Can only be used within a module E.g. the icon in a button .m-button--icon -
Interactive Cologne 2014 States Describes a version of a module
that can change over time. Can only be used with a module E.g. A disabled button .m-button.is-disabled -
Interactive Cologne 2014 Modifier Describes also a variation of the
base module Modifies only a detail Can only be used with a module E.g. a smaller version of our button Starts with a preposition (as-, with-, without-, …) .m-button.as-small -
Interactive Cologne 2014 Sub modules Describes a variation of the
basic module E.g. A secondary button Takes everything from the base module Adds specific styles .m-button_secondary -
Interactive Cologne 2014 Not all modules are created equal Atomic
Modules Blocks Page / Controller -
Interactive Cologne 2014 Atomic modules Describes the look of a
page element Modules work context independent All team members should know the current selection of modules Heavily usage of variables and mixins -
Interactive Cologne 2014 Blocks Content blocks Composition of modules Reuses
modules and puts them into a bigger picture Good to know the most common blocks in the project -
Interactive Cologne 2014 Overview Prefix Responsibility Specificity level Sass Content
Dependency Living Styleguide base absolutely basic variables, mixins, elements atomic modules „a-“ look completely generic placeholder, selectors, mixins completely content independent definitely blocks „b-“ composition in between reuses atomic modules somewhat dependent maybe controller/ pages „c-“ positioning very specific very content/ page dependent no -
Interactive Cologne 2014 Refactoring You always refactor downwards If you
don’t know where to put something new, always start at the bottom (controller level) -
Interactive Cologne 2014 shame.css The name says it all Here
comes the dirty hacks !important ! => This file should be empty -
Interactive Cologne 2014 Modular CSS in a new project If
you get a multi page design document Identify modules on first page black out known parts in all the rest -
Interactive Cologne 2014 Modular CSS in an existing project Refactor
part after part Start with something easy e.g. buttons Strip out all button related CSS and move it into the button module Start refactoring the button code Take the next module -
Interactive Cologne 2014 Living Styleguide We all know Styleguides PDFs
some Designer put together a long time ago Nobody uses them because nobody takes care of them ! => Living styleguide use current codebase Great debugging tool -
Fragen? Mail: jakob@railslove Twitter: @jkwebs Github: jhilden Mail: stephan@railslove Twitter:
@stephanpavlovic Github: stephanpavlovic