Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(navbar-toggle): convert template to render function #1313

Merged
merged 4 commits into from Nov 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/navbar/README.md
Expand Up @@ -272,10 +272,12 @@ Use the `<b-navbar-toggle>` component to control the collapse component, and set

Set the `toggleable` prop on `<b-navbar>` to the desired breakpoint you would like content
to automatically collapse at. Possible `toggleable`values are `sm`, `md`, and `lg`. Setting
`togleable` to `true` (or with no explicit value) will set the breakpoint to `sm`, while
`toggleable` to `true` (or with no explicit value) will set the breakpoint to `sm`, while
setting it to `false` will disable collapsing.

`<b-navbar-toggle>` should be placed _before_ any `<b-collapse is-nav>` component.
`<b-navbar-toggle>` components are left-aligned by default, but should they follow a sibling
element like `<b-navbar-brand>`, they’ll automatically be aligned to the far right. Reversing
your markup will reverse the placement of the toggler.

See the first example on this page for reference, and also refer to
[`<b-collapse>`](/docs/components/collapse) for details on the collapse component.
Expand Down
51 changes: 49 additions & 2 deletions src/components/navbar/navbar-toggle.js
@@ -1,3 +1,50 @@
import bNavbarToggle from './navbar-toggle.vue';
import { listenOnRootMixin } from '../../mixins';

export default bNavbarToggle;
export default {
mixins: [listenOnRootMixin],
render(h) {
const t = this;
return h(
'button',
{
class: [ 'navbar-toggler' ],
attrs: {
type: 'button',
'aria-label': t.label,
'aria-controls': t.target,
'aria-expanded': t.toggleState ? 'true' : 'false'
},
on: { click: t.onClick }
},
[ t.$slots.default || h('span', { class: [ 'navbar-toggler-icon' ] }) ]
);
},
data() {
return {
toggleState: false
};
},
props: {
label: {
type: String,
default: 'Toggle navigation'
},
target: {
type: String,
required: true
}
},
methods: {
onClick() {
this.$root.$emit('bv::toggle::collapse', this.target);
},
handleStateEvt(id, state) {
if (id === this.target) {
this.toggleState = state;
}
}
},
created() {
this.listenOnRoot('bv::collapse::state', this.handleStateEvt);
}
};
59 changes: 0 additions & 59 deletions src/components/navbar/navbar-toggle.vue

This file was deleted.