Loading...
 
Skip to main content

History: Bootstrap 3 to 4 transition

Source of version: 6

Copy to clipboard
            {DIV(class="lead")}As of this writing, the Bootstrap 4 development is at its sixth alpha release ( [http://blog.getbootstrap.com/2015/08/19/bootstrap-4-alpha/|Bootstrap 4 alpha]), so eventually there will be a beta release phase, and then the official release. There's no official timetable for this but we do know it's coming so we want to get prepared. Tiki, since version 13, is integrating Bootstrap 3 for a layout and styling framework. When Bootstrap 4.0 is released and other factors are positive, Tiki will shift from Bootstrap 3 to Bootstrap 4.{DIV}
("Other factors" might be such things as outside theme developers/designers shifting to Bootstrap 4 as well, other themes being available for Bootstrap 4 and so on. But given the long gestation period, the cool things brought by Bootstrap 4, and more and more third parties releasing Bootstrap 4 items, the transition to it is apt to be fairly fast.)

!! Testing a quick and dirty BS4 integration
To check what's necessary in the transition from 3 to 4, I made a new trunk installation on my local server, and put the Bootstrap 4 package in the ''vendors_custom'' directory. I chose one theme to test with - Amelia, probably because it's at the top of the list alphabetically. I used PhpStorm and its SCSS plugin for compiling. 

To get the stylesheets to compile, I made a "bridge file" to map old variables in existing-theme Less files to new Sass equivalents or else just to some value, and kept fixing missing variable definitions until the compile errors stopped.

PhpStorm has a Sass file watcher plugin, but you have to get and install the Sass watcher if you don't have it already. It's a Ruby gem. There are also some PHP scripts for compiling Sass files, so we'll have another chance to work the kinks out of that method.

!!! Steps of the test
* First of all, the theme's "less" directory needs to be renamed "scss". (While the CSS preprocessor is called "Sass", the directory name and file extension is ".scss".)
* To be consistent with the convention, I added an underbar to the beginning of all Sass partial files (the files that are imported), like "_tiki-selectors.scss".
* Within the Sass files, the variable name syntax needs to be converted, so instances of "@variable-name" are changed to "$variable-name".
* In Bootstrap 3, the "variables.less" file is essentially a list of definitions for variables that can be modified for the theme. In Bootstrap 4, there is no exact equivalent. Instead there is a "_custom.scss" file that is empty initially but can contain new definitions of variables to override the Bootstrap defaults.
* To customize a site or theme, the idea now is to use a ''_custom.scss'' file that contains a copy of the rules in "_variables.less" to be edited. Of course not all of the older variable names still exist, and some new ones are added. Since the new _variables.scss" is long and many variables aren't likely to need overriding, a good approach might be to make a general "_custom.scss" template with variables most often/likely specified by themes and compare this to the old "variables.less" file to do the updating/overriding.
* Less-to-Sass syntax conversions are needed in some theme and "base_files" files for things like image paths, color manipulation, etc.

In my test, I just modified one Smarty file - templates/layouts/basic/layout_view.tpl - because on first view the page columns were out of order. I rearranged div#col2, div#col1, and div#col3 into their actual order on the page. I haven't researched it yet, but it seems the "pull", "push", and "offset" classes are no longer used. In Bootstrap 4, column layout uses Flexbox by default, so in grids there is no longer floating columns into place, adding clearfix, and so on.

To get the stylesheets to compile, I made a "bridge file" to map old variables in existing-theme Less files to new Sass equivalents or else just to some value, and kept fixing missing variable definitions until the compile errors stopped.

PhpStorm has a Sass file watcher plugin, but you have to get and install the Sass watcher if you don't have it already. It's a Ruby gem. There are also some PHP scripts for compiling Sass files, so we'll have another chance to work the kinks out of that method.

!!! Test results
With just the basic adjustments to the Amelia theme files, the basic modification of layout_view.tpl, and pointing to the Bootstrap 4 lib (ignoring the Bootstrap 3 lib), the result was that the Tiki site did look and work pretty much like a Tiki site.

!!!! Issues that came up in the test
* Navbars have been revamped (and simplified) so this will have to be done in Tiki as well.
* The vertical menus were displaying horizontally. I didn't check further on this yet.
* Tabs, dropdowns and other lists containing links have new HTML so those will need updating.
* Modals, like the wiki edit help modal popup, aren't working. The shaded background appears, along with the top section of the modal, but the full modal and its content don't appear.
* Wells, panels, and so on have been replaced by "cards" so Tiki's modules, especially, and other instances of the old div classes will have to be updated.
* I understand forms have also undergone significant changes but I didn't look yet at what updating will be needed. 

!! Two kinds of changes to deal with
Looks like there are basically two kinds of changes we'll need to cope with. One is the switch from Less to Sass. That's pretty straightforward as it mostly involves file names and variable names in those files (@variable to $variable, etc.). Of course there are some method differences but probably not many that will cause trouble for us (one I came across is a color function - Less uses "spin" and Sass uses "adjust_color"). Also paths like the image path variable have slightly different syntax. But I adjusted these as I came across them and will post some docs. 

The second kind of change is with the Bootstrap bits themselves. In my "trunk - bootstrap 4 alpha", I found the grid layout and typography worked nicely already (BS4 switches to -+rem+- for the grid and for the typography), but panels and wells have been replaced by the -+card+- class, so in the templates we're going to have to do those replacements. Forms, especially horizontal forms, have changed quite a bit and will need to be adjusted. Also the navbar is being simplified, as apparently we're not alone in having trouble wrangling content into that area. Menus and tabs weren't working yet either in my installation or at the Bootstrap 4 demo so apparently they're still being worked out.

Looks like there are also Sass-variable files for Chosen; not sure about Table-sorter, but with Sass being more popular actually than Less, chances are good we can find support.

Interestingly, for Bootstrap 6, they're planning to move from Sass to [https://twitter.com/postcss|PostCSS]. I'm still reading about PostCSS, which has a lot of momentum. Apparently its power comes from the modules you add to it; it can do the standard Sass thing, but can be configured to do custom things so you're not limited to the abilities of Sass or Less or whatever.

!! Useful links
[http://v4-alpha.getbootstrap.com/]
https://scotch.io/bar-talk/whats-new-in-bootstrap-4
http://bootstrapbay.com/bootstrap4/ (Bootstrap 4 Cheatsheet)
[https://medium.com/wdstack/bootstrap-4-whats-new-visual-guide-c84dd81d8387#.b2sxbfsf6]
[http://www.hongkiat.com/blog/boostrap-4-best-features/]
[https://hackerthemes.com/bootstrap-cheatsheet/]  
[https://bootstrapcreative.com/resources/bootstrap-4-css-classes-index/]
[https://www.udemy.com/bootstrap-4/]
[http://codepen.io/search?q=bootstrap+cards&limit=all&depth=everything&show_forks=false]

[https://gist.github.com/chriseppstein/674726] - Sass/Less Comparison
[https://css-tricks.com/sass-vs-less/]

        

History

Advanced
Information Version
Wed 03 of Oct, 2018 08:03 GMT-0000 Gary Cunningham-Lee Added recent status and link. 56
Sun 12 of Aug, 2018 08:24 GMT-0000 Gary Cunningham-Lee Added title bar for page alias. 55
Sun 12 of Aug, 2018 08:21 GMT-0000 Gary Cunningham-Lee Added a link. 54
Fri 10 of Aug, 2018 05:59 GMT-0000 Gary Cunningham-Lee Added updates and link. 53
Fri 27 of Jul, 2018 10:13 GMT-0000 Gary Cunningham-Lee Updated details. 52
Fri 27 of Jul, 2018 10:08 GMT-0000 Gary Cunningham-Lee Added info. 51
Wed 25 of Jul, 2018 09:36 GMT-0000 Gary Cunningham-Lee Updated info. 50
Sun 15 of Jul, 2018 14:51 GMT-0000 Gary Cunningham-Lee Some updates. 49
Sun 15 of Jul, 2018 14:41 GMT-0000 Gary Cunningham-Lee 48
Thu 21 of Jun, 2018 14:43 GMT-0000 Gary Cunningham-Lee Added link to Organization of button colors in Tiki page. 47
Wed 30 of May, 2018 10:25 GMT-0000 Gary Cunningham-Lee Commented out bugs that are fixed or no longer a problem. 46
Wed 02 of May, 2018 08:32 GMT-0000 luciash d' being ?‍♂️ added alias workaround to prevent Google penalty for 404 result 45
Mon 23 of Apr, 2018 17:58 GMT-0000 luciash d' being ?‍♂️ browser support note 44
Sun 22 of Apr, 2018 05:13 GMT-0000 Gary Cunningham-Lee Updated merge info. 43
Sun 08 of Apr, 2018 11:34 GMT-0000 Gary Cunningham-Lee Added section for other possible related changes 42
Wed 04 of Apr, 2018 04:48 GMT-0000 Gary Cunningham-Lee Added point about Tour. 41
Tue 03 of Apr, 2018 13:19 GMT-0000 Gary Cunningham-Lee Added a couple of items. 40
Tue 03 of Apr, 2018 03:40 GMT-0000 Gary Cunningham-Lee Updated in a few places. 39
Sun 01 of Apr, 2018 07:56 GMT-0000 Jonny Bradley added js modal fixes commit 38
Wed 28 of Mar, 2018 13:00 GMT-0000 Gary Cunningham-Lee Ideas added. 37
Wed 21 of Mar, 2018 14:15 GMT-0000 Gary Cunningham-Lee More points added. 36
Thu 08 of Mar, 2018 11:15 GMT-0000 Gary Cunningham-Lee Added note about column show/hide. 35
Thu 01 of Mar, 2018 13:27 GMT-0000 Gary Cunningham-Lee Confirming that Bootstrap 6 was a typo. 34
Thu 01 of Mar, 2018 12:51 GMT-0000 Marc Laporte AFAIK, it's in 5, but maybe it changed? If so, can you add the reference? 33
Thu 01 of Mar, 2018 11:21 GMT-0000 Gary Cunningham-Lee Added code migration section 32
Mon 26 of Feb, 2018 10:07 GMT-0000 Gary Cunningham-Lee Fixed link. 31
Mon 26 of Feb, 2018 10:02 GMT-0000 Gary Cunningham-Lee Updated some links. 30
Mon 26 of Feb, 2018 09:52 GMT-0000 Gary Cunningham-Lee Added missing lines of commit info. 29
Mon 26 of Feb, 2018 09:50 GMT-0000 Gary Cunningham-Lee Fixed typo. 28
Mon 26 of Feb, 2018 09:48 GMT-0000 Gary Cunningham-Lee Updated info. 27
Mon 26 of Feb, 2018 09:40 GMT-0000 Gary Cunningham-Lee Added recent commits. 26
Fri 19 of Jan, 2018 15:53 GMT-0000 Gary Cunningham-Lee Testing page edit save. 25
Fri 05 of Jan, 2018 08:30 GMT-0000 Gary Cunningham-Lee Added r65033 info. 24
Fri 15 of Dec, 2017 10:37 GMT-0000 Gary Cunningham-Lee Added link to Updating a Tiki theme from Bootstrap 3 to 4 23
Sat 28 of Oct, 2017 12:43 GMT-0000 Gary Cunningham-Lee Added some comments. 22
Thu 26 of Oct, 2017 12:56 GMT-0000 Gary Cunningham-Lee Added another item. 21
Thu 26 of Oct, 2017 05:51 GMT-0000 Gary Cunningham-Lee Added r64379 to list. 20
Thu 19 of Oct, 2017 07:31 GMT-0000 Gary Cunningham-Lee 19
Thu 19 of Oct, 2017 06:46 GMT-0000 Gary Cunningham-Lee 18
Thu 19 of Oct, 2017 06:45 GMT-0000 Gary Cunningham-Lee Added process notes. 17
Thu 19 of Oct, 2017 06:32 GMT-0000 Gary Cunningham-Lee Fixed typos. 16
Thu 19 of Oct, 2017 06:31 GMT-0000 Gary Cunningham-Lee 15
Thu 19 of Oct, 2017 06:15 GMT-0000 Gary Cunningham-Lee Start recording non-theme commits to Bootstrap 4 experimental branch for smoother merge back (thanks, Jonny). 14
Mon 02 of Oct, 2017 10:22 GMT-0000 Gary Cunningham-Lee 13
Mon 02 of Oct, 2017 10:21 GMT-0000 Gary Cunningham-Lee Fixed typo. 12
Mon 02 of Oct, 2017 10:20 GMT-0000 Gary Cunningham-Lee Added link to Bootstrap Tour Bootstrap 4 update issue. 11
Fri 22 of Sep, 2017 09:59 GMT-0000 luciash d' being ?‍♂️ BS4 is beta now 10
Wed 02 of Aug, 2017 08:18 GMT-0000 Gary Cunningham-Lee Added a link; organized links. 9
Sun 30 of Jul, 2017 19:19 GMT-0000 drsassafras removed duplicated text & some minor grammar 8
Wed 05 of Jul, 2017 13:15 GMT-0000 Gary Cunningham-Lee Added a link. 7
  • «
  • 1 (current)
  • 2