diff --git a/frontend/documentation/components/Button.stories.tsx b/frontend/documentation/components/Button.stories.tsx index d7be200780d3..d4c6bda043a0 100644 --- a/frontend/documentation/components/Button.stories.tsx +++ b/frontend/documentation/components/Button.stories.tsx @@ -7,6 +7,7 @@ import { sizeClassNames, } from 'components/base/forms/Button' import type { ButtonType } from 'components/base/forms/Button' +import Icon from 'components/icons/Icon' const themeOptions = Object.keys(themeClassNames) as Array< keyof typeof themeClassNames @@ -81,6 +82,72 @@ export const Variants: Story = { ), } +export const IconAsChildren: Story = { + parameters: { + docs: { + description: { + story: + 'Pattern used by `btn-with-icon` consumers (e.g. table-row delete affordances): the icon is passed as `children`, not via the `iconLeft`/`iconRight` props. Layout must match the iconLeft/iconRight rendering for visual consistency. Snapshotted to catch wrapper-introduced height/width drift.', + }, + }, + }, + render: () => ( +
+ + + +
+ ), +} + +export const IconAndLabel: Story = { + parameters: { + docs: { + description: { + story: + 'The most common icon usage in real code: `iconLeft` or `iconRight` paired with a text label. Dedicated snapshot so spacing regressions between the icon and the label are caught independently of the Themes story.', + }, + }, + }, + render: () => ( +
+ + + +
+ ), +} + +export const AsAnchor: Story = { + parameters: { + docs: { + description: { + story: + "Button renders as an `` element when `href` is set — a separate code path from the ` + + + + ), +} + export const Sizes: Story = { parameters: { docs: { diff --git a/frontend/web/components/base/forms/Button.tsx b/frontend/web/components/base/forms/Button.tsx index 18f941483b4b..8170218d01b9 100644 --- a/frontend/web/components/base/forms/Button.tsx +++ b/frontend/web/components/base/forms/Button.tsx @@ -106,22 +106,28 @@ export const Button = React.forwardRef< )} ref={ref as React.RefObject} > - {!!iconLeft && ( - - )} - {children} - {!!iconRight && ( - + {iconLeft || iconRight ? ( + + {!!iconLeft && ( + + )} + {children} + {!!iconRight && ( + + )} + + ) : ( + children )} )