Skip to content

Commit e216523

Browse files
authored
Merge pull request #2376 from Akshat55/button-docs
docs: Add click event action
2 parents 0d1c99f + 58061a8 commit e216523

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/button/button.stories.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { storiesOf, moduleMetadata } from "@storybook/angular";
2+
import { action } from "@storybook/addon-actions";
23
import { withKnobs, select, boolean } from "@storybook/addon-knobs/angular";
34

45
import { ButtonModule } from "./button.module";
@@ -18,17 +19,17 @@ storiesOf("Components|Button", module)
1819
.addDecorator(withKnobs)
1920
.add("Basic", () => ({
2021
template: `
21-
<button [ibmButton]="ibmButton" [size]="size" [isExpressive]="isExpressive">Button</button>
22+
<button [ibmButton]="ibmButton" (click)="click($event)" [size]="size" [isExpressive]="isExpressive">Button</button>
2223
&nbsp;
23-
<button [ibmButton]="ibmButton" [size]="size" [isExpressive]="isExpressive" disabled="true">Button</button>
24+
<button [ibmButton]="ibmButton" (click)="click($event)" [size]="size" [isExpressive]="isExpressive" disabled="true">Button</button>
2425
&nbsp;
25-
<button [ibmButton]="ibmButton" [size]="size" [isExpressive]="isExpressive">
26+
<button [ibmButton]="ibmButton" (click)="click($event)" [size]="size" [isExpressive]="isExpressive">
2627
With icon<svg class="bx--btn__icon" ibmIcon="add" size="16"></svg>
2728
</button>
2829
<br><br>
2930
<ibm-button-set>
30-
<button ibmButton="secondary" [size]="size" [isExpressive]="isExpressive">Button</button>
31-
<button [ibmButton]="ibmButton" [size]="size" [isExpressive]="isExpressive">Button</button>
31+
<button ibmButton="secondary" (click)="click($event)" [size]="size" [isExpressive]="isExpressive">Button</button>
32+
<button [ibmButton]="ibmButton" (click)="click($event)" [size]="size" [isExpressive]="isExpressive">Button</button>
3233
</ibm-button-set>
3334
`,
3435
props: {
@@ -37,7 +38,8 @@ storiesOf("Components|Button", module)
3738
["primary", "secondary", "tertiary", "ghost", "danger", "danger--primary", "danger--tertiary", "danger--ghost"],
3839
"primary"),
3940
isExpressive: boolean("Expressive button style", false),
40-
size: select("Size of the buttons", ["normal", "sm", "field", "lg", "xl"], "normal")
41+
size: select("Size of the buttons", ["normal", "sm", "field", "lg", "xl"], "normal"),
42+
click: action("button clicked!")
4143
}
4244
}))
4345
.add("Icon only", () => ({
@@ -48,7 +50,8 @@ storiesOf("Components|Button", module)
4850
[iconOnly]="true"
4951
[hasAssistiveText]="true"
5052
[assistiveTextPlacement]="assistiveTextPlacement"
51-
[assistiveTextAlignment]="assistiveTextAlignment">
53+
[assistiveTextAlignment]="assistiveTextAlignment"
54+
(click)="click($event)">
5255
<svg class="bx--btn__icon" ibmIcon="copy" size="16"></svg>
5356
<span class="bx--assistive-text">Icon description</span>
5457
</button>
@@ -60,7 +63,8 @@ storiesOf("Components|Button", module)
6063
"tertiary"),
6164
size: select("Size of the buttons", ["normal", "sm", "field", "lg", "xl"], "normal"),
6265
assistiveTextPlacement: select("Placement of assistive text", ["top", "bottom", "left", "right"], "top"),
63-
assistiveTextAlignment: select("Alignment of assistive text", ["center", "start", "end"], "center")
66+
assistiveTextAlignment: select("Alignment of assistive text", ["center", "start", "end"], "center"),
67+
click: action("button clicked!")
6468
}
6569
}))
6670
.add("Skeleton", () => ({

0 commit comments

Comments
 (0)