aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-tools-pages/ts/components/ui/button.tsx
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-10-10 23:22:31 +0800
committerFabio Berger <me@fabioberger.com>2018-10-10 23:22:31 +0800
commitfb882b0c7710151af7024c510d853f828a54f43a (patch)
tree6260f0088cb551cb5f28f8990607d76bb0187281 /packages/dev-tools-pages/ts/components/ui/button.tsx
parent6c0d31738062b113bd34b5438a2e3c8bfbfb385b (diff)
downloaddexon-0x-contracts-fb882b0c7710151af7024c510d853f828a54f43a.tar.gz
dexon-0x-contracts-fb882b0c7710151af7024c510d853f828a54f43a.tar.zst
dexon-0x-contracts-fb882b0c7710151af7024c510d853f828a54f43a.zip
Add stuff
Diffstat (limited to 'packages/dev-tools-pages/ts/components/ui/button.tsx')
-rw-r--r--packages/dev-tools-pages/ts/components/ui/button.tsx60
1 files changed, 60 insertions, 0 deletions
diff --git a/packages/dev-tools-pages/ts/components/ui/button.tsx b/packages/dev-tools-pages/ts/components/ui/button.tsx
new file mode 100644
index 000000000..7b2e33141
--- /dev/null
+++ b/packages/dev-tools-pages/ts/components/ui/button.tsx
@@ -0,0 +1,60 @@
+import { darken, saturate } from 'polished';
+import * as React from 'react';
+import styled from 'styled-components';
+
+import { Container } from './container';
+
+export interface ButtonProps {
+ backgroundColor?: string;
+ borderColor?: string;
+ width?: string;
+ padding?: string;
+ type?: string;
+ isDisabled?: boolean;
+ onClick?: (event: React.MouseEvent<HTMLElement>) => void;
+ className?: string;
+}
+
+const PlainButton: React.StatelessComponent<ButtonProps> = ({ children, isDisabled, onClick, type, className }) => (
+ <button type={type} className={className} onClick={isDisabled ? undefined : onClick} disabled={isDisabled}>
+ {children}
+ </button>
+);
+
+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'])};
+ }
+`;
+
+Button.defaultProps = {
+ backgroundColor: 'black',
+ width: 'auto',
+ isDisabled: false,
+ padding: '1em 2.2em',
+};
+Button.displayName = 'Button';