diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2018-11-09 03:19:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 03:19:51 +0800 |
commit | b388d5496272d535b5c192a7098f4227bb1fb3f2 (patch) | |
tree | 2b1deb57dcddf1c52bb7155836971be52d0b9fa3 /packages/instant/src/components/ui/button.tsx | |
parent | adcfe51190c8ca5cd4d11e49eb7e100c80fbd16c (diff) | |
parent | c27194a35783d966b27deeb1654a077b8c1ba1c8 (diff) | |
download | dexon-sol-tools-b388d5496272d535b5c192a7098f4227bb1fb3f2.tar dexon-sol-tools-b388d5496272d535b5c192a7098f4227bb1fb3f2.tar.gz dexon-sol-tools-b388d5496272d535b5c192a7098f4227bb1fb3f2.tar.bz2 dexon-sol-tools-b388d5496272d535b5c192a7098f4227bb1fb3f2.tar.lz dexon-sol-tools-b388d5496272d535b5c192a7098f4227bb1fb3f2.tar.xz dexon-sol-tools-b388d5496272d535b5c192a7098f4227bb1fb3f2.tar.zst dexon-sol-tools-b388d5496272d535b5c192a7098f4227bb1fb3f2.zip |
Merge pull request #1220 from 0xProject/feature/instant/prevent-css-leakage
[instant] Prevent CSS leakage
Diffstat (limited to 'packages/instant/src/components/ui/button.tsx')
-rw-r--r-- | packages/instant/src/components/ui/button.tsx | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/packages/instant/src/components/ui/button.tsx b/packages/instant/src/components/ui/button.tsx index 5274d835b..b90221bf4 100644 --- a/packages/instant/src/components/ui/button.tsx +++ b/packages/instant/src/components/ui/button.tsx @@ -6,6 +6,8 @@ import { ColorOption, styled } from '../../style/theme'; export interface ButtonProps { backgroundColor?: ColorOption; borderColor?: ColorOption; + fontColor?: ColorOption; + fontSize?: string; width?: string; padding?: string; type?: string; @@ -24,29 +26,39 @@ const darkenOnHoverAmount = 0.1; const darkenOnActiveAmount = 0.2; const saturateOnFocusAmount = 0.2; export const Button = styled(PlainButton)` - cursor: ${props => (props.isDisabled ? 'default' : 'pointer')}; - transition: background-color, opacity 0.5s ease; - padding: ${props => props.padding}; - border-radius: 3px; - outline: none; - width: ${props => props.width}; - background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; - border: ${props => (props.borderColor ? `1px solid ${props.theme[props.borderColor]}` : 'none')}; - &:hover { - background-color: ${props => - !props.isDisabled - ? darken(darkenOnHoverAmount, props.theme[props.backgroundColor || 'white']) - : ''} !important; - } - &:active { - background-color: ${props => - !props.isDisabled ? darken(darkenOnActiveAmount, props.theme[props.backgroundColor || 'white']) : ''}; - } - &:disabled { - opacity: 0.5; - } - &:focus { - background-color: ${props => saturate(saturateOnFocusAmount, props.theme[props.backgroundColor || 'white'])}; + && { + all: initial; + box-sizing: border-box; + font-size: ${props => props.fontSize}; + font-family: 'Inter UI', sans-serif; + font-weight: 600; + color: ${props => props.fontColor && props.theme[props.fontColor]}; + cursor: ${props => (props.isDisabled ? 'default' : 'pointer')}; + transition: background-color, opacity 0.5s ease; + padding: ${props => props.padding}; + border-radius: 3px; + text-align: center; + outline: none; + width: ${props => props.width}; + background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')}; + border: ${props => (props.borderColor ? `1px solid ${props.theme[props.borderColor]}` : 'none')}; + &:hover { + background-color: ${props => + !props.isDisabled + ? darken(darkenOnHoverAmount, props.theme[props.backgroundColor || 'white']) + : ''} !important; + } + &:active { + background-color: ${props => + !props.isDisabled ? darken(darkenOnActiveAmount, props.theme[props.backgroundColor || 'white']) : ''}; + } + &:disabled { + opacity: 0.5; + } + &:focus { + background-color: ${props => + saturate(saturateOnFocusAmount, props.theme[props.backgroundColor || 'white'])}; + } } `; @@ -55,7 +67,8 @@ Button.defaultProps = { borderColor: ColorOption.primaryColor, width: 'auto', isDisabled: false, - padding: '1em 2.2em', + padding: '.6em 1.2em', + fontSize: '15px', }; Button.displayName = 'Button'; |