Giter Site home page Giter Site logo

vue-bootstrap-theming's Introduction

Vue Theming Bootstrap

Build Status

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Demo

https://rehmatfalcon.github.io/vue-bootstrap-theming/

Screenshot

dark_light

Motivation

  1. To integrate bootstrap with vue and make theming possible.
  2. To adapt bootstrap according to project requirement by changing its variables.

Procedures followed:

  1. Add bootstrap to project
npm i bootstrap jquery popper
// Jquery and popper were added because 
// bootstrap relies on them for some of its functionality 
  1. Create a styles file and import bootstrap scss there.
@import '~bootstrap/scss/boostrap';
// add any new styles / overrides
  1. Import the styles file in our app.

App.vue

<style>
import './styles';
</style>

Once we have done the above, we can use bootstrap classes in our application.

Blog.vue (For example)

<template>
    <div class="row">
        <div class="col">
            <button class="btn btn-primary">
                Primary
            </button>
        </div>
    </div>
</template>

Theming

Bootstrap exposes its configuration as SASS variables. So, in order to have multiple theme, its just a matter of generating different classes with adjusted variable values.

.theme-dark {
    $card-color : #d8d5d5;
    $card-bg: rgb(65, 65, 65);
    $card-cap-color: #ebebeb;
    $card-cap-bg: darken($card-bg, 5%);
}

This sets the background color and text of the card component.

Currently two themes are supported : light and dark.

When the theme is light, a theme-light class is added to the body element.

When dark theme is chosen, a theme-dark class is added to the body element.

In order to allow for multiple themes for multiple component, now the classes theme-light and theme-dark are applied to the root element of the component.

The allows us to render different parts of the app with different theme.

Js counterpart

In the js, we check the current theme and apply correct class to the body element.

We also add a temp-transitional class to the body component element for one second. This is done to ensure that the transition from light to dark theme and vice versa does not feel abrupt.

.temp-transitional {
  &, & *, & *:before, & *:after {
    transition: all .3s;
  }
}

temp-transitional is defined as above.

We also save the selected theme in localstorage, so that the user choice is persisted across request.

vue-bootstrap-theming's People

Contributors

niroula-kushal avatar

Stargazers

Biraj Mainali avatar Shikha Bista avatar Sujan Rai avatar

Watchers

James Cloos avatar  avatar

vue-bootstrap-theming's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.