-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Mui removed and basic functionality implemented * Put it in working state * button styles * Fix modal styling * Button component * Change checkbox selector * Add hover styles to buttons * bot suggestion * Add package-lock.json back in * switch span to p * Add dev data tags * preventDefault * Fix web3 select box * Correct svg attr * min and max width, margin * Make checkbox component. Address Hugh's review points
- Loading branch information
Showing
14 changed files
with
2,756 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { darkTheme, lightTheme } from './theme.js' | ||
import React, { ButtonHTMLAttributes, CSSProperties, useMemo, useState } from 'react' | ||
import addDataAttr from '../util/index.js' | ||
|
||
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
themeColor: 'light' | 'dark' | ||
buttonType: 'cancel' | 'next' | ||
onClick: () => void | ||
text: string | ||
} | ||
|
||
const buttonStyleBase: CSSProperties = { | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
position: 'relative', | ||
boxSizing: 'border-box', | ||
outline: '0px', | ||
border: '0px', | ||
margin: '0px', | ||
cursor: 'pointer', | ||
userSelect: 'none', | ||
verticalAlign: 'middle', | ||
appearance: undefined, | ||
textDecoration: 'none', | ||
fontWeight: '500', | ||
fontSize: '0.875rem', | ||
lineHeight: '1.75', | ||
letterSpacing: '0.02857em', | ||
textTransform: 'uppercase', | ||
minWidth: '64px', | ||
padding: '6px 16px', | ||
borderRadius: '4px', | ||
transition: | ||
'background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms', | ||
color: 'rgb(0, 0, 0)', | ||
backgroundColor: '#ffffff', | ||
boxShadow: | ||
'rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px', | ||
} | ||
|
||
const Button: React.FC<ButtonProps> = ({ themeColor, buttonType, text, onClick }: ButtonProps) => { | ||
const theme = useMemo(() => (themeColor === 'light' ? lightTheme : darkTheme), [themeColor]) | ||
const [hover, setHover] = useState(false) | ||
const buttonStyle = useMemo(() => { | ||
const baseStyle = { | ||
...buttonStyleBase, | ||
color: hover ? theme.palette.primary.contrastText : theme.palette.background.contrastText, | ||
} | ||
if (buttonType === 'cancel') { | ||
return { | ||
...baseStyle, | ||
backgroundColor: hover ? theme.palette.grey[600] : 'transparent', | ||
} | ||
} else { | ||
return { | ||
...baseStyle, | ||
backgroundColor: hover ? theme.palette.primary.main : theme.palette.background.default, | ||
} | ||
} | ||
}, [buttonType, hover, theme]) | ||
|
||
return ( | ||
<button | ||
{...addDataAttr({ dev: { cy: `button-${buttonType}` } })} | ||
onMouseEnter={() => setHover(true)} | ||
onMouseLeave={() => setHover(false)} | ||
style={buttonStyle} | ||
onClick={(e) => { | ||
e.preventDefault() | ||
onClick() | ||
}} | ||
> | ||
{text} | ||
</button> | ||
) | ||
} | ||
export default Button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.