Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add status "badge" in sidebar #4

Closed
stowball opened this issue Aug 6, 2020 · 4 comments
Closed

Add status "badge" in sidebar #4

stowball opened this issue Aug 6, 2020 · 4 comments

Comments

@stowball
Copy link
Contributor

stowball commented Aug 6, 2020

It would be awesome if this addon added an appropriately coloured dot beside the story name in the sidebar, and potentially some treatment to the parent so you can see the status at a glance for all stories/components.

Could potentially only identify beta or deprecated ones to reduce noise

@gavmck
Copy link
Member

gavmck commented Aug 6, 2020

Hey that would be neat! I don't know if I can get sidebar access from the storybook addon API, but I'll give it a shot

@gavmck
Copy link
Member

gavmck commented Aug 7, 2020

I don't think this is possible in Storybook v5.

If you can see a way of doing it, or anyone who is editing the sidebar content using addons, then let me know.

Leaving this open in case somebody figures it out.

🙏

@adrienrn
Copy link

Coming back to this issue looking for a similar thing.

As of Storybook 6.2.0 (which is still at a release candidate phase 🙈 ), it will be possible to use a configuration sidebar.renderLabel ! Briefly tested it and we can start prepare for it for when it is stable:

image

The gist would be:

// .storybook/manager.js
import { addons } from '@storybook/addons';
import { Icons } from '@storybook/components';
import { styled } from '@storybook/theming';
import React from 'react';

const SuffixIcon = styled(Icons)`
  align-self: center;
  display: inline;
  height: 1.125em;
  margin-left: 4px;
  width: 1.125em;
`;

addons.setConfig({
  sidebar: {
    renderLabel: item => {
      // item can be a Root | Group | Story
      if (!item.isLeaf) {
        return item.name;
      }
      
      return (<>{item.name}<SuffixIcon icon="lightning" /></>);
    },
  },
});

To dig deeper:

@gavmck
Copy link
Member

gavmck commented Apr 9, 2021

Status badges with title attr hovers so you can see the full status and description are now available on v3.0.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants