@@ -5,48 +5,85 @@ import { createUseStyles, useTheme } from "react-jss";
55type ButtonProps = {
66 onClick ?: ( ) => void ,
77 name : string ,
8- style ?: string ,
8+ disabled ?: boolean ,
9+ type ?: string ,
910} ;
1011
1112export type ButtonStyleProps = {
1213 color ?: string ,
14+ margin ?: string ,
15+ marginRight ?: string ,
16+ marginLeft ?: string ,
17+ marginTop ?: string ,
18+ marginBottom ?: string ,
1319} ;
1420export function Button ( {
1521 onClick,
1622 name,
23+ disabled,
1724 color,
18- style,
25+ margin,
26+ marginBottom,
27+ marginLeft,
28+ marginRight,
29+ marginTop,
30+ type,
1931} : ButtonProps & ButtonStyleProps ) : React . Node {
2032 const theme = useTheme ( ) ;
21- const classes = useButtonStyles ( { color } ) ;
33+ const classes = useButtonStyles ( {
34+ color,
35+ disabled,
36+ margin,
37+ marginTop,
38+ marginBottom,
39+ marginLeft,
40+ marginRight,
41+ } ) ;
2242
2343 return (
24- < button type = "button" onClick = { onClick } className = { style && classes [ style ] } >
44+ < button
45+ type = "button"
46+ onClick = { onClick }
47+ className = { [ type && classes [ type ] , classes . common ] . join ( " " ) }
48+ disabled = { disabled }
49+ >
2550 { name }
2651 </ button >
2752 ) ;
2853}
2954
3055Button . defaultProps = {
31- style : "button" ,
56+ type : "button" ,
3257} ;
3358
3459export const useButtonStyles : ( ButtonStyleProps ) => {
3560 button : string ,
61+ common : string ,
3662 link : string ,
3763} = createUseStyles ( ( theme ) => {
3864 return {
3965 button : {
4066 background : theme . button . primary ,
41- borderRadius : "10px " ,
67+ borderRadius : "0.75rem " ,
4268 borderStyle : "none" ,
4369 color : ( { color } ) => color || theme . button . color ,
70+ opacity : ( { disabled } ) => ( disabled ? 0.5 : 1 ) ,
71+ } ,
72+ common : {
73+ fontSize : "1rem" ,
74+ margin : ( { margin } ) => margin ,
75+ marginLeft : ( { marginLeft } ) => marginLeft ,
76+ marginRight : ( { marginRight } ) => marginRight ,
77+ marginTop : ( { marginTop } ) => marginTop ,
78+ marginBottom : ( { marginBottom } ) => marginBottom ,
4479 } ,
4580 link : {
4681 border : 0 ,
4782 background : "inherit" ,
4883 textDecoration : "underline" ,
4984 color : ( { color } ) => color || theme . button . primary ,
85+ opacity : ( { disabled } ) => ( disabled ? 0.5 : 1 ) ,
86+ padding : 0 ,
5087 } ,
5188 } ;
5289} ) ;
0 commit comments