From 0110e7207fb936f981107a24c0db3a482f60e0c0 Mon Sep 17 00:00:00 2001 From: "REDMOND\\humorimo" Date: Mon, 8 Apr 2019 14:49:57 -0700 Subject: [PATCH 1/3] Button: Creating ActionButton variant and cleaning styling. --- .../src/components/Button/ActionButton.tsx | 49 +++++++++++++++++++ .../src/components/Button/Button.styles.ts | 7 ++- .../src/components/Button/Button.types.tsx | 1 + .../src/components/Button/ButtonPage.tsx | 6 +++ .../components/Button/ButtonVariants.types.ts | 2 + .../src/components/Button/DefaultButton.tsx | 4 +- .../src/components/Button/PrimaryButton.tsx | 4 +- .../Button/SplitButton/SplitButton.styles.ts | 7 ++- .../__snapshots__/Button.view.test.tsx.snap | 4 +- .../examples/Button.Variants.Example.tsx | 44 +++++++++++++++++ .../src/components/Button/index.ts | 1 + 11 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 packages/experiments/src/components/Button/ActionButton.tsx create mode 100644 packages/experiments/src/components/Button/examples/Button.Variants.Example.tsx diff --git a/packages/experiments/src/components/Button/ActionButton.tsx b/packages/experiments/src/components/Button/ActionButton.tsx new file mode 100644 index 0000000000000..3ce42f03c1c29 --- /dev/null +++ b/packages/experiments/src/components/Button/ActionButton.tsx @@ -0,0 +1,49 @@ +import * as React from 'react'; +import { Button } from './Button'; +import { IButtonComponent, IButtonTokenReturnType } from './Button.types'; +import { ButtonVariantsType } from './ButtonVariants.types'; +import { FontWeights } from '../../Styling'; + +const baseTokens: IButtonComponent['tokens'] = (props, theme): IButtonTokenReturnType => { + const { palette } = theme; + + return { + backgroundColor: 'transparent', + backgroundColorHovered: 'transparent', + backgroundColorPressed: 'transparent', + borderColor: 'transparent', + color: palette.neutralPrimary, + colorHovered: palette.themePrimary, + colorPressed: palette.black, + contentPadding: '0px 4px', + height: '40px', + iconColor: palette.neutralPrimary, + iconColorHovered: palette.themePrimary, + iconColorPressed: palette.black, + textWeight: FontWeights.regular + }; +}; + +const disabledTokens: IButtonComponent['tokens'] = (props, theme): IButtonTokenReturnType => { + const { palette } = theme; + + return { + color: palette.neutralTertiary, + colorHovered: palette.neutralTertiary, + colorPressed: palette.neutralTertiary, + iconColor: palette.neutralTertiary, + iconColorHovered: palette.neutralTertiary, + iconColorPressed: palette.neutralTertiary + }; +}; + +export const ActionButtonTokens: IButtonComponent['tokens'] = (props, theme): IButtonTokenReturnType => [ + baseTokens, + props.disabled && disabledTokens +]; + +export const ActionButton: ButtonVariantsType = props => { + const { text, iconProps, ...rest } = props; + + return