Skip to content

Commit 300b93d

Browse files
authored
fix: update icon button types and docs (#18658)
1 parent 1cac413 commit 300b93d

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

packages/react/src/components/Button/Button.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ const Button: ButtonComponent = React.forwardRef(
205205
}
206206

207207
return (
208+
// @ts-expect-error - `IconButton` does not support all `size`s that
209+
// `Button` supports.
210+
//
211+
// TODO: What should be done here?
212+
// 1. Should the `IconButton` not be rendered if the `size` is not
213+
// supported?
214+
// 2. Should an error be thrown?
215+
// 3. Something else?
208216
<IconButton
209217
{...rest}
210218
ref={ref}

packages/react/src/components/Button/ButtonBase.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const ButtonBase = React.forwardRef(function ButtonBase<
4545
[`${prefix}--btn`]: true,
4646
[`${prefix}--btn--sm`]: size === 'sm' && !isExpressive, // TODO: V12 - Remove this class
4747
[`${prefix}--btn--md`]: size === 'md' && !isExpressive, // TODO: V12 - Remove this class
48+
[`${prefix}--btn--lg`]: size === 'lg' && !isExpressive, // TODO: V12 - Remove this class
4849
[`${prefix}--btn--xl`]: size === 'xl', // TODO: V12 - Remove this class
4950
[`${prefix}--btn--2xl`]: size === '2xl', // TODO: V12 - Remove this class
5051
[`${prefix}--layout--size-${size}`]: size,

packages/react/src/components/Button/__tests__/Button-test.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@ describe('Button', () => {
9797
])(
9898
'should set the expected classes for the button of kind: `%s`',
9999
(kind, className) => {
100-
render(
101-
<Button className={className} kind={kind}>
102-
test
103-
</Button>
104-
);
100+
render(<Button kind={kind}>test</Button>);
105101
expect(screen.getByText('test')).toHaveClass(className);
106102
}
107103
);
@@ -115,11 +111,7 @@ describe('Button', () => {
115111
])(
116112
'should set the expected classes for the button of size: `%s`',
117113
(size, className) => {
118-
render(
119-
<Button className={className} size={size}>
120-
test
121-
</Button>
122-
);
114+
render(<Button size={size}>test</Button>);
123115
expect(screen.getByText('test')).toHaveClass(className);
124116
}
125117
);

packages/react/src/components/IconButton/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ export interface IconButtonProps
161161
rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
162162

163163
/**
164-
* Specify the size of the Button. Defaults to `md`.
164+
* Specify the size of the Button.
165165
*/
166-
size?: ButtonSize;
166+
size?: Extract<ButtonSize, 'sm' | 'md' | 'lg'>;
167167

168168
/**
169169
* Optionally specify a `target` when using an `<a>` element.
@@ -381,7 +381,7 @@ IconButton.propTypes = {
381381
rel: PropTypes.string,
382382

383383
/**
384-
* Specify the size of the Button. Defaults to `md`.
384+
* Specify the size of the Button.
385385
*/
386386
size: PropTypes.oneOf(['sm', 'md', 'lg']),
387387

0 commit comments

Comments
 (0)