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: `
Click in the box...
(popup menu is {{menuStatus === undefined ? 'never opened' : (menuStatus ? 'open at '+menuPos.x+' , '+menuPos.y : 'closed')}})
selected: {{selectedItemValue}}
First Disabled Second Third (none)
` } }, { notes: `

` + notesTitle + `

` + notesText + `
Use the KNOBS tab to change values.` } ) } function createMenuItemStory (stories, title, notesTitle, notesText){ stories.add(title, () => { const _item1ClassName = text('Item1 class name', ''); const _item1Type = text('Item1 type', ''); const _item2ClassName = text('Item2 class name', ''); const _item2Type = text('Item2 type', 'selected'); const _item3ClassName = text('Item3 class name', ''); const _item3Type = text('Item3 type', 'disabled'); const _item4ClassName = text('Item4 class name', ''); const _item4Type = text('Item4 type', 'separator'); const _item5ClassName = text('Item5 class name', ''); const _item5Type = text('Item5 type', ''); const _Action = text('*(action)', 'Event throws when select tab changed, see in Action logger tab.'); return { props: { openManu: (menu) =>{ menu.position = {x:400, y:500}; menu.open = true; }, showSelectedItem: action('select menu item'), _item1ClassName, _item1Type, _item2ClassName, _item2Type, _item3ClassName, _item3Type, _item4ClassName, _item4Type, _item5ClassName, _item5Type }, template: `


First Selected Disabled Second
` } }, { notes: `

` + notesTitle + `

` + notesText + `
Use the KNOBS tab to change values.` } ) }