File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { ComponentMeta , Story } from "@storybook/react"
2
+ import React from "react"
3
+ import { FormFooter , FormFooterProps } from "./FormFooter"
4
+
5
+ export default {
6
+ title : "components/FormFooter" ,
7
+ component : FormFooter ,
8
+ argTypes :{
9
+ onCancel : { action : "cancel" }
10
+ }
11
+ } as ComponentMeta < typeof FormFooter >
12
+
13
+ const Template : Story < FormFooterProps > = ( args ) => < FormFooter { ...args } />
14
+
15
+ export const Ready = Template . bind ( { } )
16
+ Ready . args = {
17
+ isLoading : false ,
18
+ }
19
+
20
+ export const Custom = Template . bind ( { } )
21
+ Custom . args = {
22
+ isLoading : false ,
23
+ submitLabel : "Create" ,
24
+ }
25
+
26
+ export const Loading = Template . bind ( { } )
27
+ Loading . args = {
28
+ isLoading : true ,
29
+ }
Original file line number Diff line number Diff line change
1
+ import Button from "@material-ui/core/Button"
2
+ import { makeStyles } from "@material-ui/core/styles"
3
+ import React from "react"
4
+ import { LoadingButton } from "../LoadingButton/LoadingButton"
5
+
6
+ export interface FormFooterProps {
7
+ onCancel : ( ) => void
8
+ isLoading : boolean
9
+ submitLabel ?: string
10
+ }
11
+
12
+ const useStyles = makeStyles ( ( ) => ( {
13
+ footer : {
14
+ display : "flex" ,
15
+ flex : "0" ,
16
+ flexDirection : "row" ,
17
+ justifyContent : "center" ,
18
+ alignItems : "center" ,
19
+ } ,
20
+ button : {
21
+ margin : "1em" ,
22
+ } ,
23
+ } ) )
24
+
25
+ export const FormFooter : React . FC < FormFooterProps > = ( { onCancel, isLoading, submitLabel = "Submit" } ) => {
26
+ const styles = useStyles ( )
27
+ return (
28
+ < div className = { styles . footer } >
29
+ < Button className = { styles . button } onClick = { onCancel } variant = "outlined" >
30
+ Cancel
31
+ </ Button >
32
+ < LoadingButton loading = { isLoading } className = { styles . button } variant = "contained" color = "primary" type = "submit" >
33
+ { submitLabel }
34
+ </ LoadingButton >
35
+ </ div >
36
+ )
37
+ }
You can’t perform that action at this time.
0 commit comments