File tree Expand file tree Collapse file tree 1 file changed +19
-13
lines changed
packages/gatsby-theme/src/components Expand file tree Collapse file tree 1 file changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -2,33 +2,39 @@ import React from 'react';
2
2
import { ButtonProps } from './shared/base.d' ;
3
3
import { Flex , Image , Button } from './shared/base' ;
4
4
5
- interface CustomButtonProps extends ButtonProps {
6
- type ?: string ;
7
- }
8
-
9
- export const CustomButton : React . FunctionComponent < CustomButtonProps > = ( {
10
- type,
11
- children,
12
- ...buttonProps
13
- } ) => {
5
+ export const CustomButton : React . FunctionComponent <
6
+ CustomButtonProps ,
7
+ { type ?: 'github' | 'tutorial' | 'spectrum' | 'default' }
8
+ > = ( { type, children, ...buttonProps } ) => {
14
9
const { icon, bg } = customButtonTypes [ type ] || customButtonTypes . default ;
15
- const text = children ;
16
10
17
11
if ( ! type ) {
18
- return < Button { ...buttonProps } > { text } </ Button > ;
12
+ return < Button { ...buttonProps } > { children } </ Button > ;
19
13
}
20
14
21
15
return (
22
16
< Button { ...buttonProps } bg = { buttonProps . bg || bg } >
23
17
< Flex alignItems = "center" p = { 0 } flexDirection = "row" >
24
18
< Image src = { icon } m = { 1 } />
25
- { text }
19
+ { children }
26
20
</ Flex >
27
21
</ Button >
28
22
) ;
29
23
} ;
30
24
31
- const customButtonTypes = {
25
+ interface ButtonType {
26
+ icon : string ;
27
+ bg : string ;
28
+ }
29
+
30
+ interface CustomButtonType {
31
+ tutorial : ButtonType ;
32
+ github : ButtonType ;
33
+ spectrum : ButtonType ;
34
+ default : ButtonType ;
35
+ }
36
+
37
+ const customButtonTypes : CustomButtonType = {
32
38
tutorial : {
33
39
icon : 'https://i.ibb.co/MBKTQ9b/Icon.png' ,
34
40
bg : 'primary' ,
You can’t perform that action at this time.
0 commit comments