improve theming with (twitter) bootstrap

43
Improve theming with (Twitter) Bootstrap Yurtaev Andrey @i_amdroid

Upload: andrey-yurtaev

Post on 19-Jun-2015

298 views

Category:

Technology


2 download

DESCRIPTION

Session about using Bootstrap in Drupal theming

TRANSCRIPT

Page 1: Improve theming with  (Twitter) Bootstrap

Improve theming with (Twitter) Bootstrap

Yurtaev Andrey@i_amdroid

Page 2: Improve theming with  (Twitter) Bootstrap

What is bootstrap?

“The most popular front-end framework for developing responsive, mobile first projects

on the web.”

getbootstrap.com

Page 3: Improve theming with  (Twitter) Bootstrap
Page 4: Improve theming with  (Twitter) Bootstrap

Benefits

● standardization of markup ● popularity ● extensibility

Page 5: Improve theming with  (Twitter) Bootstrap

d.o themes

Bootstrap 3● Bootstrap dgo.to/bootstrap● Bootstrap Barrio dgo.to/bootstrap_barrio● Bootstrap Business dgo.to/bootstrap-business● Radix dgo.to/radix● Circle dgo.to/circle

Bootstrap 2● Tweme dgo.to/tweme● Elimai dgo.to/elimai

Page 6: Improve theming with  (Twitter) Bootstrap

Examples

Page 7: Improve theming with  (Twitter) Bootstrap

Bootstrap basic theme, navbar, wells, tooltips, many settings

Page 8: Improve theming with  (Twitter) Bootstrap
Page 9: Improve theming with  (Twitter) Bootstrap

Bootstrap Barrio bootstrap subtheme, basic theme

Page 10: Improve theming with  (Twitter) Bootstrap

Bootstrap Business colors, looks great

Page 11: Improve theming with  (Twitter) Bootstrap

Radix basic theme, for panopoly, bootswatch compatible

Page 12: Improve theming with  (Twitter) Bootstrap

bootswatch.com - choose theme, for example, flatly drush radix "Flatly" --bootswatch=flatly

easy, but requires compass and other gems

Page 13: Improve theming with  (Twitter) Bootstrap

Circle for panels, very basic, many settings, no bs classes for standart elements

Page 14: Improve theming with  (Twitter) Bootstrap

Tweme ready to use

Page 15: Improve theming with  (Twitter) Bootstrap
Page 16: Improve theming with  (Twitter) Bootstrap

Elimai

Page 17: Improve theming with  (Twitter) Bootstrap

More Drupal themes

themeforest.net

more than 100 professional drupal themesbased on bootstrap

price 40-50$

Page 18: Improve theming with  (Twitter) Bootstrap

Examples

Page 19: Improve theming with  (Twitter) Bootstrap

Consilium d7.to/consilium

Page 20: Improve theming with  (Twitter) Bootstrap

Dawn d7.to/dawn

Page 21: Improve theming with  (Twitter) Bootstrap

Realia d7.to/realia

Page 22: Improve theming with  (Twitter) Bootstrap

Make own Bootstrap themeMYTHEME.info:

name = MYTHEMEcore = 7.xdescription = Bootstrap start theme.dependencies[] = jquery_update

base theme = html5

Page 23: Improve theming with  (Twitter) Bootstrap

template.php:

function MYTHEME_preprocess_html(&$variables) { drupal_add_css('//netdna.bootstrapcdn.com/ bootstrap/3.1.1/css/bootstrap.min.css', array('type' => 'external')); drupal_add_js('//netdna.bootstrapcdn.com/ bootstrap/3.1.1/js/bootstrap.min.js', array('type' => 'external'));}

Page 24: Improve theming with  (Twitter) Bootstrap

page.tpl.php:

<!-- mark up from http://getbootstrap.com/components/#navbar --><nav role="navigation" class="navbar navbar-default"> <div class="container-fluid"><div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"><?php print $site_name; ?></a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array( 'id' => 'main-menu', 'class' => array('nav', 'navbar-nav')))); ?> </div></div></nav>

Page 25: Improve theming with  (Twitter) Bootstrap

Result

Page 26: Improve theming with  (Twitter) Bootstrap
Page 27: Improve theming with  (Twitter) Bootstrap

Preprocesstemplate.php: /** * Override theme_menu_local_tasks(). * Add Bootstrap class to menu */function MYTHEME_menu_tree($variables) { return '<ul class="menu nav">' . $variables['tree'] . '</ul>';}

Page 28: Improve theming with  (Twitter) Bootstrap

function MYTHEME_menu_local_tasks(&$variables) { $output = '';

if (!empty($variables['primary'])) { $variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>'; $variables['primary']['#prefix'] .= '<ul class="nav nav-tabs">'; $variables['primary']['#suffix'] = '</ul>'; $output .= drupal_render($variables['primary']); } if (!empty($variables['secondary'])) { $variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>'; $variables['secondary']['#prefix'] .= '<ul class="nav nav-tabs">'; $variables['secondary']['#suffix'] = '</ul>'; $output .= drupal_render($variables['secondary']); }

return $output;}

Page 29: Improve theming with  (Twitter) Bootstrap

So, we will get...

Bootstrap(d.o theme)

Page 30: Improve theming with  (Twitter) Bootstrap

Or...

Glookd7.to/glook-sb

Page 31: Improve theming with  (Twitter) Bootstrap

Glook ready to use, flexbox

Page 32: Improve theming with  (Twitter) Bootstrap

Approaches

Classic way● a lot of css● little bit preprocess● different look

BS subtheme or own theme● little bit css● a lot of preprocess● close to default look

Another way● little bit of Sass (or

Less)● no preprocess● different look

Page 33: Improve theming with  (Twitter) Bootstrap

Bootstrap SASS

github.com/twbs/bootstrap-sass

gem install bootstrap-sass

compass create MYTHEME -r bootstrap-sass--using bootstrap

Page 34: Improve theming with  (Twitter) Bootstrap

Theme filestemplate.php:

/* disable cdnfunction MYTHEME_preprocess_html(&$variables) { ...}*/

Page 35: Improve theming with  (Twitter) Bootstrap

MYTHEME.info:

stylesheets[all][] = css/styles.css

scripts[] = js/bootstrap/collapse.js...

Page 36: Improve theming with  (Twitter) Bootstrap

styles.scss:

// customize bootstrap variables here:@import "variables";@import "bootstrap";

.links, .links li { list-style: none; padding: 0; }

.links li a { @extend .btn; @extend .btn-info; }

Page 37: Improve theming with  (Twitter) Bootstrap

Result

Page 38: Improve theming with  (Twitter) Bootstrap
Page 39: Improve theming with  (Twitter) Bootstrap

In sum

Page 40: Improve theming with  (Twitter) Bootstrap
Page 41: Improve theming with  (Twitter) Bootstrap

Actually

only on themeforest,but there are:● templatemonster.com● templateshop.be● dreamtemplate.com● and many others

Page 43: Improve theming with  (Twitter) Bootstrap

Thank You

Questions?