Skip to content

Commit

Permalink
Adding some doc blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hayward committed Feb 15, 2024
1 parent 874b85e commit 4d63235
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions storybook/badges.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Provides badge configuration options.
* See https://github.com/geometricpanda/storybook-addon-badges
*/

export default {
private: {
icon: '🔒',
Expand Down
13 changes: 13 additions & 0 deletions storybook/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Provides sidebar configuration options.
* See https://storybook.js.org/docs/configure/features-and-behavior
*/

/**
* External dependencies
*/
Expand Down Expand Up @@ -25,6 +30,10 @@ const Icons = styled.span( {} );

const Icon = styled.span( {} );

/**
* Fetches tags from the Storybook API, and returns Icon
* elements for any that have matching badge data
*/
function useIcons( item ) {
const api = useStorybookApi();
const prefix = 'status-';
Expand Down Expand Up @@ -53,6 +62,9 @@ function useIcons( item ) {
}, [ api, item.children, item.isComponent ] );
}

/**
* Renders the item name and any associated badge icons.
*/
function Label( { item } ) {
const iconSet = useIcons( item );
const title = createElement( Title, {}, item.name );
Expand All @@ -62,5 +74,6 @@ function Label( { item } ) {
}

export default {
// Renders status icons for items tagged with `status-*`
renderLabel: ( item ) => createElement( Label, { item } ),
};

0 comments on commit 4d63235

Please sign in to comment.