Skip to content

Commit

Permalink
docs: add more story docs (#43)
Browse files Browse the repository at this point in the history
* add link & link-to stories
* add loader story
* add modal story
* add radio story
* add radio toggle story
* add switch story
* add select story
  • Loading branch information
jkusa authored Sep 30, 2020
1 parent 4a7d058 commit 4eebe67
Show file tree
Hide file tree
Showing 28 changed files with 397 additions and 212 deletions.
7 changes: 7 additions & 0 deletions addon/components/denali-link-enums.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Copyright 2020, Verizon Media
* Licensed under the terms of the MIT license. See accompanying LICENSE.md file for terms.
*/

export const STATES = ['default', 'active', 'disabled'];
export const SIZES = ['default', 'small'];
8 changes: 3 additions & 5 deletions addon/components/denali-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import Component from '@glimmer/component';
import { arg } from 'ember-arg-types';
import { boolean, oneOf, string } from 'prop-types';

const states = ['active', 'disabled'];
const sizes = ['small'];
import { SIZES, STATES } from './denali-link-enums';

export default class DenaliLinkComponent extends Component {
@arg(oneOf(states)) state;
@arg(oneOf(sizes)) size;
@arg(oneOf(STATES)) state;
@arg(oneOf(SIZES)) size;
@arg(boolean) isSecondary;
@arg(boolean) isSub;
@arg(string) iconFront;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
* Copyright 2020, Verizon Media
* Licensed under the terms of the MIT license. See accompanying LICENSE.md file for terms.
*/
import Route from '@ember/routing/route';

export default class DenaliLoaderRoute extends Route {}
export const SIZES = ['default', 'extrasmall', 'small', 'medium', 'large'];
2 changes: 1 addition & 1 deletion addon/components/denali-loader.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{{! Copyright 2020, Verizon Media. Licensed under the terms of the MIT license. See accompanying LICENSE.md file for terms. }}
<div class="loader {{this.sizeClass}} {{this.isInverseClass}}"></div>
<div class="loader {{this.sizeClass}} {{this.isInverseClass}}" ...attributes></div>
5 changes: 2 additions & 3 deletions addon/components/denali-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
import Component from '@glimmer/component';
import { arg } from 'ember-arg-types';
import { boolean, oneOf } from 'prop-types';

const sizes = ['extrasmall', 'small', 'medium', 'large'];
import { SIZES } from './denali-loader-enums';

export default class DenaliLoaderComponent extends Component {
@arg(oneOf(sizes))
@arg(oneOf(SIZES))
size;

@arg(boolean)
Expand Down
36 changes: 36 additions & 0 deletions stories/link-to.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { hbs } from 'ember-cli-htmlbars';
import { withKnobs, text } from '@storybook/addon-knobs';
import { argument, content, attribute } from './knob-categories';
export default {
title: 'DenaliLinkTo',
component: 'DenaliLinkTo',
decorators: [withKnobs],
};

export const Default = () => ({
template: hbs`
<DenaliLinkTo @route="index">
Denali Link To
</DenaliLinkTo>
`,
});

export const Playground = () => ({
template: hbs`
<DenaliLinkTo
@route="/"
@iconFront={{iconFront}}
@iconBack={{iconBack}}
class={{class}}
>
{{content}}
</DenaliLinkTo>
`,
context: {
route: text('route', 'index', argument),
iconFront: text('iconFront', 'home', argument),
iconBack: text('iconBack', '', argument),
content: text('content', 'Link To Home', content),
class: text('class', '', attribute),
},
});
45 changes: 45 additions & 0 deletions stories/link.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { hbs } from 'ember-cli-htmlbars';
import { withKnobs, boolean, text, select } from '@storybook/addon-knobs';
import { argument, content, attribute } from './knob-categories';
import { SIZES, STATES } from '../addon/components/denali-link-enums';

export default {
title: 'DenaliLink',
component: 'DenaliLink',
decorators: [withKnobs],
};

export const Default = () => ({
template: hbs`
<DenaliLink href="https://denali.design">
Denali Link
</DenaliLink>
`,
});

export const Playground = () => ({
template: hbs`
<DenaliLink
@iconFront={{iconFront}}
@iconBack={{iconBack}}
@state={{state}}
@size={{size}}
@isSecondary={{isSecondary}}
href={{href}}
class={{class}}
>
{{content}}
</DenaliLink>
`,
context: {
route: text('route', 'index', argument),
iconFront: text('iconFront', 'denali', argument),
iconBack: text('iconBack', '', argument),
size: select('size', SIZES, SIZES[0], argument),
state: select('state', STATES, STATES[0], argument),
isSecondary: boolean('isSecondary', false, argument),
href: text('href', 'https://denali.design', attribute),
class: text('class', '', attribute),
content: text('content', 'Denali Design', content),
},
});
31 changes: 31 additions & 0 deletions stories/loader.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { hbs } from 'ember-cli-htmlbars';
import { withKnobs, boolean, text, select } from '@storybook/addon-knobs';
import { argument, attribute } from './knob-categories';
import { SIZES } from '../addon/components/denali-loader-enums';

export default {
title: 'DenaliLoader',
component: 'DenaliLoader',
decorators: [withKnobs],
};

export const Default = () => ({
template: hbs`
<DenaliLoader />
`,
});

export const Playground = () => ({
template: hbs`
<DenaliLoader
@isInverse={{isInverse}}
@size={{size}}
class={{class}}
/>
`,
context: {
size: select('size', SIZES, SIZES[0], argument),
isInverse: boolean('isInverse', false, argument),
class: text('class', '', attribute),
},
});
51 changes: 51 additions & 0 deletions stories/modal.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { hbs } from 'ember-cli-htmlbars';
import { action } from '@storybook/addon-actions';
import { withKnobs, boolean, text } from '@storybook/addon-knobs';
import { argument, attribute, content } from './knob-categories';

export default {
title: 'DenaliModal',
component: 'DenaliModal',
decorators: [withKnobs],
};

export const Default = () => ({
template: hbs`
<DenaliModal @isOpen={{true}} as |Modal|>
<Modal.Header>{{headerContent}}</Modal.Header>
<Modal.Content>{{bodyContent}}</Modal.Content>
<Modal.Footer>{{footerContent}}</Modal.Footer>
</DenaliModal>
`,
context: {
headerContent: 'Modal Header',
bodyContent:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.',
footerContent: 'Modal Footer',
},
});

export const Playground = () => ({
template: hbs`
<DenaliModal
@isOpen={{isOpen}}
@isFullScreen={{isFullScreen}}
@onClose={{onClose}}
class={{class}}
as |Modal|
>
<Modal.Header>{{headerContent}}</Modal.Header>
<Modal.Content>{{bodyContent}}</Modal.Content>
<Modal.Footer>{{footerContent}}</Modal.Footer>
</DenaliModal>
`,
context: {
isOpen: boolean('isOpen', true, argument),
isFullScreen: boolean('isFullScreen', false, argument),
headerContent: text('headerContent', 'Modal Header', content),
bodyContent: text('bodyContent', 'Modal Body', content),
footerContent: text('footerContent', 'Modal Footer', content),
class: text('class', '', attribute),
onClose: action('onClose'),
},
});
64 changes: 64 additions & 0 deletions stories/radio-toggle.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { hbs } from 'ember-cli-htmlbars';
import { action } from '@storybook/addon-actions';
import { withKnobs, array, boolean, text } from '@storybook/addon-knobs';
import { argument, attribute, example } from './knob-categories';

export default {
title: 'DenaliRadioToggle',
component: 'DenaliRadioToggle',
decorators: [withKnobs],
};

export const Default = () => ({
template: hbs`
<DenaliRadioToggle
@onChanged={{queue onChange (fn (mut selectedItem))}}
as |Radio|
>
{{#each items as |item|}}
<Radio.Option
@value={{item}}
@checked={{eq item selectedItem}}
>
{{item}}
</Radio.Option>
{{/each}}
</DenaliRadioToggle>
`,
context: {
items: ['Denali', 'Radio'],
selectedItem: 'Denali',
onChange: action('onChange'),
},
});

export const Playground = () => ({
template: hbs`
<DenaliRadioToggle
@onChanged={{queue onChange (fn (mut selectedItem))}}
@isInverse={{isInverse}}
@isSmall={{isSmall}}
class={{class}}
as |Radio|
>
{{#each items as |item|}}
<Radio.Option
@value={{item}}
@checked={{eq item selectedItem}}
@disabled={{eq item disabledItem}}
>
{{item}}
</Radio.Option>
{{/each}}
</DenaliRadioToggle>
`,
context: {
isInverse: boolean('isInverse', false, argument),
isSmall: boolean('isSmall', false, argument),
items: array('items', ['Ember', 'Denali', 'Radio'], ',', example),
selectedItem: text('selectedItem', 'Denali', example),
disabledItem: text('disabledItem', 'Radio', example),
onChange: action('onChange'),
class: text('class', '', attribute),
},
});
60 changes: 60 additions & 0 deletions stories/radio.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { hbs } from 'ember-cli-htmlbars';
import { action } from '@storybook/addon-actions';
import { withKnobs, text, array } from '@storybook/addon-knobs';
import { attribute, example } from './knob-categories';

export default {
title: 'DenaliRadio',
component: 'DenaliRadio',
decorators: [withKnobs],
};

export const Default = () => ({
template: hbs`
<DenaliRadio
@onChanged={{queue onChange (fn (mut selectedItem))}}
as |Radio|
>
{{#each items as |item|}}
<Radio.Option
@value={{item}}
@checked={{eq item selectedItem}}
>
{{item}}
</Radio.Option>
{{/each}}
</DenaliRadio>
`,
context: {
items: ['Denali', 'Radio'],
selectedItem: 'Denali',
onChange: action('onChange'),
},
});

export const Playground = () => ({
template: hbs`
<DenaliRadio
@onChanged={{queue onChange (fn (mut selectedItem))}}
as |Radio|
>
{{#each items as |item|}}
<Radio.Option
@value={{item}}
@checked={{eq item selectedItem}}
@disabled={{eq item disabledItem}}
class={{class}}
>
{{item}}
</Radio.Option>
{{/each}}
</DenaliRadio>
`,
context: {
class: text('class', '', attribute),
items: array('items', ['Ember', 'Denali', 'Radio'], ',', example),
selectedItem: text('selectedItem', 'Denali', example),
disabledItem: text('disabledItem', 'Radio', example),
onChange: action('onChange'),
},
});
52 changes: 52 additions & 0 deletions stories/select.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { hbs } from 'ember-cli-htmlbars';
import { action } from '@storybook/addon-actions';
import { withKnobs, array, boolean, text } from '@storybook/addon-knobs';
import { argument, attribute, example } from './knob-categories';

export default {
title: 'DenaliSelect',
component: 'DenaliSelect',
decorators: [withKnobs],
};

export const Default = () => ({
template: hbs`
<DenaliSelect
@options={{items}}
@selectedOption={{selectedItem}}
@onChange={{queue onChange (fn (mut selectedItem))}}
as |item|>
{{item}}
</DenaliSelect>
`,
context: {
items: ['Denali', 'Select'],
selectedItem: 'Denali',
onChange: action('onChange'),
},
});

export const Playground = () => ({
template: hbs`
<DenaliSelect
@options={{items}}
@selectedOption={{selectedItem}}
@disabledOptions={{disabledItems}}
@isSmall={{isSmall}}
@isInverse={{isInverse}}
@onChange={{queue onChange (fn (mut selectedItem))}}
class={{class}}
as |item|>
{{item}}
</DenaliSelect>
`,
context: {
isSmall: boolean('isSmall', false, argument),
isInverse: boolean('isInverse', false, argument),
class: text('class', '', attribute),
items: array('items', ['Ember', 'Denali', 'Select'], ',', example),
selectedItem: text('selectedItem', 'Denali', example),
disabledItems: array('disabledItems', ['Select'], ',', example),
onChange: action('onChange'),
},
});
Loading

0 comments on commit 4eebe67

Please sign in to comment.