-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: custom docs rendering instead of autodocs for API (#756)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new documentation pages for the Button and ButtonIcon components in Storybook. - Enhanced control configuration in Storybook for better customization and usability. - Added a new `AutoDoc` component for generating structured documentation for UI components. - **Bug Fixes** - Updated import paths for several helper modules across multiple documentation files to ensure correct resolution. - **Refactor** - Improved structure and organization of story definitions for the Button and ButtonIcon components. - Simplified Storybook configuration by removing unnecessary properties. - **Chores** - Updated the package configuration to support ECMAScript modules. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
19 changed files
with
139 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Controls, Primary, Unstyled } from "@storybook/blocks"; | ||
import { Pill } from "@versini/ui-pill"; | ||
import { Flexgrid, FlexgridItem } from "@versini/ui-system"; | ||
|
||
import Highlight from "./Highlight"; | ||
|
||
interface AutoDocProps { | ||
importName: string; | ||
|
||
header?: string; | ||
importPackage?: string; | ||
stage?: "alpha" | "beta" | "stable"; | ||
} | ||
|
||
export default ({ importName, importPackage, stage, header }: AutoDocProps) => { | ||
const packageName = importPackage || `ui-${importName.toLowerCase()}`; | ||
const titleHeader = header || importName; | ||
let variant: "information" | "warning" | "success", releaseTag; | ||
switch (stage) { | ||
case "beta": | ||
variant = "information"; | ||
releaseTag = "beta"; | ||
break; | ||
case "stable": | ||
variant = "success"; | ||
releaseTag = "stable"; | ||
break; | ||
default: | ||
variant = "warning"; | ||
releaseTag = "alpha"; | ||
break; | ||
} | ||
return ( | ||
<> | ||
<Unstyled> | ||
<div className="prose"> | ||
<Flexgrid alignVertical="center" className="mb-2" columnGap={3}> | ||
<FlexgridItem> | ||
<h1 className="m-0">{titleHeader}</h1> | ||
</FlexgridItem> | ||
<FlexgridItem> | ||
<Pill label={releaseTag} variant={variant} className="mt-2" /> | ||
</FlexgridItem> | ||
</Flexgrid> | ||
|
||
<div className="prose"> | ||
<Highlight | ||
codeBlock={`import { ${importName} } from "@versini/${packageName}";`} | ||
/> | ||
</div> | ||
</div> | ||
</Unstyled> | ||
<Primary /> | ||
<Controls /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Meta } from "@storybook/blocks"; | ||
|
||
import AutoDoc from "../helpers/AutoDoc"; | ||
import * as Stories from "./Button.stories"; | ||
|
||
<Meta title="Components/Button" of={Stories} /> | ||
<AutoDoc importName="Button" stage="stable" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,53 @@ | ||
import type { Meta } from "@storybook/react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { fn } from "@storybook/test"; | ||
|
||
import { Button } from "@versini/ui-button/src/components"; | ||
|
||
type Story = StoryObj<typeof Button>; | ||
|
||
const meta: Meta<typeof Button> = { | ||
parameters: { | ||
layout: "centered", | ||
docs: { | ||
controls: { exclude: ["spacing"] }, | ||
}, | ||
}, | ||
title: "Components/Button", | ||
|
||
component: Button, | ||
args: { children: "Button", onClick: fn() }, | ||
args: { onClick: fn() }, | ||
}; | ||
|
||
export default meta; | ||
export const Basic = (args: React.ComponentProps<typeof Button>) => ( | ||
<div className="flex flex-wrap gap-2"> | ||
<Button {...args}>Button lorem ipsum</Button> | ||
<Button {...args}>Button lorem ipsum dolor</Button> | ||
<Button {...args}>Button lorem ipsum dolor sit amet</Button> | ||
</div> | ||
); | ||
|
||
export const Truncate = (args: React.ComponentProps<typeof Button>) => { | ||
args.className = "w-44 sm:w-52"; | ||
return ( | ||
<> | ||
<p>For text to truncate, you need to limit the width of the buttons.</p> | ||
<p>This can be done by using Tailwind width classes, for example</p> | ||
<code>className={args.className}</code> | ||
export const Basic: Story = { | ||
render: (args) => ( | ||
<div className="flex flex-wrap gap-2"> | ||
<Button {...args}>Button lorem ipsum</Button> | ||
<Button {...args}>Button lorem ipsum dolor</Button> | ||
<Button {...args}>Button lorem ipsum dolor sit amet</Button> | ||
</div> | ||
), | ||
}; | ||
|
||
<div className="flex flex-wrap gap-2"> | ||
<Button {...args}>Button lorem ipsum</Button> | ||
<Button {...args}>Button lorem ipsum dolor</Button> | ||
<Button {...args}>Button lorem ipsum dolor sit amet</Button> | ||
</div> | ||
</> | ||
); | ||
export const Truncate: Story = { | ||
args: { className: "w-44 sm:w-52" }, | ||
render: (args) => { | ||
return ( | ||
<> | ||
<div className="flex flex-wrap gap-2"> | ||
<Button {...args}>Button lorem ipsum</Button> | ||
<Button {...args}>Button lorem ipsum dolor</Button> | ||
<Button {...args}>Button lorem ipsum dolor sit amet</Button> | ||
</div> | ||
<div className="pt-4"> | ||
<p> | ||
For text to truncate, you need to limit the width of the buttons. | ||
</p> | ||
<p>This can be done by using Tailwind width classes, for example</p> | ||
<code>className={args.className}</code> | ||
</div> | ||
</> | ||
); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Meta } from "@storybook/blocks"; | ||
|
||
import AutoDoc from "../helpers/AutoDoc"; | ||
import * as Stories from "./ButtonIcon.stories"; | ||
|
||
<Meta title="Components/ButtonIcon" of={Stories} /> | ||
<AutoDoc importName="ButtonIcon" importPackage="ui-button" stage="stable" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
import type { Meta } from "@storybook/react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { fn } from "@storybook/test"; | ||
|
||
import { ButtonIcon } from "@versini/ui-button/src/components"; | ||
import { IconSettings } from "@versini/ui-icons"; | ||
|
||
type Story = StoryObj<typeof ButtonIcon>; | ||
|
||
const meta: Meta<typeof ButtonIcon> = { | ||
parameters: { | ||
layout: "centered", | ||
docs: { | ||
controls: { exclude: ["spacing"] }, | ||
}, | ||
}, | ||
title: "Components/ButtonIcon", | ||
|
||
component: ButtonIcon, | ||
args: { onClick: fn() }, | ||
}; | ||
|
||
export default meta; | ||
export const Basic = (args: React.ComponentProps<typeof ButtonIcon>) => ( | ||
<ButtonIcon {...args}> | ||
<IconSettings /> | ||
</ButtonIcon> | ||
); | ||
export const Basic: Story = { | ||
render: (args) => ( | ||
<ButtonIcon {...args}> | ||
<IconSettings /> | ||
</ButtonIcon> | ||
), | ||
}; |