67
LEARNING FROM CSS BEST PRACTICES FAILING

(learning from) CSS Best Practices (failing)

Embed Size (px)

DESCRIPTION

Wie kann man in rapider, interdisziplinärer Arbeitsweise Web-Projekte mit wartbarem, modularem CSS bauen? Was können wir dafür aus bekannten Ansätzen und Best-Practices lernen und besser machen? Ein Versuch, einen "goldenen Mittelweg" zu finden.

Citation preview

Page 1: (learning from) CSS Best Practices (failing)

LEARNING FROM

CSS BEST PRACTICESFAILING

Page 2: (learning from) CSS Best Practices (failing)

DAMALS

Page 3: (learning from) CSS Best Practices (failing)

'95: WARUM CSS?<font face="Comic Sans MS" color="pink"> I can haz spaghetti on my <table>?

Page 4: (learning from) CSS Best Practices (failing)

'99: WEIL'S BESSER GEHT<p class="spaghetti">U can</p>

Table-Layout bliebSchriften/Farben wanderten ins CSSCSS = Skin/Theme

///

Page 5: (learning from) CSS Best Practices (failing)

'01: CSS KANN MEHRAuch f�r LayoutSemantisches MarkupSeparation of concernsLayout und Skin getrennt vom MarkupTags, Klassen und IDs als Hooks

/////

Page 6: (learning from) CSS Best Practices (failing)

BEST PRACTICE 2001CSS Zen Garden, anyone?Tables raus, wir floatenSemantisches, schlankes MarkupIDs kapseln Bereiche im LayoutTags/Klassen f�r wiederkehrende Inhalte

/////

Page 7: (learning from) CSS Best Practices (failing)

FUNKTIONIERT DOCHHEUTE NOCH!... BIS ES GRÖSSER WIRD

Page 8: (learning from) CSS Best Practices (failing)

2005BIG SITES

Page 9: (learning from) CSS Best Practices (failing)

HERAUSFORDERUNGENViele Seitentypen... mit unterschiedlichem InhaltPixelgenau soll es seinWartbar soll es bleiben

////

Page 10: (learning from) CSS Best Practices (failing)

LÖSUNG CA. 2004DEEP NESTING

So spezifisch wie m�glich, so allgemein wie n�tigKlare Struktur im CSSNeue Bereiche r�hren alte nicht anAlte Bereiche k�nnen leicht entfernt werdenMarkup bleibt sauber

/////

Page 11: (learning from) CSS Best Practices (failing)

DEEP NESTINGImplizite enge Kopplung von Markup und StylingNeue Module/Seiten brauchen neues StylingStetig wachsender CSS-CodeInkonsistentes StylingSpecifity Wars

/////

Page 12: (learning from) CSS Best Practices (failing)

2010ALLES DYNAMISCH

Page 13: (learning from) CSS Best Practices (failing)

ALLES DYNAMISCHWEBAPPS KOMMEN

CSS kommt an seine GrenzenWasserfall auch

//

Page 14: (learning from) CSS Best Practices (failing)

PREPROCESSORSSASS, LESS, STYLUS, ...

Variablen und Mixins l�sen KonsistenzproblemeDeep-Nesting einfacher durch DRY-Schreibweise

//

Page 15: (learning from) CSS Best Practices (failing)

PREPROCESSORSPROBLEME

F�rdert stumpfes Nachbauen von DesignsCSS-Code wächst weiterAbstraktionsschicht→ Komplexität, Unachtsamkeit

////

Page 16: (learning from) CSS Best Practices (failing)

OOCSSKOMBINIEREN VON KLASSEN

Wiederverwendbare, variable Module & AspekteKontext-unabhängigNo Specifity WarNeue Seiten ohne neues CSSCSS bleibt kleinDesign bleibt konsistentF�rdert Rapid Development

///////

Page 17: (learning from) CSS Best Practices (failing)

OOCSSPROBLEME

Specifity War → Class HellSemantik leidet (Namensfindung!)CSS-Änderungen → Auswirkungen?CSS l�schen wird haarigMacht Feintuning hartResponsive Design evtl. schwierig

//////

Page 18: (learning from) CSS Best Practices (failing)

BEMOOCSS+ MIT NAMENSSCHEMA.block (Layout/Komponente).block__elemente (Content/Einzelteile).block--modifier (Variationen/Skin)

///

Page 19: (learning from) CSS Best Practices (failing)

BEMPROBLEME

kann zu unn�tigem Markup f�hrenFeintuning bleibt schwierig

//.form--compact__row__button--primary--wtf

Page 20: (learning from) CSS Best Practices (failing)

LESSONS LEARNEDPICK THE CHERRIES!

Page 21: (learning from) CSS Best Practices (failing)

VERMEIDEN!Specifity WarsClass HellKontextabhängigkeitMarkup BloatImplizite starke Kopplung

/////

Page 22: (learning from) CSS Best Practices (failing)

WAS WIR WOLLENSchlankes, semantisches MarkupKompaktes CSSKonsistentes Design ohne LangeweileWiederverwendbare ModuleKlarheit im Code

/////

Wie wollen wir arbeiten?

Page 23: (learning from) CSS Best Practices (failing)

WASSERFALLDesign final, dann CodeKlare Deadlines, Feature-CommitmentsKeine verschwendete ArbeitszeitWenig Abstimmungsaufwand

////

Ich hab meine Ruhe

Page 24: (learning from) CSS Best Practices (failing)

YEAH!!WEIHNACHTSMANN?

Page 25: (learning from) CSS Best Practices (failing)
Page 26: (learning from) CSS Best Practices (failing)

RAPIDHäufige, enge Abstimmung zw. Design & CodeCode so fr�h wie m�glichPhotoshop so viel wie n�tigBessere Ideen, in echt verprobtSchnelle Entscheidungen & ErgebnisseMinimierte Missverständnisse

//////

Page 27: (learning from) CSS Best Practices (failing)

INTERGALACTODISCIPLINARY!!!

UNDE SCH... CODE

Page 28: (learning from) CSS Best Practices (failing)
Page 29: (learning from) CSS Best Practices (failing)

DESIGNER WILL SPIELEN?Problem von �berall beleuchtenAnsätze wie Legosteine zusammensetzen... nach und nach ergibt sich ein BildVerfeinern, ausarbeiten

////

Page 30: (learning from) CSS Best Practices (failing)

DESIGN... funktioniert iterativvom Groben zum Feinen... dann vom Kleinen zum Gro�en

///

Page 31: (learning from) CSS Best Practices (failing)

CODER WOLLEN KLARHEIT?Problem von �berall beleuchtenAnsätze wie Legosteine zusammensetzen... nach und nach ergibt sich ein BildVerfeinern, ausarbeiten

////

Page 32: (learning from) CSS Best Practices (failing)

CODEN... funktioniert iterativvom Groben zum Feinen... dann vom Kleinen zum Gro�en

///

Page 33: (learning from) CSS Best Practices (failing)

iterativ

Page 34: (learning from) CSS Best Practices (failing)

GROB

Page 35: (learning from) CSS Best Practices (failing)

fein

Page 36: (learning from) CSS Best Practices (failing)

klein

Page 37: (learning from) CSS Best Practices (failing)

GROSS

Page 38: (learning from) CSS Best Practices (failing)

iterativ

Page 39: (learning from) CSS Best Practices (failing)

GROB

Page 40: (learning from) CSS Best Practices (failing)

fein

Page 41: (learning from) CSS Best Practices (failing)

klein

Page 42: (learning from) CSS Best Practices (failing)

GROSS

Page 43: (learning from) CSS Best Practices (failing)

ATOMIC DESIGN

Page 44: (learning from) CSS Best Practices (failing)

ATOMIC DESIGNDESIGN-METHODE

Starte beim Allgemeinen, werde dann speziellerStarte beim Kleinen, gehe dann zum Gro�enAlles ist aus kleineren Teilen aufgebaut

///

Page 45: (learning from) CSS Best Practices (failing)

CHERRY PICKING!1. Style von allgemein nach speziell (AD)2. Module flexibel und wiederverwendbar (OOCSS, BEM)3. Nutze Präprozessoren intelligent4. Arbeite in interdisziplinären Teams

Page 46: (learning from) CSS Best Practices (failing)

#1 BASICSALLGEMEIN → SPEZIELL

Page 47: (learning from) CSS Best Practices (failing)

HELFER VORBEREITENvars.less: Standardfarben, Gr��en, Schriften, Timings etc.Agnostische mixins.less, verwendet varsVenor Prefixes, Hacks, Grids, Meta-Module wie OOCSS Media-Block, Clearfix, Image Replacement

//

Page 48: (learning from) CSS Best Practices (failing)

NORMALISIERE MIT STILResets sind outnormalize.css tut mehr als n�tigContent = BasisHeadlines, Standard-Links, Listen, Tabellen etc. f�r Standard-Flie�text

→ Atome in der basic.less

///

/

Page 49: (learning from) CSS Best Practices (failing)

UNIVERSELLE MINI-OBJEKTEKlassen, wenn es keine Tags gibt (.weak)... oder visuelle Semantik und Element-Natur auseinanderlaufen k�nnenButtons: universell f�r a, button, input.btn, .btn-forth, .btn-primary

Headline-Klassen .h1̀ .h6In Ruhe lassen: form, fieldset, label

//

/

//

Page 50: (learning from) CSS Best Practices (failing)

½ STYLEGUIDEGRID, FARBEN, TYPOGRAFIE TUNEN

Page 51: (learning from) CSS Best Practices (failing)

#2 MODULEFLEXIBEL & WIEDERVERWENDBAR

Page 52: (learning from) CSS Best Practices (failing)

MODULContainer zum Strukturieren von ContentTeaser, Sidebar-Box, Slider, Tabs, Kommentare, ProdukteK�nnen ineinander geschachtelt sein

///

Page 53: (learning from) CSS Best Practices (failing)

FLEXIBELBreite von au�en vorgegebenContent bestimmt die H�heMeide feste H�hen & BreitenMeide absolute Positionierung

////

Page 54: (learning from) CSS Best Practices (failing)

WIEDERVERWENDBARMinimaler Kontext f�r ModuleGerade so viel, dass es ganz bleibtHeader/Footer, Seitentypen, Media Queries dazu→ Rahmen f�r Module

////

Page 55: (learning from) CSS Best Practices (failing)

PROJEKT-BOOTSTRAP80% AM ZIEL, 20% CODE!

Page 56: (learning from) CSS Best Practices (failing)

#3 TUNINGMIT PRÄPROZESSOR-POWER

Page 57: (learning from) CSS Best Practices (failing)

TUNINGNie generische Klassen f�r Kontext verwendenKlassenanzahl pro Element gering haltenBl�cke f�r Sonderfälle identifizieren

///

Page 58: (learning from) CSS Best Practices (failing)

PRÄPROZESSORENTUNING ÜBER MIXINS & EXTENDS

Neues Modul: Partial + Less-DateiScope �ber neuen Modul-KlassennamenMixin/Extend der alten KlassennamenTuning-Regeln dazu

////

Page 59: (learning from) CSS Best Practices (failing)

WARUM?Universelle Regeln bleiben �bersichtlichMarkup wird saubererSonderlocken leicht zu l�schenNicht zu viel Kontext und Spezifität

////

Page 60: (learning from) CSS Best Practices (failing)

BEST OF BOTH WORLDSMODULAR UND FEINGETUNED

Page 61: (learning from) CSS Best Practices (failing)

#4 TEAMWORKINTERDISZIPLINÄRE ARBEITSWEISE

Page 62: (learning from) CSS Best Practices (failing)

VOM GROBEN ...Design: Moods, Farbwelt, Typo, GridCode: vars.less = wachsender Styleguide

//

Page 63: (learning from) CSS Best Practices (failing)

... UND KLEINENDesign/Code: Grundelemente tunenCode/Design: Module identifizieren/bauen

//

Page 64: (learning from) CSS Best Practices (failing)

ZUM GROSSEN ...Code: Prototyp aus Modulen bootstrappenDesign/Code: Zusammen feintunen

//

Page 65: (learning from) CSS Best Practices (failing)

... UND FEINENDesign/Code: Sonderfälle identifizierenCode: BauenDesign/Code: Zusammen feintunen

///

Page 66: (learning from) CSS Best Practices (failing)

INTERGALACTODISCIPLINARY!!!

UND SCHÖNER CODE!UND GEILE UX!!

Page 67: (learning from) CSS Best Practices (failing)

the end