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

feat: add CvButtonSkeleton component #213

Merged
merged 4 commits into from
Feb 18, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/components/cv-button/cv-button-skeleton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<button
disabled
class="bx--btn bx--skeleton"
:class="{ 'bx--btn--sm': small }"
type="button"
></button>
</template>

<script>
export default {
name: 'CvButtonSkeleton',
props: {
small: { type: Boolean, default: false },
},
};
</script>

<style lang="scss"></style>
57 changes: 54 additions & 3 deletions src/components/cv-button/cv-button-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import knobsHelper from '../../_storybook/utils/knobs-helper';

import CvButtonNotesMD from './cv-button-notes.md';
import CvButton from './cv-button';
import CvButtonSkeleton from './cv-button-skeleton';

const stories = storiesOf('CvButton', module);
stories.addDecorator(withKnobs);
stories.addDecorator(withNotes);

const exampleIconPath = require('../../assets/images/example-icons.svg');

const preKnobs = {
let preKnobs = {
small: {
group: 'attr',
type: boolean,
Expand Down Expand Up @@ -58,7 +59,7 @@ const preKnobs = {
},
};

const variants = [
let variants = [
{ name: 'default' },
{ name: 'minimal', excludes: ['small', 'disabled', 'iconHref'] },
{
Expand Down Expand Up @@ -87,7 +88,7 @@ const variants = [
},
];

const storySet = knobsHelper.getStorySet(variants, preKnobs);
let storySet = knobsHelper.getStorySet(variants, preKnobs);

for (const story of storySet) {
stories.add(
Expand Down Expand Up @@ -126,3 +127,53 @@ for (const story of storySet) {
}
);
}

// cv-button-skeleton

preKnobs = {
small: {
group: 'attr',
type: boolean,
config: ['small', false], // consts.CONFIG], // fails when used with number in storybook 4.1.4
prop: {
name: 'small',
type: Boolean,
},
},
};

variants = [{ name: 'skeleton' }];

storySet = knobsHelper.getStorySet(variants, preKnobs);

for (const story of storySet) {
stories.add(
story.name,
() => {
const settings = story.knobs();

const templateString = `
<cv-button-skeleton${settings.group.attr}></cv-button-skeleton>
`;

// ----------------------------------------------------------------

const templateViewString = `
<sv-template-view
sv-margin
sv-source='${templateString.trim()}'>
<template slot="component">${templateString}</template>
</sv-template-view>
`;

return {
components: { CvButtonSkeleton, SvTemplateView },
template: templateViewString,
props: settings.props,
};
},
{
notes: { markdown: CvButtonNotesMD },
}
);
}