diff --git a/code/addons/toolbars/src/components/ToolbarMenuButton.tsx b/code/addons/toolbars/src/components/ToolbarMenuButton.tsx index f7d297be6b93..14fb01bc07dc 100644 --- a/code/addons/toolbars/src/components/ToolbarMenuButton.tsx +++ b/code/addons/toolbars/src/components/ToolbarMenuButton.tsx @@ -10,6 +10,10 @@ interface ToolbarMenuButtonProps { onClick?: () => void; } +// We can't remove the Icons component just yet because there's no way for now to import icons +// in the preview directly. Before having a better solution, we are going to keep the Icons component +// for now and remove the deprecated warning. + export const ToolbarMenuButton: FC = ({ active, title, @@ -19,7 +23,7 @@ export const ToolbarMenuButton: FC = ({ }) => { return ( - {icon && } + {icon && } {title ? `\xa0${title}` : null} ); diff --git a/code/ui/components/src/components/icon/icon.stories.tsx b/code/ui/components/src/components/icon/icon.stories.tsx index d3da4af90ed1..92dcba29a13a 100644 --- a/code/ui/components/src/components/icon/icon.stories.tsx +++ b/code/ui/components/src/components/icon/icon.stories.tsx @@ -90,3 +90,16 @@ export const NoLabels = (args: ComponentProps) => ( ); + +export const NoDeprecateWarning = (args: ComponentProps) => ( + <> +
{Object.keys(icons).length} icons
+ + {Object.keys(icons).map((key) => ( + + + + ))} + + +); diff --git a/code/ui/components/src/components/icon/icon.tsx b/code/ui/components/src/components/icon/icon.tsx index b0164ef2a276..a8a019daf889 100644 --- a/code/ui/components/src/components/icon/icon.tsx +++ b/code/ui/components/src/components/icon/icon.tsx @@ -24,18 +24,27 @@ export interface IconsProps extends ComponentProps { icon: IconType; useSymbol?: boolean; onClick?: () => void; + removeDeprecateWarning?: boolean; } /** * @deprecated No longer used, will be removed in Storybook 9.0 * Please use the `@storybook/icons` package instead. * */ -export const Icons = ({ icon, useSymbol, ...props }: IconsProps) => { - deprecate( - `Use of the deprecated Icons ${ - `(${icon})` || '' - } component detected. Please use the @storybook/icons component directly. For more informations, see the migration notes at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#icons-is-deprecated` - ); +export const Icons = ({ + icon, + useSymbol, + removeDeprecateWarning = false, + ...props +}: IconsProps) => { + if (!removeDeprecateWarning) { + deprecate( + `Use of the deprecated Icons ${ + `(${icon})` || '' + } component detected. Please use the @storybook/icons component directly. For more informations, see the migration notes at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#icons-is-deprecated` + ); + } + const findIcon: NewIconTypes = icons[icon] || null; if (!findIcon) { logger.warn(