11import { createUseStyles } from 'react-jss'
2- import { ReactElement , ReactNode , CSSProperties , ElementType } from 'react'
2+ import type { ReactElement , ReactNode , CSSProperties , ElementType , MouseEventHandler } from 'react'
33
44import Typography from './Typography'
55import { colors } from './css'
@@ -31,6 +31,28 @@ const useStyles = createUseStyles({
3131 transition : '0.1s' ,
3232 } ,
3333 } ,
34+ '& > *:not(:last-child)' : {
35+ marginRight : 10 ,
36+ display : 'flex' ,
37+ justifyContent : 'center' ,
38+ alignItems : 'center' ,
39+ } ,
40+ } ,
41+ light : {
42+ color : colors . text . normal ,
43+ backgroundColor : colors . white ,
44+ padding : 8 ,
45+ cursor : 'pointer' ,
46+ '& svg' : {
47+ fill : colors . text . normal ,
48+ } ,
49+ '&:hover, &:active' : {
50+ backgroundColor : colors . lightOrange ,
51+ color : colors . swarmOrange ,
52+ '& svg' : {
53+ fill : colors . swarmOrange ,
54+ } ,
55+ } ,
3456 } ,
3557 disabled : {
3658 color : colors . text . normal ,
@@ -42,27 +64,19 @@ const useStyles = createUseStyles({
4264 '&:hover, &:active' : {
4365 color : colors . text . normal ,
4466 backgroundColor : colors . surface . lightGray ,
45- transition : '0.1s' ,
4667 '& svg' : {
4768 fill : colors . text . normal ,
48- transition : '0.1s' ,
4969 } ,
5070 } ,
5171 } ,
52- icon : {
53- marginRight : 10 ,
54- display : 'flex' ,
55- justifyContent : 'center' ,
56- alignItems : 'center' ,
57- } ,
5872} )
5973
6074interface Props {
61- variant : 'primary' | 'secondary'
62- children : ReactNode
75+ variant : 'primary' | 'secondary' | 'light'
76+ children ? : ReactNode
6377 icon ?: ReactElement
6478 style ?: CSSProperties
65- onClick ?: ( ) => void
79+ onClick ?: MouseEventHandler
6680 className ?: string
6781 component ?: ElementType
6882 disabled ?: boolean
@@ -73,15 +87,19 @@ const Button = ({ variant, children, style, onClick, icon, className, component,
7387
7488 const DefaultComponent : ElementType = component || 'div'
7589
90+ let variantClass = ''
91+
92+ if ( variant === 'light' ) variantClass = classes . light
93+
7694 return (
77- < Typography variant = " button" style = { style } className = { className } >
95+ < Typography variant = { variant === 'light' ? 'code' : ' button' } style = { style } className = { className } >
7896 < DefaultComponent
79- className = { `${ classes . common } ${ disabled ? classes . disabled : '' } ` }
97+ className = { `${ classes . common } ${ variantClass } ${ disabled ? classes . disabled : '' } ` }
8098 onClick = { disabled ? undefined : onClick }
8199 disabled = { disabled }
82100 >
83- { icon ? < div className = { classes . icon } > { icon } </ div > : null }
84- { children }
101+ { icon }
102+ { children ? < span > { children } </ span > : null }
85103 </ DefaultComponent >
86104 </ Typography >
87105 )
0 commit comments