Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Improve color theme selection for navbars
Browse files Browse the repository at this point in the history
  • Loading branch information
luyangkenneth committed Mar 31, 2019
1 parent 048d5de commit f151f41
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/Navbar.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<template>
<nav ref="navbar" :class="['navbar', 'navbar-expand-md',
{
'navbar-dark':(type === 'inverse'),
'navbar-light':(type === 'default'),
'bg-dark':(type === 'inverse'),
'bg-light':(type === 'default')
}, addClass]">
<nav ref="navbar" :class="['navbar', 'navbar-expand-md', themeOptions, addClass]">
<div class="container-fluid">
<div class="navbar-brand"><slot name="brand"></slot></div>
<button v-if="!slots.collapse" class="navbar-toggler" type="button" aria-expanded="false" aria-label="Toggle navigation" @click="toggleCollapse">
Expand All @@ -32,7 +26,7 @@ export default {
props: {
type: {
type: String,
default: 'default'
default: 'primary'
},
addClass: {
type: String,
Expand All @@ -49,6 +43,28 @@ export default {
computed: {
slots () {
return this.$slots
},
themeOptions () {
// If the value of `type` is not primary | dark | light | none,
// then explicitly set isNavbarDark and isBgPrimary to true.
const isNavbarDark = (this.type === 'primary' || this.type === 'dark')
? true
: (this.type === 'light' || this.type === 'none')
? false
: true
const isBgPrimary = (this.type === 'primary')
? true
: (this.type === 'dark' || this.type === 'light' || this.type === 'none')
? false
: true
return {
'navbar-dark': isNavbarDark,
'navbar-light': (this.type === 'light'),
'bg-primary': isBgPrimary,
'bg-dark': (this.type === 'dark'),
'bg-light': (this.type === 'light')
}
}
},
methods: {
Expand Down

0 comments on commit f151f41

Please sign in to comment.