variations on a theme

54
Variations on a Theme Brad Czerniak [might raise his voice]

Upload: commercial-progression

Post on 19-Jul-2015

486 views

Category:

Design


2 download

TRANSCRIPT

Page 1: Variations on a Theme

Variations on a Theme

Brad Czerniak [might raise his voice]

Page 2: Variations on a Theme

§1. Templates (and helpers)

Page 4: Variations on a Theme

❝Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.❞

Page 6: Variations on a Theme

This feels good:

Page 7: Variations on a Theme

page.tpl.php

<?php if ($page['header']) print render($page['header']) ?>

<?php if ($page['nav']) print render($page['nav']) ?>

<?php if ($page['content_top']) print render($page['content_top']) ?>

<?php if ($page['content']) print render($page['content']) ?>

<?php if ($page['content_bottom']) print render($page['content_bottom']) ?>

<?php if ($page['footer']) print render($page['footer']) ?>

Page 8: Variations on a Theme

How do we get there?

Page 9: Variations on a Theme

Blockify [module]https://www.drupal.org/project/blockify

Page 11: Variations on a Theme

Mantra #1: Everything’s a block

Page 12: Variations on a Theme

Allows for:.region-header > .block {

float: left;

margin: 0 1em 1em 0;

}

Page 16: Variations on a Theme

Entity view modes= secret sauce

Page 17: Variations on a Theme

Views is [sometimes] hell

Page 18: Variations on a Theme

Fields are nice

Page 19: Variations on a Theme

Formatters are often the answer

Page 20: Variations on a Theme

Examples:● field_collection_image_link_parent● field_collection_delta_display● display_text_formats● mediaelement_responsive● file_link● file_big_icons

Page 22: Variations on a Theme

Preprocess functionspass stuff to templates

Page 23: Variations on a Theme

YOURTHEME_button() {}Stuff like this usually belongs in template.php

Page 24: Variations on a Theme

Guideline: Minimize .tpl.php

Page 25: Variations on a Theme

Guideline: Should this view be fields?

Page 28: Variations on a Theme

...but not {less}

Page 29: Variations on a Theme

Take pride in avoiding Sass

Page 30: Variations on a Theme

often Distrust libraries

Page 31: Variations on a Theme

DRY (or others)

Page 32: Variations on a Theme

I HAVE NO PATIENCE FOR

Page 33: Variations on a Theme

reset.css, normalize.css

Page 34: Variations on a Theme

forms.css, footer.css

Page 35: Variations on a Theme

a:link {

background-color: transparent;

border-top: 0 none;

border-right: 0 none;

border-bottom: 0 none;

border-left: 0 none;

border-radius: 0;

clear: none;

color: #0000ff;

cursor: pointer;

display: inline;

float: none;

font-style: normal;

font-weight: normal;

margin: 0;

padding: 0;

position: static;

text-align: left;

text-decoration: underline;

}

Page 37: Variations on a Theme

body.node-12 #logo a[href] img

Page 38: Variations on a Theme

.header-level-2

Page 39: Variations on a Theme

* { box-sizing: border-box; }

Page 41: Variations on a Theme

Utility classes (for blocks)

.pipe-spaced {}

.pipe-spaced li:after {

color: #ccc;

content: '|';

display: inline-block;

padding: 0 0 0 10px;

}

.pipe-spaced li.last:after {

display: none;

}

Page 42: Variations on a Theme

Big .info files; overridesstylesheets[all][] = admin.cssstylesheets[all][] = aggregator.cssstylesheets[all][] = block.cssstylesheets[all][] = book.cssstylesheets[all][] = comment.cssstylesheets[all][] = contextual.cssstylesheets[all][] = ctools.cssstylesheets[all][] = date.cssstylesheets[all][] = datepicker.1.7.cssstylesheets[all][] = dblog.cssstylesheets[all][] = field.cssstylesheets[all][] = file.cssstylesheets[all][] = filter.cssstylesheets[all][] = forum.css...

Page 43: Variations on a Theme

There’s been a lot of code

Page 44: Variations on a Theme

Responsive trickery.region > .inner {

margin: 0 auto;

max-width: 960px;

padding: 20px 20px;

width: 960px;

}

@media all and (min-width: 1px) {

.region > .inner {

width: inherit;

}

}

Page 45: Variations on a Theme

Practical grids.grid {}

.grid .views-row {

float: left;

margin: 0 20px 20px 0;

}

.grid .view-content {

overflow: hidden;

}

Page 46: Variations on a Theme

§3. Resource Payload

Page 47: Variations on a Theme

mantra #2: Flush the caches

Page 48: Variations on a Theme

Fonts are part of a site

Page 49: Variations on a Theme

@font-face {

font-family: 'lato';

font-style: normal;

font-weight: normal;

src: url('fonts/lato.eot');

src: url('fonts/lato.eot?') format('embedded-opentype'),

url('fonts/lato.woff') format('woff');

}

@font-face {

font-family: 'lato';

font-style: italic;

font-weight: normal;

src: url('fonts/lato-i.eot');

src: url('fonts/lato-i.eot?') format('embedded-opentype'),

url('fonts/lato-i.woff') format('woff');

}

Page 50: Variations on a Theme

Social iconscan be done a million ways

Page 51: Variations on a Theme

.social {}

.social a[href] {

color: transparent;

display: inline-block;

font-size: 0px;

font-style: normal;

}

.social a[href]:before {

background-color: #888;

color: #fff;

content: '\1f517';

display: block;

font-family: 'fontello';

font-size: 16px;

font-size: 1rem;

min-width: 1em;

padding: 5px;

}

.social a[href]:hover:before {

background-color: #111;

color: #fff;

}

Page 52: Variations on a Theme

.social a[href*="facebook.com"]:before {

content: '\192';

}

.social a[href*="facebook.com"]:hover:before {

background-color: #3b5998;

}