40

Drupal Step-by-Step: How We Built Our Training Site, Part 2

  • Upload
    acquia

  • View
    5.462

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Drupal Step-by-Step: How We Built Our Training Site, Part 2
Page 2: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Drupal Step-by-Step: How We Built Our Training site

(part 2) Theming with Bootstrap

Page 3: Drupal Step-by-Step: How We Built Our Training Site, Part 2

About Me

•  Dave Myburgh •  Senior Engineer at

Acquia

•  Lead dev on Acquia.com site

Page 4: Drupal Step-by-Step: How We Built Our Training Site, Part 2

What we will cover

•  What is Twitter Bootstrap? •  Modules for better styling and CSS •  Using Bootstrap and Views •  Grid system and responsive layouts •  Components available

Page 5: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Who’s this for?

•  Themers •  Site builders •  With some experience in Drupal •  New Drupalers will learn too

Page 6: Drupal Step-by-Step: How We Built Our Training Site, Part 2
Page 7: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Requirements •  Update the old design •  Consistent look •  Cross-browser •  Easy to style new things without new styles

and constant code pushes •  Use SASS and Compass for the backend dev

work

Page 8: Drupal Step-by-Step: How We Built Our Training Site, Part 2
Page 9: Drupal Step-by-Step: How We Built Our Training Site, Part 2
Page 10: Drupal Step-by-Step: How We Built Our Training Site, Part 2

WHAT IS TWITTER BOOTSTRAP?

Page 11: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Bootstrap 3 "The most popular front-end framework for developing responsive, mobile first projects on the web." http://getbootstrap.com

•  made by Twitter for internal tool consistency •  released as open source on Github

Page 12: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Bootstrap 3 Features •  mobile-first, responsive •  cross-browser & IE8+

•  can use SASS or LESS as preprocessor OR use precompiled code

•  LOTS of useful CSS and JS “components”

•  excellent documentation and community

Page 13: Drupal Step-by-Step: How We Built Our Training Site, Part 2

•  Complete base theme drupal.org/project/bootstrap

•  Selected companion modulesdrupal.org/node/2011034

Integrate Bootstrap with Drupal

Page 14: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Bootstrap Drupal Theme •  jQuery incompatibility issue

–  Bootstrap requires jQuery 1.7 –  Views UI breaks with jQuery 1.8+ –  jQuery Update module 7.x-2.5 will have a fix

•  CSS Preprocessor –  Sub-theme uses LESS by default –  Modified to use SASS

Page 15: Drupal Step-by-Step: How We Built Our Training Site, Part 2

What is SASS? •  http://sass-lang.com •  Syntactically Awesome Style Sheets •  CSS with superpowers •  variables •  nested rules •  mixins ( = functions / scripts ) •  installed locally as a Ruby gem (module) •  compiled into a regular CSS file

Page 16: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Sub-theme setup •  Default tutorial is for LESS:

https://drupal.org/node/1978010 •  Add bootstrap folder with JS, fonts, and

(optionally) css •  Either as separate components or one css/js file

with everything (minified at 29kb)

Page 17: Drupal Step-by-Step: How We Built Our Training Site, Part 2

SASS friendly sub-theme •  (option) @import bootstrap in main .scss file •  for Compass, config.rb needs require 'bootstrap-sass'

•  bootstrap.js (or components) added to .info •  glyphicon font loaded in a scss file with @font-face

Page 18: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Sub-theme layout my_subtheme          |_  bootstrap          |          |_  fonts  (glyphicons-­‐halfling-­‐regular.*)          |          |_  js  (separate  js  files,  or  all  in  bootstrap.js)          |          |_  css  (optional  -­‐  bootstrap.css)          |_  css          |          |_  styles.css  (compiled  css  -­‐  added  to  .info)          |_  sass          |          |_  components  (_*.scss)          |          |_  styles.scss  (@import  all  the  components)          |_  templates          |          |_  *.tpl.php          |_  theme          |          |_  *.inc  (preprocess,  theme)          |_  my_subtheme.info          |_  config.rb          |_  template.php          |_  ...  (favicon,  logo,  screenshot)  

Page 19: Drupal Step-by-Step: How We Built Our Training Site, Part 2

MODULES FOR STYLING & CSS

Page 20: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Modules for better styling •  Field Group (HTML5 elements for groups)

•  Field Formatter Class (custom class on fields)

•  Block Class (custom class on blocks)

•  Font Awesome (cool icons just with a class)

•  Draggableviews (front-end reordering of table rows)

•  Gmap (event maps)

•  Views Bootstrap (Views styles using Bootstrap components)

Page 21: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Adding classes Field Formatter Class Block Class

Page 22: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Demo node forms, events page

Page 23: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Other bootstrap modules

•  Bootstrap Field Group •  Display Suite Bootstrap Layouts •  Panels Bootstrap Layouts, Styles, Tabs

Page 24: Drupal Step-by-Step: How We Built Our Training Site, Part 2

BOOTSTRAP AND VIEWS

Page 25: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Components

Page 26: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Views Bootstrap module •  Use 7.x-3.x-dev version for Bootstrap 3 (Jan 31,

2014) •  New Views styles: ○  Accordion ○  Carousel ○  Grid ○  Media Object ○  Tab ○  Table ○  Thumbnails

Page 27: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Demo track page + View, homepage

Page 28: Drupal Step-by-Step: How We Built Our Training Site, Part 2

GRID & RESPONSIVE LAYOUTS

Page 29: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Bootstrap Grid •  http://getbootstrap.com/css/#grid •  12 column grid •  Grid options

Page 30: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Responsive tables •  http://getbootstrap.com/css/#tables-responsive

Page 31: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Responsive helper classes •  http://getbootstrap.com/css/#responsive-

utilities •  img-responsive (max-width: 100%; and height: auto;)

Page 32: Drupal Step-by-Step: How We Built Our Training Site, Part 2

COMPONENTS AVAILABLE

Page 33: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Bootstrap CSS goodies

•  lead text, lists, code, etc •  Forms: inline options •  Buttons: colors, sizes, states, grouping •  Glyphicons: icon font •  Jumbotron •  Panels •  many more…

Page 34: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Demo bootstrap components documentation pages

Page 35: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Bootstrap Javascript goodies

•  Accordion & Carousel •  Modals (on current page or remote)

•  Tooltips •  Popovers •  Affix (sticky sidebar nav)

Page 36: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Demo bootstrap javascript documentation pages

Page 37: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Any questions?

Page 38: Drupal Step-by-Step: How We Built Our Training Site, Part 2

Thank you!

Page 39: Drupal Step-by-Step: How We Built Our Training Site, Part 2
Page 40: Drupal Step-by-Step: How We Built Our Training Site, Part 2