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

fix(pivot): pivot-item active respects prop value #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/pivot/Pivot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default {
.filter(pivotItem => pivotItem.tag === 'vnt-pivot-item')
.forEach((pivotItem, index) => {
const attrs = pivotItem.data.attrs;
const isActive = Object.keys(attrs).indexOf('active') > -1;
const isActive = attrs && (!!attrs.active || attrs.active === '');

const header = createElement('li', {
staticClass: 'vnt-pivot__header',
Expand Down
23 changes: 22 additions & 1 deletion stories/components/pivot.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { storiesOf } from '@storybook/vue';

const items = [
{ label: 'Pivot 1', active: true, text: 'Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Curabitur et ligula. Ut molestie a, ultricies porta urna. Vestibulum commodo volutpat a, convallis ac, laoreet enim.' },
{ label: 'Pivot 2', active: false, text: 'Phasellus fermentum in, dolor. Pellentesque facilisis. Nulla imperdiet sit amet magna. Vestibulum dapibus, mauris nec malesuada fames ac turpis velit, rhoncus eu, luctus et interdum adipiscing wisi. Aliquam erat ac ipsum. Integer aliquam purus.' },
{ label: 'Pivot 3', active: false, text: 'Quisque lorem tortor fringilla sed, vestibulum id, eleifend justo vel bibendum sapien massa ac turpis faucibus orci luctus non, consectetuer lobortis quis, varius in, purus. Integer ultrices posuere cubilia Curae' }
];

const createData = () => ({
items
});

/* eslint no-undef: 0,
no-unused-vars: 0 */
storiesOf('Pivot', module)
Expand All @@ -26,4 +36,15 @@ storiesOf('Pivot', module)
Determines which tab should be set as active.
Must be added to \`vnt-pivot-item\` element that should be active at start.
`
});
})
.add('active', () => ({
data: () => createData(),
template: `
<span>
<vnt-pivot>
<vnt-pivot-item v-for="item in items" :key="item.label" :label="item.label" :active="item.active">
<p>{{ item.text }}</p>
</vnt-pivot-item>
</vnt-pivot>
</span>`
}));