@@ -13,41 +13,45 @@ import { ThemeContext, ThemeType } from '../../theme';
1313import { Button } from '../button/button.component' ;
1414import { Icon } from '../icon/icon.component' ;
1515import { FabProps } from './fab.type' ;
16+ import { withDefaultProps } from '../../utilities/withDefaultProps' ;
1617
1718interface FabState {
1819 active : boolean ;
1920}
2021
21- class Fab extends React . Component < FabProps , FabState > {
22- static defaultProps : Partial < FabProps > = {
23- color : 'white' ,
24- fontSize : '4xl' ,
25- p : 18 ,
26- overlayColor : 'gray900' ,
27- overlayOpacity : 0.5 ,
28- position : 'absolute' ,
29- openOnMount : false ,
30- showBackground : true ,
31- animated : true ,
32- bottom : 30 ,
33- right : 30 ,
34- icon : 'plus' ,
35- activeIcon : 'close' ,
36- rounded : 'circle' ,
37- bg : 'blue500' ,
38- useNativeDriver : false ,
39- shadow : 'lg' ,
40- shadowColor : 'gray900' ,
41- } ;
42-
22+ const defaultProps = {
23+ color : 'white' ,
24+ fontSize : '4xl' ,
25+ p : 18 ,
26+ overlayColor : 'gray900' ,
27+ overlayOpacity : 0.5 ,
28+ position : 'absolute' ,
29+ openOnMount : false ,
30+ showBackground : true ,
31+ animated : true ,
32+ bottom : 30 ,
33+ right : 30 ,
34+ icon : 'plus' ,
35+ activeIcon : 'close' ,
36+ rounded : 'circle' ,
37+ bg : 'blue500' ,
38+ useNativeDriver : false ,
39+ shadow : 'lg' ,
40+ shadowColor : 'gray900' ,
41+ } as const ;
42+
43+ class FabBase extends React . Component <
44+ FabProps & typeof defaultProps ,
45+ FabState
46+ > {
4347 animation : any ;
4448 fadeAnimation : any ;
4549 visibleAnimation : any ;
4650 actionsAnimation : any ;
4751 mainBottomAnimation : any ;
4852 actionsBottomAnimation : any ;
4953
50- constructor ( props : FabProps ) {
54+ constructor ( props : FabProps & typeof defaultProps ) {
5155 super ( props ) ;
5256
5357 this . state = {
@@ -363,4 +367,6 @@ class Fab extends React.Component<FabProps, FabState> {
363367 }
364368}
365369
370+ const Fab = withDefaultProps < FabProps > ( FabBase , 'Fab' ) ( defaultProps ) ;
371+
366372export { Fab } ;
0 commit comments