Андрей Юртаев - improve theming with (twitter) bootstrap

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

Upload: drupalspb

Post on 28-Jan-2015

114 views

Category:

Software


3 download

DESCRIPTION

Андрей Юртаев - Improve theming with (Twitter) Bootstrap Событие: Drupal White Nights 2014 Дата: 07.06.2014 Анонс: http://camp2014.drupalspb.org/sessions/improve-theming-twitter-bootstrap

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?