From efbe9fc70e48466961830994269ecc60ea03400e Mon Sep 17 00:00:00 2001 From: marginy <98329176+Marginy605@users.noreply.github.com> Date: Mon, 15 May 2023 19:08:47 +0300 Subject: [PATCH] feat(Button): add xs Button size (#663) --- src/components/Button/Button.scss | 24 +++++++++++++++++++ src/components/Button/Button.tsx | 2 +- src/components/Button/README.md | 2 +- .../Button/__stories__/Button.new.stories.tsx | 2 +- .../Button/__stories__/Button.stories.tsx | 4 ++++ .../Button/__stories__/ButtonShowcase.tsx | 2 ++ .../ButtonExampleView/ButtonExampleView.tsx | 1 + .../Button/__tests__/Button.test.tsx | 13 ++++++---- .../hoc/withTableActions/withTableActions.tsx | 9 +++++-- 9 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/components/Button/Button.scss b/src/components/Button/Button.scss index 18caab4636..d7909252f6 100644 --- a/src/components/Button/Button.scss +++ b/src/components/Button/Button.scss @@ -85,6 +85,30 @@ $block: '.#{variables.$ns}button'; } &_size { + &_xs { + --yc-button-height: 20px; + + font-size: 13px; + + #{$block}__text { + margin: 0 6px; + } + + #{$block}__icon { + width: var(--yc-button-height); + + &_side_left ~ #{$block}__text { + margin-left: 18px; + } + + &_side_right ~ #{$block}__text { + margin-right: 18px; + } + } + + --yc-button-border-radius: var(--yc-border-radius-xs); + } + &_s { --yc-button-height: 24px; diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 7d9ba1eb4a..a87e2a6fa5 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -23,7 +23,7 @@ export type ButtonView = | 'outlined-contrast' // outlined button appearance with contrast background | 'flat-contrast'; // flat button appearance with contrast background -export type ButtonSize = 's' | 'm' | 'l' | 'xl'; +export type ButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl'; export type ButtonPin = | 'round-round' diff --git a/src/components/Button/README.md b/src/components/Button/README.md index 43814fe9ba..aaeacff4e8 100644 --- a/src/components/Button/README.md +++ b/src/components/Button/README.md @@ -82,7 +82,7 @@ type ButtonView = | 'outlined-contrast' | 'flat-contrast'; -type ButtonSize = 's' | 'm' | 'l' | 'xl'; +type ButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl'; type ButtonPin = | 'round-round' diff --git a/src/components/Button/__stories__/Button.new.stories.tsx b/src/components/Button/__stories__/Button.new.stories.tsx index 52159efd5c..57d1028e54 100644 --- a/src/components/Button/__stories__/Button.new.stories.tsx +++ b/src/components/Button/__stories__/Button.new.stories.tsx @@ -29,7 +29,7 @@ export default { defaultValue: 'normal', }, size: { - options: ['s', 'm', 'l', 'xl'], + options: ['xs', 's', 'm', 'l', 'xl'], control: {type: 'radio'}, defaultValue: 'm', }, diff --git a/src/components/Button/__stories__/Button.stories.tsx b/src/components/Button/__stories__/Button.stories.tsx index 20822854fe..74233c2556 100644 --- a/src/components/Button/__stories__/Button.stories.tsx +++ b/src/components/Button/__stories__/Button.stories.tsx @@ -15,6 +15,10 @@ export const Default = DefaultTemplate.bind({}); const SizeTemplate: Story = (args) => ( <> + + diff --git a/src/components/Button/__stories__/ButtonShowcase.tsx b/src/components/Button/__stories__/ButtonShowcase.tsx index 6e30ccef93..e795d907b0 100644 --- a/src/components/Button/__stories__/ButtonShowcase.tsx +++ b/src/components/Button/__stories__/ButtonShowcase.tsx @@ -16,6 +16,8 @@ export function ButtonShowcase() { {renderViewGrid()}

+ + diff --git a/src/components/Button/__stories__/examples/ButtonExampleView/ButtonExampleView.tsx b/src/components/Button/__stories__/examples/ButtonExampleView/ButtonExampleView.tsx index 266af18a3b..ff44910699 100644 --- a/src/components/Button/__stories__/examples/ButtonExampleView/ButtonExampleView.tsx +++ b/src/components/Button/__stories__/examples/ButtonExampleView/ButtonExampleView.tsx @@ -238,6 +238,7 @@ export function ButtonExampleState() { export function ButtonExampleSize() { return ( + diff --git a/src/components/Button/__tests__/Button.test.tsx b/src/components/Button/__tests__/Button.test.tsx index b9204269b4..389879a8f8 100644 --- a/src/components/Button/__tests__/Button.test.tsx +++ b/src/components/Button/__tests__/Button.test.tsx @@ -48,12 +48,15 @@ describe('Button', () => { expect(button).not.toBeDisabled(); }); - test.each(new Array('s', 'm', 'l', 'xl'))('render with given "%s" size', (size) => { - render(