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

docs: ability to assign badges to stories and dropdown as an example #475

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .storybook/manager.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.componentTag__container--beta {
position: static;
}

.componentTag__badge--beta {
font-size: 12px;
font-weight: 500;
margin-top: -13px;
padding: 0 6px;
background-color: #faad14;
}

.componentTag__badge--beta > .ant-ribbon-corner {
color: #faad14;
}
6 changes: 0 additions & 6 deletions .storybook/manager.ts

This file was deleted.

28 changes: 28 additions & 0 deletions .storybook/manager.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import { addons } from '@storybook/manager-api'
import customTheme from './theme'
import { Badge } from 'antd'

import './manager.css'

addons.setConfig({
theme: customTheme,
sidebar: {
renderLabel: item => {
if (item.tags?.includes('deprecated')) {
return (
<div title={item.name}>
<span>{item.name}</span>
<Badge.Ribbon
rootClassName="componentTag__container--beta"
className="componentTag__badge--beta"
text="Deprecated"
/>
</div>
)
}

return item.name
},
},
})
2 changes: 0 additions & 2 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ const preview: Preview = {
},
},
},

tags: ['autodocs'],
Comment on lines -55 to -56
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was recently added while upgrading Storybook versions but it was adding default blank Documentation page files for all component stories. We are doing that manually while we work on documenting components so I'm removing this config.

}

export default preview
10 changes: 6 additions & 4 deletions src/components/navigation/Dropdown/Dropdown.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { type ReactNode } from 'react'
import type { ReactNode } from 'react'
import { cloneElement } from 'react'
import { useState } from 'react'
import { type Meta, type StoryObj } from '@storybook/react'
import type { Meta, StoryObj } from '@storybook/react'
import { Button } from 'src/components/general/Button/Button'
import { Dropdown, type IDropdownProps } from 'src/components/navigation/Dropdown/Dropdown'
import { ExampleStory } from 'src/utils/ExampleStory'
import { Tooltip, type IMenuProps, Icon } from 'src/components'
import { Space } from 'src/components'
import { Divider } from 'src/components'
import { theme } from 'antd'
import { type MenuProps } from 'antd'
import type { MenuProps } from 'antd'
import { Typography } from 'src/components/general/Typography/Typography'

const menu: IDropdownProps['menu'] = {
Expand Down Expand Up @@ -93,7 +93,9 @@ type Story = StoryObj<typeof Dropdown>
Customize the stories based on specific requirements.
*/

export const Primary: Story = {}
export const Primary: Story = {
tags: ['deprecated'],
}

export const WithArrow: Story = {
args: {
Expand Down
Loading