From 7055deff7eab92c3bfdbd016ecb2d1a9be09dd92 Mon Sep 17 00:00:00 2001 From: Chaiwat Ekkaewnumchai Date: Thu, 5 Sep 2019 04:37:25 -0700 Subject: [PATCH] Button.tsx Summary: _typescript_ Reviewed By: danielbuechele Differential Revision: D17165021 fbshipit-source-id: 6a8cb9f6167efc4c3105c38854d7b6b8fd931be9 --- src/ui/components/Button.tsx | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/ui/components/Button.tsx b/src/ui/components/Button.tsx index 8a5bc7c33..0e32b14f8 100644 --- a/src/ui/components/Button.tsx +++ b/src/ui/components/Button.tsx @@ -16,7 +16,13 @@ import {keyframes} from 'react-emotion'; import {State as Store} from '../../reducers/index'; import Glyph, {IconSize} from './Glyph'; -const borderColor = props => { +type ButtonType = 'primary' | 'success' | 'warning' | 'danger'; + +const borderColor = (props: { + windowIsFocused?: boolean; + type?: ButtonType; + depressed?: boolean; +}) => { if (!props.windowIsFocused) { return colors.macOSTitleBarButtonBorderBlur; } else if (props.type === 'danger') { @@ -29,7 +35,11 @@ const borderColor = props => { return colors.macOSTitleBarButtonBorder; } }; -const borderBottomColor = props => { +const borderBottomColor = (props: { + windowIsFocused?: boolean; + type?: ButtonType; + depressed?: boolean; +}) => { if (!props.windowIsFocused) { return colors.macOSTitleBarButtonBorderBlur; } else if (props.type === 'danger') { @@ -41,7 +51,11 @@ const borderBottomColor = props => { } }; -const backgroundImage = props => { +const backgroundImage = (props: { + windowIsFocused?: boolean; + type?: ButtonType; + depressed?: boolean; +}) => { if (props.windowIsFocused) { if (props.depressed) { return `linear-gradient(to bottom, ${ @@ -61,7 +75,11 @@ const backgroundImage = props => { } }; -const color = props => { +const color = (props: { + windowIsFocused?: boolean; + type?: ButtonType; + disabled?: boolean; +}) => { if (props.type === 'danger' && props.windowIsFocused) { return colors.red; } else if (props.type === 'primary' && props.windowIsFocused) { @@ -198,7 +216,7 @@ type OwnProps = { /** * Type of button. */ - type?: 'primary' | 'success' | 'warning' | 'danger'; + type?: ButtonType; /** * Children. */