From b7f37249e4c4ba5fde9fa035fc617d3434b66d62 Mon Sep 17 00:00:00 2001 From: unix Date: Fri, 15 May 2020 20:14:31 +0800 Subject: [PATCH] feat(button): add light type support test(button): update snapshots --- .../__snapshots__/icon.test.tsx.snap | 4 +- components/button/__tests__/index.test.tsx | 4 + components/button/button.tsx | 28 ++- components/button/styles.ts | 186 +++++++++++------- components/utils/color.ts | 35 ++++ components/utils/prop-types.ts | 13 +- 6 files changed, 185 insertions(+), 85 deletions(-) create mode 100644 components/utils/color.ts diff --git a/components/button/__tests__/__snapshots__/icon.test.tsx.snap b/components/button/__tests__/__snapshots__/icon.test.tsx.snap index cdaf903..19a2c49 100644 --- a/components/button/__tests__/__snapshots__/icon.test.tsx.snap +++ b/components/button/__tests__/__snapshots__/icon.test.tsx.snap @@ -51,7 +51,7 @@ exports[`ButtonIcon should render correctly 1`] = ` text-align: center; white-space: nowrap; transition: background-color 200ms ease 0ms, box-shadow 200ms ease 0ms, - border 200ms ease 0ms; + border 200ms ease 0ms, color 200ms ease 0ms; position: relative; overflow: hidden; color: #666; @@ -146,7 +146,7 @@ exports[`ButtonIcon should work with right 1`] = ` text-align: center; white-space: nowrap; transition: background-color 200ms ease 0ms, box-shadow 200ms ease 0ms, - border 200ms ease 0ms; + border 200ms ease 0ms, color 200ms ease 0ms; position: relative; overflow: hidden; color: #666; diff --git a/components/button/__tests__/index.test.tsx b/components/button/__tests__/index.test.tsx index a11dce0..eb5434d 100644 --- a/components/button/__tests__/index.test.tsx +++ b/components/button/__tests__/index.test.tsx @@ -13,9 +13,13 @@ describe('Button', () => { const wrapper = mount(
, ) diff --git a/components/button/button.tsx b/components/button/button.tsx index ad6ea6e..51a4140 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -6,7 +6,13 @@ import ButtonLoading from '../loading' import { ButtonTypes, NormalSizes } from '../utils/prop-types' import { filterPropsWithGroup, getButtonChildrenWithIcon } from './utils' import { useButtonGroupContext } from '../button-group/button-group-context' -import { getButtonColors, getButtonCursor, getButtonHoverColors, getButtonSize } from './styles' +import { + getButtonColors, + getButtonCursor, + getButtonDripColor, + getButtonHoverColors, + getButtonSize, +} from './styles' interface Props { type?: ButtonTypes @@ -66,16 +72,23 @@ const Button: React.FC> = ({ ...btnProps }) ...props } = filteredProps - const { bg, border, color } = useMemo(() => getButtonColors(theme, filteredProps), [ - theme, + const { bg, border, color } = useMemo(() => getButtonColors(theme.palette, filteredProps), [ + theme.palette, + filteredProps, + ]) + const hover = useMemo(() => getButtonHoverColors(theme.palette, filteredProps), [ + theme.palette, filteredProps, ]) - const hover = useMemo(() => getButtonHoverColors(theme, filteredProps), [theme, filteredProps]) const { cursor, events } = useMemo(() => getButtonCursor(disabled, loading), [disabled, loading]) const { height, minWidth, padding, width, fontSize } = useMemo(() => getButtonSize(size, auto), [ size, auto, ]) + const dripColor = useMemo(() => getButtonDripColor(theme.palette, filteredProps), [ + theme.palette, + filteredProps, + ]) /* istanbul ignore next */ const dripCompletedHandle = () => { @@ -117,12 +130,7 @@ const Button: React.FC> = ({ ...btnProps }) {...props}> {loading ? : childrenWithIcon} {dripShow && ( - + )}