From a24933d2f9c438f37feec282093b73b1cdabed3d Mon Sep 17 00:00:00 2001 From: witt Date: Sun, 5 Jul 2020 14:29:33 +0800 Subject: [PATCH] Button (#319) * feat(button): center the icon if the button is empty * test(button): add testcase for icon only * docs(button): add example for icon only --- .../__snapshots__/icon.test.tsx.snap | 108 +++++++++++++++++- components/button/__tests__/icon.test.tsx | 7 ++ components/button/button-icon.tsx | 11 +- components/button/utils.tsx | 7 ++ pages/en-us/components/button.mdx | 2 +- pages/zh-cn/components/button.mdx | 2 +- 6 files changed, 132 insertions(+), 5 deletions(-) diff --git a/components/button/__tests__/__snapshots__/icon.test.tsx.snap b/components/button/__tests__/__snapshots__/icon.test.tsx.snap index 62c0e08..6653687 100644 --- a/components/button/__tests__/__snapshots__/icon.test.tsx.snap +++ b/components/button/__tests__/__snapshots__/icon.test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ButtonIcon should render correctly 1`] = ` -"" `; + +exports[`ButtonIcon should work without text 1`] = ` +"" +`; diff --git a/components/button/__tests__/icon.test.tsx b/components/button/__tests__/icon.test.tsx index 02470d6..b443b06 100644 --- a/components/button/__tests__/icon.test.tsx +++ b/components/button/__tests__/icon.test.tsx @@ -16,6 +16,13 @@ describe('ButtonIcon', () => { expect(() => wrapper.unmount()).not.toThrow() }) + it('should work without text', () => { + const wrapper = mount( + diff --git a/pages/zh-cn/components/button.mdx b/pages/zh-cn/components/button.mdx index 8b62e05..6e6b1ae 100644 --- a/pages/zh-cn/components/button.mdx +++ b/pages/zh-cn/components/button.mdx @@ -109,7 +109,7 @@ export const meta = { scope={{ Button, Spacer, Settings, UserX, Power }} code={` <> - +