Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Bootstrap 4 Cookbook

You're reading from   Bootstrap 4 Cookbook Solutions to common problems faced in Responsive Web Design

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781785889295
Length 338 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Ajdin Imsirovic Ajdin Imsirovic
Author Profile Icon Ajdin Imsirovic
Ajdin Imsirovic
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Installing Bootstrap 4 and Comparing Its Versions FREE CHAPTER 2. Layout Like a Boss with the Grid System 3. Power Up with the Media Object, Text, Images, and Tables 4. Diving Deep into Bootstrap 4 Components 5. Menus and Navigations 6. Extending Bootstrap 4 7. Make Your Own jQuery Plugins in Bootstrap 4 8. Bootstrap 4 Flexbox and Layouts 9. Workflow Boosters 10. Creating a Blog with Jekyll and Bootstrap 4 11. Bootstrap 4 with ASP.NET Core 12. Integrating Bootstrap 4 with React and Angular

Comparing Bootstrap 4 versions with Bower

In this recipe, we will see how to have a fine-grained view of the changes between Bootstrap 4 versions, using Bower. We will first install Bower, and then utilize Git to make comparisons.

Getting ready

To begin with, all we need to do is make a new project on Cloud9 IDE, without cloning a repository.

How to do it...

  1. Install bower using npm:
      npm install -g bower
  1. Verify the bower installation:
      which bower && bower -v
Note that both commands should return some values.
  1. Install Bootstrap 4 alpha 5 (this is not a typo!):
      bower install bootstrap#v4.0.0-alpha.5
We are installing an older version on purpose. This will be explained in the next steps.
  1. See the list of the installed dependencies:
      bower list

The preceding command will print out the status of your project's dependencies, including the available update to the currently installed Bootstrap 4 alpha 5.

  1. Initialize git in root:
      cd && cd workspace;
git init
  1. Stage the files into git's staging area:
      git add --all
  1. Commit the changes with a message:
      git commit -m “Add B4, alpha 5”
  1. Upgrade Bootstrap 4 to alpha 6 with bower:
      bower install bootstrap#v4.0.0-alpha.6
To install this update, Windows users will have to use the command prompt (rather than Git Bash for Windows).

When prompted for answer, type "2" and then press ENTER.
  1. Now, using git diff, we have at our fingertips the full view of changes that happened between alpha 5 and alpha 6 versions of Bootstrap 4. However, it is not feasible to simply use a blanket git diff command because too many changes are made to too many files between each version. A much better strategy is to use the git diff --stat, with the --stat flag giving us a nice overall idea of the changes, as well as which files had the most changes and which had the least. The following screenshot lists only the beginning of the output of the git diff --stat command, and does not include all the files affected, but it gives us a nice visual overview of changes made between alpha versions 5 and 6:
For Windows users, before listing the result of the git diff --stat command, Windows command prompt will throw a bunch of errors--just use the Page Down button to move past them.
  1. Now we can inspect only the files that we are interested in, for example, the following command:
      git diff bower_components/bootstrap/scss/_alert.scss

The preceding command will show us the changes made only in the _alert.scss partial, between Bootstrap 4 Alpha 5 and Alpha 6 versions. In the following screenshot, we can see one of the changes made to this file:

  1. With this approach, it is also really simple to track the changes to the _alert.scss file in the previous versions of Bootstrap 4 alpha. For example, we can downgrade our Bootstrap 4 installation with the help of Bower, and then repeat our git diff for the _alert.scss file only, by running the following commands:
      bower install bootstrap#4.0.0-alpha.4
git diff bower_components/bootstrap/scss/_alert.scss

With this recipe, we are able to have complete, fine-grained control of observing the changes made to the framework through its versions. This is an amazing approach to understand the changes that occurred to specific components between different versions of the framework. It can help us understand why bugs occurred in our code, avoid pitfalls when working with legacy code, and learn the approaches taken by the Bootstrap contributors and how to better work with Sass in Bootstrap.

You have been reading a chapter from
Bootstrap 4 Cookbook
Published in: Jun 2017
Publisher: Packt
ISBN-13: 9781785889295
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime