storybook icon indicating copy to clipboard operation
storybook copied to clipboard

[Bug]: deprecation warnings when older icons are being used

Open vanessayuenn opened this issue 1 year ago • 10 comments

Describe the bug

Project: MealDrop Version: 8.0.0-alpha.14 Bug/feedback:

It seems that not all parts of Storybook are using the new icons, so the browser console gets many deprecation warnings when older icons are being used such as:

Use of deprecated props in the button component detected, see the migration notes at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#new-ui-and-props-for-button-and-iconbutton-components

Use of the deprecated Icons (check) 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

Use of the deprecated Icons (play) 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

Scenario 1:

When using addon-interactions and accessing a story that contains a play function. The addon interactions panel seems to be using old icons (check, play).

Scenario 2:

When creating your own toolbar (from official docs), you can define icons via their name like so:

const preview = {
  //... other properties,
  globalTypes: {
    theme: {
      name: 'Theme',
      description: 'Theme for the components',
      defaultValue: 'light',
      toolbar: {
        icon: 'circlehollow',
        items: [
          { value: 'light', icon: 'circlehollow', title: 'light' },
          { value: 'dark', icon: 'circle', title: 'dark' },
          { value: 'side-by-side', icon: 'sidebar', title: 'side by side' },
        ],
      },
    },
  },
};

export default preview;

When clicking on the newly created toolbar button, you will get as many warnings as the amount of icons you create: image

To Reproduce

  1. Go to https://stackblitz.com/edit/github-csg7tu 2.1 Open the Page - Logged In story 2.2 Click on the circle toolbar
  2. See the warnings

System

No response

Additional context

No response

vanessayuenn avatar Jan 25 '24 14:01 vanessayuenn

Tempted to make this a beta blocker if we can squeeze it in. It's an easy fix and will reduce the noise, allowing us and users to flag other error/warning messages more easily @vanessayuenn

shilman avatar Jan 26 '24 03:01 shilman

I'm working on it now @shilman so hopefully it should be done for Beta.

cdedreuille avatar Jan 30 '24 13:01 cdedreuille

Why was this issue closed? The official docs for custom toolbar buttons still show the same method of adding an icon, which causes the deprecation warning

lunelson avatar May 23 '24 12:05 lunelson

OP is exactly my scenario, following the theme-switching docs and getting the same icon deprecation warning. Using the latest Storybook 8.1.5 w/ Next.js framework in a fresh setup.

notacouch avatar May 31 '24 22:05 notacouch

I have the same deprecation warning and indeed, following the doc of v8.1, we are still recommended to use icons from @storybook/components : https://storybook.js.org/docs/essentials/toolbars-and-globals#advanced-usage https://storybook.js.org/docs/faq#what-icons-are-available-for-my-toolbar-or-my-addon

Why this issue has been closed ? is there a workaround ?

solyane2002 avatar Jun 14 '24 09:06 solyane2002

@lunelson @notacouch @solyane2002 thanks for bringing this up. The documentation should indeed be updated. Meanwhile, the same icons should be imported from @storybook/icons instead.

vanessayuenn avatar Jun 24 '24 13:06 vanessayuenn

Thanks @vanessayuenn — how would we work with the globalTypes API to create icons for toolbar items then? These expect a string identifier: https://storybook.js.org/docs/essentials/toolbars-and-globals#globals

lunelson avatar Jun 24 '24 16:06 lunelson

In the documentation, any reference to @storybook/components should be changed to @storybook/icons, but the API itself has not changed. So, the same code snippet in the globalTypes API docs should work without triggering any deprecation warning. Sounds like that's not the case for you, @lunelson @solyane2002? If so, could either of you assist in providing a repro via https://storybook.new/? 🙏🏼

vanessayuenn avatar Jun 27 '24 13:06 vanessayuenn

Actually it does seem to be fixed in the latest version, for me.

In a previous patch version, adding this property to the default export of .storybook/preview.tsx resulted in the deprecation warning, even when that file imported neither @storybook/icons nor @storybook/components, but it now seems to work

  globalTypes: {
    graticule: {
      description: 'Toggle the Graticule in preview area',
      type: 'string',
      defaultValue: 'visible',
      toolbar: {
        icon: 'component', // <--- this line was the problem
        items: [
          { value: 'off', title: 'Off' },
          { value: 'hidden', title: 'Hidden' },
          { value: 'visible', title: 'Visible' },
        ],
      },
    },
  },

lunelson avatar Jun 27 '24 14:06 lunelson

Here's a minimal repro:

https://stackblitz.com/edit/github-mqgxvo?file=.storybook%2Fpreview.js

The console warning appears when clicking the 'Click me!' in the toolbar.

mrginglymus avatar Jun 27 '24 14:06 mrginglymus