diff --git a/.changeset/nice-vans-vanish.md b/.changeset/nice-vans-vanish.md new file mode 100644 index 0000000000..c52fc42488 --- /dev/null +++ b/.changeset/nice-vans-vanish.md @@ -0,0 +1,5 @@ +--- +'@backstage/canon': minor +--- + +**Breaking Change** Icons on Button and IconButton now need to be imported and placed like this: - @@ -71,8 +72,12 @@ export const Sizes: Story = { }, render: () => ( - - + + ), }; @@ -83,9 +88,13 @@ export const WithIcons: Story = { }, render: args => ( - ); }, diff --git a/packages/canon/src/components/Button/styles.css b/packages/canon/src/components/Button/styles.css index 785fbf3b88..a4afd85c9b 100644 --- a/packages/canon/src/components/Button/styles.css +++ b/packages/canon/src/components/Button/styles.css @@ -94,12 +94,14 @@ height: 32px; } -.canon-Button[data-size='small'] .canon-ButtonIcon { +.canon-ButtonIcon[data-size='small'], +.canon-ButtonIcon[data-size='small'] svg { width: 1rem; height: 1rem; } -.canon-Button[data-size='medium'] .canon-ButtonIcon { - width: 1.5rem; - height: 1.5rem; +.canon-ButtonIcon[data-size='medium'], +.canon-ButtonIcon[data-size='medium'] svg { + width: 1.25rem; + height: 1.25rem; } diff --git a/packages/canon/src/components/Button/types.ts b/packages/canon/src/components/Button/types.ts index 0d61e1cda4..4ab62d5683 100644 --- a/packages/canon/src/components/Button/types.ts +++ b/packages/canon/src/components/Button/types.ts @@ -13,8 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { IconNames } from '../Icon'; + import type { ButtonOwnProps } from './Button.props'; +import { ReactElement } from 'react'; /** * Properties for {@link Button} @@ -43,10 +44,10 @@ export interface ButtonProps /** * Optional icon to display at the start of the button */ - iconStart?: IconNames; + iconStart?: ReactElement; /** * Optional icon to display at the end of the button */ - iconEnd?: IconNames; + iconEnd?: ReactElement; } diff --git a/packages/canon/src/components/Collapsible/Collapsible.stories.tsx b/packages/canon/src/components/Collapsible/Collapsible.stories.tsx index 4130419a0c..175dadba85 100644 --- a/packages/canon/src/components/Collapsible/Collapsible.stories.tsx +++ b/packages/canon/src/components/Collapsible/Collapsible.stories.tsx @@ -19,6 +19,7 @@ import { Collapsible } from './'; import { Button } from '../Button'; import { Box } from '../Box'; import { Text } from '../Text'; +import { Icon } from '../Icon'; const meta = { title: 'Components/Collapsible', @@ -42,7 +43,13 @@ export const Default: Story = { render={(props, state) => ( ); }, diff --git a/packages/canon/src/components/IconButton/styles.css b/packages/canon/src/components/IconButton/styles.css index 859c512fd6..066b0fbad5 100644 --- a/packages/canon/src/components/IconButton/styles.css +++ b/packages/canon/src/components/IconButton/styles.css @@ -94,12 +94,14 @@ width: 32px; } -.canon-IconButton[data-size='small'] .canon-IconButtonIcon { +.canon-IconButtonIcon[data-size='small'], +.canon-IconButtonIcon[data-size='small'] svg { width: 1rem; height: 1rem; } -.canon-IconButton[data-size='medium'] .canon-IconButtonIcon { - width: 1.5rem; - height: 1.5rem; +.canon-IconButtonIcon[data-size='medium'], +.canon-IconButtonIcon[data-size='medium'] svg { + width: 1.25rem; + height: 1.25rem; } diff --git a/packages/canon/src/components/IconButton/types.ts b/packages/canon/src/components/IconButton/types.ts index 90505d3352..ece1950d1b 100644 --- a/packages/canon/src/components/IconButton/types.ts +++ b/packages/canon/src/components/IconButton/types.ts @@ -13,8 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { IconNames } from '../Icon'; + import type { IconButtonOwnProps } from './IconButton.props'; +import { ReactElement } from 'react'; /** * Properties for {@link IconButton} @@ -36,7 +37,7 @@ export interface IconButtonProps variant?: IconButtonOwnProps['variant']; /** - * Icon to display at the start of the button + * Icon to display in the button */ - icon: IconNames; + icon: ReactElement; } diff --git a/packages/canon/src/components/Menu/Menu.stories.tsx b/packages/canon/src/components/Menu/Menu.stories.tsx index d1b8f831c5..5d04a2f19c 100644 --- a/packages/canon/src/components/Menu/Menu.stories.tsx +++ b/packages/canon/src/components/Menu/Menu.stories.tsx @@ -17,6 +17,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { Menu } from './Menu'; import { Button } from '../Button'; +import { Icon } from '../Icon'; const meta = { title: 'Components/Menu', @@ -36,7 +37,7 @@ export const Default: Story = { {...props} size="medium" variant="secondary" - iconEnd="chevron-down" + iconEnd={} > Menu