Git Product home page Git Product logo

vue-bootstrap-sidebar's Introduction

๐Ÿ“‘ vue-bootstrap-sidebar ๐Ÿ“‘

vue-bootstrap-sidebar is a Vue sidebar menu component, build using bootstrap-vue.

Be sure to check out the Sidebar component in BootstrapVue firtst. My implementation is older, much simpler, but still in active development.

Preview

For the preview just clone this repository and run dev server.

git clone https://github.com/JurajKavka/vue-bootstrap-sidebar.git
cd vue-bootstrap-sidebar
npm install
npm run serve

Installation & integration to Vue app

NOTE: I assume, that You are already building Vue application with bootstrap. If not, You will need to install and configure bootstrap-vue.

NOTE: If You want to use Font Awesome icons, be sure that you have installed and configured vue-fontawesome.

Installation from npm registry

You can use npm

npm install vue-bootstrap-sidebar

or yarn

yarn add vue-bootstrap-sidebar

Integration to the project

BootstrapSidebar component is a wrapper for a whole page with two named slots:

  • navbar - slot for your top navbar component
  • content - slot for the entire content of your page

It is up to You, how Your top navbar component and content looks like. As we are using bootstrap, it is good if a whole webpage follows bootstrap patterns.

Except that, styles needs to be imported.

<style lang="scss">
  @import 'node_modules/vue-bootstrap-sidebar/src/scss/default-theme.scss';
</style>

So, Your main app component should look like on this example:

<script>
import Vue from 'vue'
import BootstrapSidebar from 'vue-bootstrap-sidebar'

export default Vue.extend({
  name: 'App',
  components: {
    BootstrapSidebar
  },
  data () {
    return {
      initialShow: true,
      header: '<h3>Sidebar</h3>',
      links: [
        { name: 'Home', href: { name: 'home' }, faIcon: ['fas', 'home'] },
        {
          name: 'Dropdown',
          faIcon: ['fas', 'tint'],
          children: [
            {
              name: 'Child Item 1',
              href: {
                name: 'child-item-1'
              },
              faIcon: ['fas', 'child']
            },
            {
              name: 'Child Item 2',
              href: {
                name: 'child-item-2'
              },
              faIcon: ['fas', 'child']
            }
          ]
        },
        { name: 'About', href: { name: 'about' }, faIcon: 'users' },
        { name: 'Contact', href: { name: 'contact' }, faIcon: 'phone' }
      ]
    }
  },
  methods: {
    onSidebarChanged () {
    }
  }
})
</script>

<template>
  <div id="App">
    <BootstrapSidebar
      :initial-show="initialShow"
      :links="links"
      :header="header"
      :fa="true"
      @sidebarChanged="onSidebarChanged"
    >
      <template v-slot:navbar>
        <b-navbar
          id="mainNavbar"
          toggleable="lg"
          type="light"
          variant="light"
          fixed="top"
        >
          <b-navbar-nav>
            <b-nav-item>
              Navbar
            </b-nav-item>
          </b-navbar-nav>
        </b-navbar>
      </template>

      <template v-slot:content>
        <b-container style="margin-top: 56px">
          <router-view />
        </b-container>
      </template>
    </BootstrapSidebar>
  </div>
</template>

<style lang="scss">
@import 'node_modules/bootstrap/scss/bootstrap';
@import 'node_modules/bootstrap-vue/src/index.scss';
@import 'node_modules/vue-bootstrap-sidebar/src/scss/default-theme';
</style>

Configuration (props)

Configuration options (props) of the BootstrapSidebar are:

  • initialShow - true/false if the sidebar is initially visible or not (default: true)
  • header - header for the sidebar. You can also use html tags like h3, strong, etc.
  • links - array of menu items.
    • href propery is rendered with router-link.
    • children property is rendered as dropdown with defined child.
    • faIcon renders Font Awesome icon, lef to the menu item. For this feature, You need to install vue-fontawesome. You can provide icon as array e.g. ['fas', 'user'] or as string e.g.'user'.
  • theme - custom scss theme (default: default-theme).

TODOs

  • write tests

Notes

vue-bootstrap-sidebar's People

Contributors

jurajkavka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-bootstrap-sidebar's Issues

How to not render the font-awesome icon in children?

Hello, i want to render font-awesome icon for parent but not children in a dropdown list.

I can simply put empty string or empty array in faIcon and error message will show in console.

Is this the correct way to not render an icon? Thanks.

Dropdown doesn't work when there is a name contain space

The dropdown with name "My Product" doesn't work. When i change it to "Product" then it will work.

                    name: "My Product",
                    faIcon: ["fas", "box-open"],
                    children: [
                        {
                            name: "Product list",
                            href: {
                                name: "product",
                            },
                            faIcon: false,
                        },
                        {
                            name: "Add product",
                            href: {
                                name: "product-create",
                            },
                            faIcon: false,
                        },
                    ],

So i can assume that the dropdown won't work when the parent name contain space.

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.