Badge Functions
Badge functions are an option in several places throughout the config for storybook-addon-badges
.
They are a way to dynamically alter the value returned based on information about a story/badge.
The function accepts the following parameters:
badgeId
: The ID used to look up the badge's configurationcontent
: The parsed `content` of the badgeentry
: The Storybook data for the story. An object containing:id
: The unique ID of the entry.depth
: The depth of the entry in the sidebar tree (how many folders deep - including theroot
).name
: The name of the entry, usually displayed in the sidebar.refId
: An internal Storybook reference.renderLabel
: A function for rendering the label in the sidebar. See the Storybook docs for more details.type
: The type of the entry.startCollapsed
: Whether aroot
entry is collapsed on initial load. (Only available ontype: 'root'
).children
: The contents of aroot
,group
, orcomponent
entry. Lists the direct child entry ID's.parent
: The parent of agroup
,component
,docs
orstory
entry. The ID of the entry's direct parent entry.tags
: Thetags
of acomponent
,docs
orstory
entry.title
: The title of adocs
orstory
entry. Can be inferred, or manually entered in the component'smeta
.prepared
: A boolean indicating whether thedocs
/story
has been prepared. Iffalse
, theargs
,argTypes
,initialArgs
andparameters
are unlikely to be populated.importPath
: The file path fordocs
/story
entries. Relates to their story file (*.stories.tsx?
).parameters
: Theparameters
of adocs
/story
entry. Only available if the entry is prepared.args
: The currentargs
of astory
entry, will differ toinitialArgs
if the values have been updated in Storybook but not saved. Only available if the entry is prepared.argTypes
: TheargTypes
of astory
entry. Only available if the entry is prepared.initialArgs
: TheinitialArgs
of astory
entry. Only available if the entry is prepared.
getBadgeParts
: A function that accepts a string, and splits it into `badgeId` and `content` based on thedelimiter
from thematcher
orbadgesConfig
.rawContent
: The string that was passed in to thetags
/badges
array.