diff --git a/.changeset/lucky-buckets-shout.md b/.changeset/lucky-buckets-shout.md new file mode 100644 index 0000000000..40093315fa --- /dev/null +++ b/.changeset/lucky-buckets-shout.md @@ -0,0 +1,5 @@ +--- +'@contentful/f36-button': patch +--- + +IconButton: adjust size, deprecate `size="large"` and `children` props. diff --git a/packages/components/button/src/IconButton/IconButton.styles.ts b/packages/components/button/src/IconButton/IconButton.styles.ts new file mode 100644 index 0000000000..dca616240e --- /dev/null +++ b/packages/components/button/src/IconButton/IconButton.styles.ts @@ -0,0 +1,33 @@ +import { css } from 'emotion'; +import tokens from '@contentful/f36-tokens'; +import { ButtonSize } from '../types'; + +function sizeToStyles(size: ButtonSize) { + switch (size) { + case 'small': { + return { + padding: tokens.spacing2Xs, + minHeight: '32px', + minWidth: '32px', + }; + } + case 'medium': { + return { + padding: tokens.spacingXs, + minHeight: '40px', + minWidth: '40px', + }; + } + default: { + return {}; + } + } +} + +export function getStyles({ size }: { size: ButtonSize }) { + return { + iconButton: css({ + ...sizeToStyles(size), + }), + }; +} diff --git a/packages/components/button/src/IconButton/IconButton.tsx b/packages/components/button/src/IconButton/IconButton.tsx index 25023ec744..4774010292 100644 --- a/packages/components/button/src/IconButton/IconButton.tsx +++ b/packages/components/button/src/IconButton/IconButton.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { cx } from 'emotion'; import type { PolymorphicProps, PolymorphicComponent, @@ -6,9 +7,13 @@ import type { } from '@contentful/f36-core'; import { Button } from '../Button'; import type { ButtonInternalProps } from '../types'; +import { getStyles } from './IconButton.styles'; interface IconButtonInternalProps - extends Omit { + extends Omit< + ButtonInternalProps, + 'startIcon' | 'endIcon' | 'children' | 'size' + > { /** * Expects any of the icon components */ @@ -17,6 +22,15 @@ interface IconButtonInternalProps * Aria label is required when using icon only */ 'aria-label': string; + /** + * @deprecated Use