Skip to content

Commit

Permalink
feat: add CvButtonSkeleton component (carbon-design-system#213)
Browse files Browse the repository at this point in the history
* feat: add CvButtonSkeleton component

* docs: add a story for CvButtonSkeleton component
  • Loading branch information
sabov authored and dcwarwick committed Mar 18, 2019
1 parent 26c54e1 commit 037ab83
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 3 deletions.
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 },
}
);
}

0 comments on commit 037ab83

Please sign in to comment.