diff --git a/src/components/Button/Button.scss b/src/components/Button/Button.scss index fbc18536e8..5172c7344d 100644 --- a/src/components/Button/Button.scss +++ b/src/components/Button/Button.scss @@ -294,6 +294,10 @@ $block: '.#{variables.$ns}button'; &_side_end { order: 1; } + + &:only-child { + margin: 0; + } } &:has(#{$block}__icon:only-child) { diff --git a/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-dark-chromium-linux.png b/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-dark-chromium-linux.png new file mode 100644 index 0000000000..1e33a56254 Binary files /dev/null and b/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-dark-chromium-linux.png differ diff --git a/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-dark-webkit-linux.png b/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-dark-webkit-linux.png new file mode 100644 index 0000000000..5f559d1f10 Binary files /dev/null and b/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-dark-webkit-linux.png differ diff --git a/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-light-chromium-linux.png b/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-light-chromium-linux.png new file mode 100644 index 0000000000..ff80e032d7 Binary files /dev/null and b/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-light-chromium-linux.png differ diff --git a/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-light-webkit-linux.png b/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-light-webkit-linux.png new file mode 100644 index 0000000000..99eb41f126 Binary files /dev/null and b/src/components/Button/__snapshots__/Button.visual.test.tsx-snapshots/Button-single-Icon-in-shrinked-container-light-webkit-linux.png differ diff --git a/src/components/Button/__tests__/Button.visual.test.tsx b/src/components/Button/__tests__/Button.visual.test.tsx index f0dc1ed4b0..b707c2da7d 100644 --- a/src/components/Button/__tests__/Button.visual.test.tsx +++ b/src/components/Button/__tests__/Button.visual.test.tsx @@ -2,7 +2,11 @@ import React from 'react'; import {test} from '~playwright/core'; -import {ButtonStories, CustomIconSizeButton} from './helpersPlaywright'; +import { + ButtonStories, + CustomIconSizeButton, + SingleIconButtonInShrinkedContainer, +} from './helpersPlaywright'; test.describe('Button', () => { test('render story: ', async ({mount, expectScreenshot}) => { @@ -76,4 +80,10 @@ test.describe('Button', () => { await expectScreenshot(); }); + + test('single Icon in shrinked container', async ({mount, expectScreenshot}) => { + await mount(); + + await expectScreenshot(); + }); }); diff --git a/src/components/Button/__tests__/helpersPlaywright.scss b/src/components/Button/__tests__/helpersPlaywright.scss new file mode 100644 index 0000000000..b0e589df18 --- /dev/null +++ b/src/components/Button/__tests__/helpersPlaywright.scss @@ -0,0 +1,17 @@ +.button-view-showcase-container { + width: 200px; + + .showcase__content { + flex-direction: column; + } + + &__shrinked-container { + display: flex; + width: 20px; + border: 1px solid var(--g-color-line-generic); + + &_max { + width: 100%; + } + } +} diff --git a/src/components/Button/__tests__/helpersPlaywright.tsx b/src/components/Button/__tests__/helpersPlaywright.tsx index c22d3c6769..add8f6bba8 100644 --- a/src/components/Button/__tests__/helpersPlaywright.tsx +++ b/src/components/Button/__tests__/helpersPlaywright.tsx @@ -1,13 +1,18 @@ import React from 'react'; -import {ChevronDown, Globe} from '@gravity-ui/icons'; +import {ChevronDown, Globe, Xmark} from '@gravity-ui/icons'; import {composeStories} from '@storybook/react'; import {Button} from '..'; import {Showcase} from '../../../demo/Showcase'; import {Icon} from '../../Icon'; +import {cn} from '../../utils/cn'; import * as DefaultButtonStories from '../__stories__/Button.stories'; +import './helpersPlaywright.scss'; + +const b = cn('button-view-showcase-container'); + export const ButtonStories = composeStories(DefaultButtonStories); export const CustomIconSizeButton = () => ( @@ -39,3 +44,18 @@ export const CustomIconSizeButton = () => ( ); + +export const SingleIconButtonInShrinkedContainer = () => ( + +
+ +
+
+ +
+
+);