aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components/ui/icon.tsx
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-11-02 06:23:42 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-11-02 06:25:34 +0800
commitd16499da4e0611438df7bfe226bce940beca6918 (patch)
tree59affb762069db178050928fa826062244f4a1e8 /packages/instant/src/components/ui/icon.tsx
parentc2645b26b457c66b3adcb98a5c089eba3e72f458 (diff)
downloaddexon-sol-tools-d16499da4e0611438df7bfe226bce940beca6918.tar
dexon-sol-tools-d16499da4e0611438df7bfe226bce940beca6918.tar.gz
dexon-sol-tools-d16499da4e0611438df7bfe226bce940beca6918.tar.bz2
dexon-sol-tools-d16499da4e0611438df7bfe226bce940beca6918.tar.lz
dexon-sol-tools-d16499da4e0611438df7bfe226bce940beca6918.tar.xz
dexon-sol-tools-d16499da4e0611438df7bfe226bce940beca6918.tar.zst
dexon-sol-tools-d16499da4e0611438df7bfe226bce940beca6918.zip
Remove alternate hover styling from button and move into icon component
Diffstat (limited to 'packages/instant/src/components/ui/icon.tsx')
-rw-r--r--packages/instant/src/components/ui/icon.tsx69
1 files changed, 48 insertions, 21 deletions
diff --git a/packages/instant/src/components/ui/icon.tsx b/packages/instant/src/components/ui/icon.tsx
index a05017ba1..f12059cff 100644
--- a/packages/instant/src/components/ui/icon.tsx
+++ b/packages/instant/src/components/ui/icon.tsx
@@ -1,5 +1,8 @@
+import * as _ from 'lodash';
import * as React from 'react';
+import { styled } from '../../style/theme';
+
type svgRule = 'evenodd' | 'nonzero' | 'inherit';
interface IconInfo {
viewBox: string;
@@ -52,33 +55,57 @@ const ICONS: IconInfoMapping = {
};
export interface IconProps {
+ className?: string;
width: number;
height?: number;
color?: string;
icon: keyof IconInfoMapping;
+ onClick?: (event: React.MouseEvent<HTMLElement>) => void;
+ padding?: string;
}
-export const Icon: React.SFC<IconProps> = props => {
+const PlainIcon: React.SFC<IconProps> = props => {
const iconInfo = ICONS[props.icon];
-
return (
- <svg
- width={props.width}
- height={props.height}
- viewBox={iconInfo.viewBox}
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d={iconInfo.path}
- fill={props.color}
- fillRule={iconInfo.fillRule || 'nonzero'}
- clipRule={iconInfo.clipRule || 'nonzero'}
- stroke={iconInfo.stroke}
- strokeOpacity={iconInfo.strokeOpacity}
- strokeWidth={iconInfo.strokeWidth}
- strokeLinecap={iconInfo.strokeLinecap}
- strokeLinejoin={iconInfo.strokeLinejoin}
- />
- </svg>
+ <div onClick={props.onClick} className={props.className}>
+ <svg
+ width={props.width}
+ height={props.height}
+ viewBox={iconInfo.viewBox}
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d={iconInfo.path}
+ fill={props.color}
+ fillRule={iconInfo.fillRule || 'nonzero'}
+ clipRule={iconInfo.clipRule || 'nonzero'}
+ stroke={iconInfo.stroke}
+ strokeOpacity={iconInfo.strokeOpacity}
+ strokeWidth={iconInfo.strokeWidth}
+ strokeLinecap={iconInfo.strokeLinecap}
+ strokeLinejoin={iconInfo.strokeLinejoin}
+ />
+ </svg>
+ </div>
);
};
+
+export const Icon = styled(PlainIcon)`
+ cursor: ${props => (!_.isUndefined(props.onClick) ? 'pointer' : 'default')};
+ transition: opacity 0.5s ease;
+ padding: ${props => props.padding};
+ opacity: ${props => (!_.isUndefined(props.onClick) ? 0.7 : 1)};
+ &:hover {
+ opacity: 1;
+ }
+ &:active {
+ opacity: 1;
+ }
+`;
+
+Icon.defaultProps = {
+ color: 'white',
+ padding: '0em 0em',
+};
+
+Icon.displayName = 'Icon';