From 2430d21f4bd4de621b0c2a8924c71d563e817d1b Mon Sep 17 00:00:00 2001 From: unix Date: Fri, 29 May 2020 14:46:11 +0800 Subject: [PATCH 1/3] fix(button): fix loading is not display under auto width --- components/button/button-loading.tsx | 27 +++++++++++++++++++++++++++ components/button/button.tsx | 6 ++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 components/button/button-loading.tsx diff --git a/components/button/button-loading.tsx b/components/button/button-loading.tsx new file mode 100644 index 0000000..2f6f0d8 --- /dev/null +++ b/components/button/button-loading.tsx @@ -0,0 +1,27 @@ +import React from 'react' +import Loading from '../loading' + +interface Props { + color: string +} + +const ButtonLoading: React.FC> = ({ color }) => { + return ( +
+ + +
+ ) +} + +export default React.memo(ButtonLoading) diff --git a/components/button/button.tsx b/components/button/button.tsx index e091003..b2e3cd0 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -9,7 +9,7 @@ import React, { } from 'react' import useTheme from '../styles/use-theme' import ButtonDrip from './button.drip' -import ButtonLoading from '../loading' +import ButtonLoading from './button-loading' import { ButtonTypes, NormalSizes } from '../utils/prop-types' import { filterPropsWithGroup, getButtonChildrenWithIcon } from './utils' import { useButtonGroupContext } from '../button-group/button-group-context' @@ -141,7 +141,8 @@ const Button = React.forwardRef - {loading ? : childrenWithIcon} + {loading && } + {childrenWithIcon} {dripShow && ( )} @@ -176,6 +177,7 @@ const Button = React.forwardRef Date: Fri, 29 May 2020 14:47:00 +0800 Subject: [PATCH 2/3] docs(button): add docs for loading button --- pages/en-us/components/button.mdx | 10 ++++++++-- pages/zh-cn/components/button.mdx | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pages/en-us/components/button.mdx b/pages/en-us/components/button.mdx index 5703f82..3c03cf2 100644 --- a/pages/en-us/components/button.mdx +++ b/pages/en-us/components/button.mdx @@ -26,9 +26,15 @@ Used to trigger an operation. Action +<> + + + + + + `} /> 动作 +<> + + + + + + `} /> Date: Fri, 29 May 2020 14:48:08 +0800 Subject: [PATCH 3/3] test: update snapshots --- .../button-group/__tests__/__snapshots__/index.test.tsx.snap | 5 +++++ components/button/__tests__/__snapshots__/icon.test.tsx.snap | 2 ++ .../use-toasts/__tests__/__snapshots__/index.test.tsx.snap | 2 ++ 3 files changed, 9 insertions(+) diff --git a/components/button-group/__tests__/__snapshots__/index.test.tsx.snap b/components/button-group/__tests__/__snapshots__/index.test.tsx.snap index 72c0904..06fd2bb 100644 --- a/components/button-group/__tests__/__snapshots__/index.test.tsx.snap +++ b/components/button-group/__tests__/__snapshots__/index.test.tsx.snap @@ -32,6 +32,7 @@ exports[`ButtonGroup buttons should be displayed vertically 1`] = ` --zeit-ui-button-padding: 1.25rem; --zeit-ui-button-height: 2.5rem; --zeit-ui-button-color: #666; + --zeit-ui-button-bg: #fff; } .btn:hover { @@ -92,6 +93,7 @@ exports[`ButtonGroup buttons should be displayed vertically 1`] = ` --zeit-ui-button-padding: 1.25rem; --zeit-ui-button-height: 2.5rem; --zeit-ui-button-color: #666; + --zeit-ui-button-bg: #fff; } .btn:hover { @@ -200,6 +202,7 @@ exports[`ButtonGroup props should be passed to each button 1`] = ` --zeit-ui-button-padding: 0.625rem; --zeit-ui-button-height: 1.5rem; --zeit-ui-button-color: #fff; + --zeit-ui-button-bg: #0070f3; } .btn:hover { @@ -308,6 +311,7 @@ exports[`ButtonGroup props should be passed to each button 2`] = ` --zeit-ui-button-padding: 0.625rem; --zeit-ui-button-height: 1.5rem; --zeit-ui-button-color: #fff; + --zeit-ui-button-bg: #0070f3; } .btn:hover { @@ -416,6 +420,7 @@ exports[`ButtonGroup should render correctly 1`] = ` --zeit-ui-button-padding: 1.25rem; --zeit-ui-button-height: 2.5rem; --zeit-ui-button-color: #666; + --zeit-ui-button-bg: #fff; } .btn:hover { diff --git a/components/button/__tests__/__snapshots__/icon.test.tsx.snap b/components/button/__tests__/__snapshots__/icon.test.tsx.snap index 55796dc..62c0e08 100644 --- a/components/button/__tests__/__snapshots__/icon.test.tsx.snap +++ b/components/button/__tests__/__snapshots__/icon.test.tsx.snap @@ -63,6 +63,7 @@ exports[`ButtonIcon should render correctly 1`] = ` --zeit-ui-button-padding: 1.375rem; --zeit-ui-button-height: 2.5rem; --zeit-ui-button-color: #666; + --zeit-ui-button-bg: #fff; } .btn:hover { @@ -158,6 +159,7 @@ exports[`ButtonIcon should work with right 1`] = ` --zeit-ui-button-padding: 1.375rem; --zeit-ui-button-height: 2.5rem; --zeit-ui-button-color: #666; + --zeit-ui-button-bg: #fff; } .btn:hover { diff --git a/components/use-toasts/__tests__/__snapshots__/index.test.tsx.snap b/components/use-toasts/__tests__/__snapshots__/index.test.tsx.snap index 8fcaa31..03acd43 100644 --- a/components/use-toasts/__tests__/__snapshots__/index.test.tsx.snap +++ b/components/use-toasts/__tests__/__snapshots__/index.test.tsx.snap @@ -32,6 +32,7 @@ exports[`UseToast should render different actions 1`] = ` --zeit-ui-button-padding: 0.625rem; --zeit-ui-button-height: 1.5rem; --zeit-ui-button-color: #fff; + --zeit-ui-button-bg: #000; } .btn:hover { @@ -92,6 +93,7 @@ exports[`UseToast should render different actions 1`] = ` --zeit-ui-button-padding: 0.625rem; --zeit-ui-button-height: 1.5rem; --zeit-ui-button-color: #666; + --zeit-ui-button-bg: #fff; } .btn:hover {