|
| 1 | +import { storiesOf, moduleMetadata } from "@storybook/angular"; |
| 2 | +import { withNotes } from "@storybook/addon-notes"; |
| 3 | +import { action } from "@storybook/addon-actions"; |
| 4 | +import { withKnobs, boolean, object } from "@storybook/addon-knobs/angular"; |
| 5 | + |
| 6 | +import { Component } from "@angular/core"; |
| 7 | + |
| 8 | +import { TranslateModule } from "@ngx-translate/core"; |
| 9 | + |
| 10 | +import { BannerModule, BannerService } from "../"; |
| 11 | + |
| 12 | + |
| 13 | +@Component({ |
| 14 | + selector: "app-banner-story", |
| 15 | + template: ` |
| 16 | + <button class="bx--btn bx--btn--primary" (click)="showBanner()">Show info banner</button> |
| 17 | + <div class="banner-container"></div> |
| 18 | + `, |
| 19 | + providers: [BannerService] |
| 20 | +}) |
| 21 | +class BannnerStory { |
| 22 | + |
| 23 | + constructor(private bannerService: BannerService) { } |
| 24 | + |
| 25 | + showBanner() { |
| 26 | + this.bannerService.showBanner({ |
| 27 | + type: "info", |
| 28 | + title: "Sample banner", |
| 29 | + message: "Sample info message", |
| 30 | + target: ".banner-container" |
| 31 | + }); |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +storiesOf("Banner", module) |
| 36 | + .addDecorator( |
| 37 | + moduleMetadata({ |
| 38 | + declarations: [ |
| 39 | + BannnerStory |
| 40 | + ], |
| 41 | + imports: [ |
| 42 | + BannerModule, |
| 43 | + TranslateModule.forRoot() |
| 44 | + ] |
| 45 | + }) |
| 46 | + ) |
| 47 | + .addDecorator(withKnobs) |
| 48 | + .add("Basic", () => ({ |
| 49 | + template: ` |
| 50 | + <ibm-banner [bannerObj]="{type: 'error', title: 'Sample banner', message: 'Sample error message'}"></ibm-banner> |
| 51 | + <ibm-banner [bannerObj]="{type: 'info', title: 'Sample banner', message: 'Sample info message'}"></ibm-banner> |
| 52 | + <ibm-banner [bannerObj]="{type: 'success', title: 'Sample banner', message: 'Sample success message'}"></ibm-banner> |
| 53 | + <ibm-banner [bannerObj]="{type: 'warning', title: 'Sample banner', message: 'Sample warning message'}"></ibm-banner> |
| 54 | + ` |
| 55 | + })) |
| 56 | + .add("Dynamic", () => ({ |
| 57 | + template: ` |
| 58 | + <app-banner-story></app-banner-story> |
| 59 | + ` |
| 60 | + })) |
| 61 | + .add("Toast", () => ({ |
| 62 | + template: ` |
| 63 | + <h4>Coming soon</h4> |
| 64 | + <em>Teaser ...</em> |
| 65 | + <div class="bx--toast-notification bx--toast-notification--info" role="alert"> |
| 66 | + <div class="bx--toast-notification__details"> |
| 67 | + <h3 class="bx--toast-notification__title">Notification title</h3> |
| 68 | + <p class="bx--toast-notification__subtitle">Subtitle text goes here.</p> |
| 69 | + <p class="bx--toast-notification__caption">Time stamp [00:00:00]</p> |
| 70 | + </div> |
| 71 | + <button class="bx--toast-notification__close-button" type="button"> |
| 72 | + <svg |
| 73 | + class="bx--toast-notification-icon" |
| 74 | + aria-label="close" |
| 75 | + width="10" |
| 76 | + height="10" |
| 77 | + viewBox="0 0 10 10" |
| 78 | + xmlns="http://www.w3.org/2000/svg"> |
| 79 | + <path d="M6.32 5L10 8.68 8.68 10 5 6.32 1.32 10 0 8.68 3.68 5 0 1.32 1.32 0 5 3.68 8.68 0 10 1.32 6.32 5z" fill-rule="nonzero"/> |
| 80 | + </svg> |
| 81 | + </button> |
| 82 | + </div> |
| 83 | + ` |
| 84 | + })); |
0 commit comments