From e56c21fd22d73afa4be1922e5404545c005a25f8 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 22 May 2018 23:48:22 -0400 Subject: [PATCH] use color prop for icon color instead of relying on type of icon and tooltip cleanup --- src/renderer/component/button/view.jsx | 6 +++-- src/renderer/component/categoryList/view.jsx | 1 - src/renderer/component/common/icon.jsx | 23 ++++++++++++++----- src/renderer/component/common/tooltip.jsx | 9 +++----- src/renderer/component/fileActions/view.jsx | 1 + src/renderer/component/fileCard/view.jsx | 2 +- .../component/fileDownloadLink/view.jsx | 9 +++++++- .../component/subscribeButton/view.jsx | 3 ++- src/renderer/page/file/view.jsx | 4 ++-- src/renderer/scss/component/_file-list.scss | 4 ++++ 10 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/renderer/component/button/view.jsx b/src/renderer/component/button/view.jsx index f622ff28a..8b496ea12 100644 --- a/src/renderer/component/button/view.jsx +++ b/src/renderer/component/button/view.jsx @@ -22,6 +22,7 @@ type Props = { button: ?string, // primary, secondary, alt, link noPadding: ?boolean, // to remove padding and allow circular buttons uppercase: ?boolean, + iconColor: ?string, }; class Button extends React.PureComponent { @@ -48,6 +49,7 @@ class Button extends React.PureComponent { type, noPadding, uppercase, + iconColor, ...otherProps } = this.props; @@ -82,10 +84,10 @@ class Button extends React.PureComponent { const content = ( - {icon && } + {icon && } {label && {label}} {children && children} - {iconRight && } + {iconRight && } ); diff --git a/src/renderer/component/categoryList/view.jsx b/src/renderer/component/categoryList/view.jsx index 56c69f4c9..0afa57940 100644 --- a/src/renderer/component/categoryList/view.jsx +++ b/src/renderer/component/categoryList/view.jsx @@ -223,7 +223,6 @@ class CategoryList extends React.PureComponent { {category && category.match(/^community/i) && ( { @@ -23,8 +24,20 @@ class IconComponent extends React.PureComponent { return null; } }; + + getIconColor = (color: string) => { + switch (color) { + case 'red': + return RED_COLOR; + case 'purple': + return PURPLE_COLOR; + default: + return null; + } + }; + render() { - const { icon, tooltip } = this.props; + const { icon, tooltip, iconColor } = this.props; const Icon = FeatherIcons[icon]; if (!Icon) { @@ -32,10 +45,8 @@ class IconComponent extends React.PureComponent { } let color; - if (icon === icons.TRASH || icon === icons.FEATURED) { - color = RED_COLOR; - } else if (icon === icons.OPEN) { - color = PURPLE_COLOR; + if (iconColor) { + color = this.getIconColor(iconColor); } let size = 14; diff --git a/src/renderer/component/common/tooltip.jsx b/src/renderer/component/common/tooltip.jsx index f1c5ca893..4bd264516 100644 --- a/src/renderer/component/common/tooltip.jsx +++ b/src/renderer/component/common/tooltip.jsx @@ -3,7 +3,7 @@ import * as React from 'react'; import classnames from 'classnames'; type Props = { - body: ?string, + body: string, label?: string, children: ?React.Node, icon: ?boolean, @@ -12,7 +12,7 @@ type Props = { class ToolTip extends React.PureComponent { static defaultProps = { - direction: 'top', + direction: 'bottom', }; render() { @@ -32,10 +32,7 @@ class ToolTip extends React.PureComponent { })} > {tooltipContent} - {body && ( - // body may be undefined for some icons until we add messages for them - {body} - )} + {body} ); } diff --git a/src/renderer/component/fileActions/view.jsx b/src/renderer/component/fileActions/view.jsx index a485cc90e..4ab110fca 100644 --- a/src/renderer/component/fileActions/view.jsx +++ b/src/renderer/component/fileActions/view.jsx @@ -30,6 +30,7 @@ class FileActions extends React.PureComponent {