1
1
import React from "react" ;
2
- import { Button } from "./Button" ;
2
+ import { Button , ButtonWithLoading } from "." ;
3
+ import { WithLoadingProps } from "../../hoc/withLoading" ;
4
+ import { ButtonProps } from "./Button.styles" ;
3
5
4
6
export default {
5
7
title : "Components/Button" ,
6
8
component : Button ,
9
+ argTypes : {
10
+ variant : {
11
+ control : { type : "select" } ,
12
+ options : [ "primary" , "secondary" ] ,
13
+ } ,
14
+ isLoading : {
15
+ control : { type : "boolean" } ,
16
+ } ,
17
+ loadingText : {
18
+ control : { type : "text" } ,
19
+ } ,
20
+ children : {
21
+ control : { type : "text" } ,
22
+ } ,
23
+ } ,
7
24
} ;
8
25
9
- export const Primary = ( ) => < Button > Primary Button</ Button > ;
10
- export const Secondary = ( ) => < Button variant = "secondary" > Secondary Button</ Button > ;
26
+ const Template = ( args : React . JSX . IntrinsicAttributes & ButtonProps ) => < Button { ...args } /> ;
27
+ const LoadingTemplate = ( args : React . JSX . IntrinsicAttributes & WithLoadingProps & ButtonProps ) => < ButtonWithLoading { ...args } /> ;
28
+
29
+ export const Primary = Template . bind ( { } ) ;
30
+ Primary . args = {
31
+ children : "Primary Button" ,
32
+ variant : "primary" ,
33
+ } ;
34
+
35
+ export const Secondary = Template . bind ( { } ) ;
36
+ Secondary . args = {
37
+ children : "Secondary Button" ,
38
+ variant : "secondary" ,
39
+ } ;
40
+
41
+ export const WithLoading = LoadingTemplate . bind ( { } ) ;
42
+ WithLoading . args = {
43
+ children : "Secondary Button" ,
44
+ variant : "secondary" ,
45
+ isLoading : true ,
46
+ loadingText : "Loading..." ,
47
+ } ;
0 commit comments