import { storiesOf } from '@storybook/angular'; import { withKnobs, text, number, boolean, array, select, color, date, button } from '@storybook/addon-knobs'; import { withNotes } from '@storybook/addon-notes'; import { action, configureActions } from '@storybook/addon-actions'; import { moduleMetadata } from '@storybook/angular'; import { PopupMenuModule } from '../../src/angular/popup-menu/popup-menu.module'; import { ButtonsModule } from '../../src/angular/buttons/buttons.module'; let stories = storiesOf('Menu', module) .addDecorator(withKnobs) .addDecorator(withNotes) .addDecorator( moduleMetadata({ declarations: [ ], imports: [ PopupMenuModule, ButtonsModule, ] }) ) let containsPosition = true; let containsRelative = true; let containsClassName = true; createMenuListStory(stories, "Menu list All options", containsPosition, containsRelative, containsClassName, "Menu list", "Full example of menu list."); createMenuListStory(stories, "Menu list with position", containsPosition, !containsRelative, !containsClassName, "Menu list", "Full example of menu list with position."); createMenuListStory(stories, "Menu list with relative", !containsPosition, containsRelative, !containsClassName, "Menu list", "Full example of menu list with relative."); createMenuListStory(stories, "Menu list with class", !containsPosition, !containsRelative, containsClassName, "Menu list", "Full example of menu list with class."); createMenuItemStory(stories, "Menu item All options", "Tabs", "Full example of simple tabs."); function createMenuListStory(stories, title, containsPosition, containsRelative, containsClassName, notesTitle, notesText){ stories.add(title, () => { const _className = containsClassName ? text('Class name', ''): null; const _relative = containsRelative ? boolean('Relative', true) : true; const _positionLeft = containsPosition ? number('Position left', 0): 0; const _positionTop = containsPosition ? number('Position top', 0): 0; const _open = containsPosition ? boolean('Menu list open', undefined): false; const _openChange = text('*(openChange)', 'Event throws when menu is open or close, see in Action logger tab.'); const _positionChange = text('*(positionChange)', 'Event throws when position changed, see in Action logger tab.'); return { props: { selectedItemValue: '', selectedItemColor: '', openChanged: action('Menu open status is'), positionChanged: action('Menu position changed to'), showSelectedItem: (itemPlace, color, selectedItem)=> { selectedItem.innerText = itemPlace; selectedItem.style.color = color; }, _className, _relative, _positionLeft, _positionTop, _open }, template: `