Skip to content

Commit

Permalink
feat: Add support for group entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidnioulz committed Jan 16, 2025
1 parent 73b8acc commit 44a5d5c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .storybook/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ addons.setConfig({
tooltip: 'This component can catch flies!',
},
display: {
sidebar: ['component'],
sidebar: ['component', 'group'],
toolbar: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const Sidebar: FC<SidebarProps> = ({ children, item }) => {

if (
item.type !== 'component' &&
item.type !== 'group' &&
item.type !== 'docs' &&
item.type !== 'story'
) {
Expand All @@ -38,7 +39,6 @@ export const Sidebar: FC<SidebarProps> = ({ children, item }) => {
if (item.parent) {
const parentItem = api.resolveStory(item.parent)
if (parentItem && parentItem.type !== 'root') {
// @ts-expect-error group entry tags hasn't yet been merged on SB.
parentTags = parentItem.tags
}
}
Expand Down
1 change: 1 addition & 0 deletions src/renderLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Sidebar } from './components/Sidebar'
export function renderLabel(item: API_HashEntry) {
if (
item.type !== 'story' &&
item.type !== 'group' &&
item.type !== 'docs' &&
item.type !== 'component'
) {
Expand Down
2 changes: 1 addition & 1 deletion src/stories/Page.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { within, userEvent } from '@storybook/test'
import { Page } from './Page'

const meta: Meta<typeof Page> = {
title: 'Example/Page',
title: 'Example/Page/Component',
component: Page,
parameters: {
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
Expand Down
7 changes: 7 additions & 0 deletions src/stories/PageLayout.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Meta } from '@storybook/blocks'

<Meta title="Example/Page/Layout" tags={['frog', 'new']} />

# Layout

This is a page about page layouts.
11 changes: 9 additions & 2 deletions src/useBadgesToDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { useMemo } from 'react'

import { DisplayOutcome, shouldDisplay } from './utils/display'
import { matchTags } from './utils/tag'
import { API_ComponentEntry, API_LeafEntry } from '@storybook/types'
import {
API_ComponentEntry,
API_GroupEntry,
API_LeafEntry,
} from '@storybook/types'
import { TagBadgeParameters } from './types/TagBadgeParameters'
import { BadgeOrBadgeFn } from './types/Badge'

Expand All @@ -11,7 +15,10 @@ interface UseBadgesToDisplayOptions {
parameters: TagBadgeParameters
parentTags?: string[]
tags: string[]
type: API_ComponentEntry['type'] | API_LeafEntry['type']
type:
| API_ComponentEntry['type']
| API_GroupEntry['type']
| API_LeafEntry['type']
}

type BadgesToDisplay = { badge: BadgeOrBadgeFn; tag: string }[]
Expand Down

0 comments on commit 44a5d5c

Please sign in to comment.