StudioKonKon / bootstrap-konkon

A personal project I intend to use as a theme for my own website but available for others to use if they wish either for their own content or for educational purposes.
https://play.studiokonkon.com/
MIT License
4 stars 0 forks source link

Upgrade to Bootstrap v5 #1

Open StudioKonKon opened 3 years ago

StudioKonKon commented 3 years ago

Bootstrap v5 is sill in Beta but there were too many issues in v4. This project was originally made with Less and Bootstrap v3 but was not upgraded properly. This may be only a personal project that I only intend to use for myself but it is due for an upgrade.

New Changes:

Major Changes:

Fix bugs and issues:

Project Layout

_bootstrap-required.scss Include all necessary functions, variables an mixins for both our custom code and Bootstrap's. This will not produce any CSS and is useful for customising builds and including with @use if Dart is supported. This is used in Child Themes or custom builds where not all of Bootstrap may be use. For Example, when importing our _konkon-components.scss or separate styles without any of the core Bootstrap styles.

_bootstrap-optional.scss and _konkon-optional.scss Simply import All of bootstrap's or our optional styles.

_konkon-components.scss Import All of our custom components. This is completely separate and optional. It's recommended only to use what's needed and without the core Bootstrap module.

Icons

Icons still use the Material Design Iconic Font as there are a few issues with Bootstrap's new Icon set and don't include most other icons. Bootstrap's Icon may get it's own separate style. This theme relies on the .icon class so any icon library will work with it with some custom styling. The .icon class must always be specific to a parent so the styles can be different according to the components it's used with instead of using very long prefixes. E.g .btn .icon or .dropdown .icon or .toast-header .icon

More Information

More on Migration: https://getbootstrap.com/docs/5.0/migration/

StudioKonKon commented 3 years ago
StudioKonKon commented 3 years ago
StudioKonKon commented 3 years ago

Import order (from Bootstrap 5.1.*)

@import "bootstrap-required";

In order for overrides to work, variable overrides need to be defined before bootstrap's. It appears the authors' do not fully understand the `!default" keyword and that variables are not reactive, even though it's already been pointed out, this issue is more apparent in the new Bootstrap 5.1.0 release. Original Issue: https://github.com/twbs/bootstrap-npm-starter/issues/43

// Functions
@import "../node_modules/bootstrap/scss/functions"; // Required (Bootstrap)
@import "functions"; // Theme Required

// Variable Overrides
@import "variables"; // Theme Required

// Bootstrap Variables
@import "../node_modules/bootstrap/scss/variables"; // Required (Bootstrap)

// Theme Variables
@import "theme-variables"; // Theme Required

// Maps
@import "bootstrap-maps"; // Theme Required

// Mixins
@import "../node_modules/bootstrap/scss/mixins"; // Required (Bootstrap)
@import "mixins"; // Theme Required

// Utilities
@import "../node_modules/bootstrap/scss/utilities"; // Required (Bootstrap)

When using this theme, only @import "bootstrap-required"; is needed unless other variable overrides are required. Any bootstrap overrides must always come before bootstrap's own @import "../node_modules/bootstrap/scss/variables"; with the downside of not been able to use bootstrap's own variables.

Alternatively. use @use "bootstrap" as bootstrap; https://github.com/twbs/bootstrap-npm-starter/issues/43#issuecomment-781456048

Bootstrap 5.1.0

Due to existing variable override issues, some new maps need regenerating. We will do this in _bootstrap-maps.scss as bootstrap no longer allows maps to be overridden before importing due to lack of map-merge and !default

// Required
$theme-colors: map-merge($theme-colors, $custom-theme-colors); 
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value"); 
$utilities-colors: map-merge($utilities-colors, $theme-colors-rgb); 
$utilities-text-colors: map-loop($utilities-colors, rgba-css-var, "$key", "text"); 
$utilities-bg-colors: map-loop($utilities-colors, rgba-css-var, "$key", "bg"); 

Bootstrap 5.2.0-beta1

Issue with maps have now been fixed. _bootstrap-maps.scss will still be used for map overrides. Only $theme-colors is need as required.

// Required
$theme-colors: map-merge($theme-colors, $custom-theme-colors); 
StudioKonKon commented 1 year ago

Upgrade to Bootstrap v5.3.* - v6.0.0

Get Ready for Bootstrap v6.0.0: https://getbootstrap.com/docs/5.3/migration/

Issues

Updates

Sidebar HTML

<div class="sidebar" data-sk-type="fixed">
  <div class="sidebar-wrapper">
    <!-- Sidebar Content  -->
  </div>
</div>

Sidebar JS

const sidebar = new konkon.Sidebar("#left-sidebar")

function sidebarClose(event) {
   if (typeof sidebar.triggerAutoClose !== "undefined") {
      sidebar.triggerAutoClose(event)
   }
}

document.addEventListener("mousedown", sidebarClose, false)
document.addEventListener("touchstart", sidebarClose, false)