feat: use separated file for examples
This commit is contained in:
parent
3aacc3ff83
commit
425f1325c9
@ -1,7 +1,9 @@
|
|||||||
import { Button } from "@components/Button";
|
import { Button } from "@components/Button";
|
||||||
import { TabProvider, TabTrigger, TabContent, TabList } from "@components/Tabs";
|
import { TabProvider, TabTrigger, TabContent, TabList } from "@components/Tabs";
|
||||||
import { Story } from "@/components/Story";
|
import { Story } from "@/components/Story";
|
||||||
import { LoadedCode } from "@/components/LoadedCode";
|
import { LoadedCode, GITHUB } from "@/components/LoadedCode";
|
||||||
|
import { ButtonDemo } from "./ButtonBlocks/Preview";
|
||||||
|
import Examples from "./ButtonBlocks/Examples";
|
||||||
|
|
||||||
# Button
|
# Button
|
||||||
Displays a button or a component that looks like a button.
|
Displays a button or a component that looks like a button.
|
||||||
@ -13,17 +15,11 @@ Displays a button or a component that looks like a button.
|
|||||||
</TabList>
|
</TabList>
|
||||||
<TabContent name="preview">
|
<TabContent name="preview">
|
||||||
<Story layout="centered">
|
<Story layout="centered">
|
||||||
<Button>Button</Button>
|
<ButtonDemo />
|
||||||
</Story>
|
</Story>
|
||||||
</TabContent>
|
</TabContent>
|
||||||
<TabContent name="code">
|
<TabContent name="code">
|
||||||
```tsx
|
<LoadedCode from={`${GITHUB}/packages/react/src/docs/components/ButtonBlocks/Preview.tsx`} />
|
||||||
import { Button } from "@components/Button";
|
|
||||||
|
|
||||||
export function ButtonDemo() {
|
|
||||||
return <Button>Button</Button>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
</TabContent>
|
</TabContent>
|
||||||
</TabProvider>
|
</TabProvider>
|
||||||
|
|
||||||
@ -32,7 +28,7 @@ Displays a button or a component that looks like a button.
|
|||||||
1. Create a new file `Button.tsx` in your component folder.
|
1. Create a new file `Button.tsx` in your component folder.
|
||||||
2. Copy and paste the following code into the file.
|
2. Copy and paste the following code into the file.
|
||||||
|
|
||||||
<LoadedCode from="https://raw.githubusercontent.com/p-sw/ui/main/packages/react/components/Button.tsx" />
|
<LoadedCode from={`${GITHUB}/packages/react/components/Button.tsx`} />
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -73,17 +69,11 @@ import { Button } from "@components/Button";
|
|||||||
</TabList>
|
</TabList>
|
||||||
<TabContent name="preview">
|
<TabContent name="preview">
|
||||||
<Story layout="centered">
|
<Story layout="centered">
|
||||||
<Button>Button</Button>
|
<Examples.Default />
|
||||||
</Story>
|
</Story>
|
||||||
</TabContent>
|
</TabContent>
|
||||||
<TabContent name="code">
|
<TabContent name="code">
|
||||||
```tsx
|
<LoadedCode from={`${GITHUB}/packages/react/src/docs/components/ButtonBlocks/Examples/Default.tsx`} />
|
||||||
import { Button } from "@components/Button";
|
|
||||||
|
|
||||||
export function ButtonDemo() {
|
|
||||||
return <Button preset="default">Button</Button>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
</TabContent>
|
</TabContent>
|
||||||
</TabProvider>
|
</TabProvider>
|
||||||
|
|
||||||
@ -96,17 +86,11 @@ export function ButtonDemo() {
|
|||||||
</TabList>
|
</TabList>
|
||||||
<TabContent name="preview">
|
<TabContent name="preview">
|
||||||
<Story layout="centered">
|
<Story layout="centered">
|
||||||
<Button preset="ghost">Button</Button>
|
<Examples.Ghost />
|
||||||
</Story>
|
</Story>
|
||||||
</TabContent>
|
</TabContent>
|
||||||
<TabContent name="code">
|
<TabContent name="code">
|
||||||
```tsx
|
<LoadedCode from={`${GITHUB}/packages/react/src/docs/components/ButtonBlocks/Examples/Ghost.tsx`} />
|
||||||
import { Button } from "@components/Button";
|
|
||||||
|
|
||||||
export function ButtonDemo() {
|
|
||||||
return <Button preset="ghost">Button</Button>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
</TabContent>
|
</TabContent>
|
||||||
</TabProvider>
|
</TabProvider>
|
||||||
|
|
||||||
@ -119,17 +103,11 @@ export function ButtonDemo() {
|
|||||||
</TabList>
|
</TabList>
|
||||||
<TabContent name="preview">
|
<TabContent name="preview">
|
||||||
<Story layout="centered">
|
<Story layout="centered">
|
||||||
<Button preset="link">Button</Button>
|
<Examples.Link />
|
||||||
</Story>
|
</Story>
|
||||||
</TabContent>
|
</TabContent>
|
||||||
<TabContent name="code">
|
<TabContent name="code">
|
||||||
```tsx
|
<LoadedCode from={`${GITHUB}/packages/react/src/docs/components/ButtonBlocks/Examples/Link.tsx`} />
|
||||||
import { Button } from "@components/Button";
|
|
||||||
|
|
||||||
export function ButtonDemo() {
|
|
||||||
return <Button preset="link">Button</Button>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
</TabContent>
|
</TabContent>
|
||||||
</TabProvider>
|
</TabProvider>
|
||||||
|
|
||||||
@ -142,17 +120,11 @@ export function ButtonDemo() {
|
|||||||
</TabList>
|
</TabList>
|
||||||
<TabContent name="preview">
|
<TabContent name="preview">
|
||||||
<Story layout="centered">
|
<Story layout="centered">
|
||||||
<Button preset="success">Button</Button>
|
<Examples.Success />
|
||||||
</Story>
|
</Story>
|
||||||
</TabContent>
|
</TabContent>
|
||||||
<TabContent name="code">
|
<TabContent name="code">
|
||||||
```tsx
|
<LoadedCode from={`${GITHUB}/packages/react/src/docs/components/ButtonBlocks/Examples/Success.tsx`} />
|
||||||
import { Button } from "@components/Button";
|
|
||||||
|
|
||||||
export function ButtonDemo() {
|
|
||||||
return <Button preset="success">Button</Button>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
</TabContent>
|
</TabContent>
|
||||||
</TabProvider>
|
</TabProvider>
|
||||||
|
|
||||||
@ -165,17 +137,11 @@ export function ButtonDemo() {
|
|||||||
</TabList>
|
</TabList>
|
||||||
<TabContent name="preview">
|
<TabContent name="preview">
|
||||||
<Story layout="centered">
|
<Story layout="centered">
|
||||||
<Button preset="warning">Button</Button>
|
<Examples.Warning />
|
||||||
</Story>
|
</Story>
|
||||||
</TabContent>
|
</TabContent>
|
||||||
<TabContent name="code">
|
<TabContent name="code">
|
||||||
```tsx
|
<LoadedCode from={`${GITHUB}/packages/react/src/docs/components/ButtonBlocks/Examples/Warning.tsx`} />
|
||||||
import { Button } from "@components/Button";
|
|
||||||
|
|
||||||
export function ButtonDemo() {
|
|
||||||
return <Button preset="warning">Button</Button>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
</TabContent>
|
</TabContent>
|
||||||
</TabProvider>
|
</TabProvider>
|
||||||
|
|
||||||
@ -188,16 +154,10 @@ export function ButtonDemo() {
|
|||||||
</TabList>
|
</TabList>
|
||||||
<TabContent name="preview">
|
<TabContent name="preview">
|
||||||
<Story layout="centered">
|
<Story layout="centered">
|
||||||
<Button preset="danger">Button</Button>
|
<Examples.Danger />
|
||||||
</Story>
|
</Story>
|
||||||
</TabContent>
|
</TabContent>
|
||||||
<TabContent name="code">
|
<TabContent name="code">
|
||||||
```tsx
|
<LoadedCode from={`${GITHUB}/packages/react/src/docs/components/ButtonBlocks/Examples/Danger.tsx`} />
|
||||||
import { Button } from "@components/Button";
|
|
||||||
|
|
||||||
export function ButtonDemo() {
|
|
||||||
return <Button preset="danger">Button</Button>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
</TabContent>
|
</TabContent>
|
||||||
</TabProvider>
|
</TabProvider>
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
import { Button } from "@components/Button";
|
||||||
|
|
||||||
|
export const Danger = () => {
|
||||||
|
return <Button preset="danger">Danger</Button>;
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
import { Button } from "@components/Button";
|
||||||
|
|
||||||
|
export const Default = () => {
|
||||||
|
return <Button preset="default">Default</Button>;
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
import { Button } from "@components/Button";
|
||||||
|
|
||||||
|
export const Ghost = () => {
|
||||||
|
return <Button preset="ghost">Ghost</Button>;
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
import { Button } from "@components/Button";
|
||||||
|
|
||||||
|
export const Link = () => {
|
||||||
|
return <Button preset="link">Link</Button>;
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
import { Button } from "@components/Button";
|
||||||
|
|
||||||
|
export const Success = () => {
|
||||||
|
return <Button preset="success">Success</Button>;
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
import { Button } from "@components/Button";
|
||||||
|
|
||||||
|
export const Warning = () => {
|
||||||
|
return <Button preset="warning">Warning</Button>;
|
||||||
|
};
|
@ -0,0 +1,16 @@
|
|||||||
|
import { Danger } from "./Danger";
|
||||||
|
import { Warning } from "./Warning";
|
||||||
|
import { Success } from "./Success";
|
||||||
|
import { Link } from "./Link";
|
||||||
|
import { Ghost } from "./Ghost";
|
||||||
|
import { Default } from "./Default";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
Danger,
|
||||||
|
Warning,
|
||||||
|
Success,
|
||||||
|
Link,
|
||||||
|
Ghost,
|
||||||
|
Default,
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,5 @@
|
|||||||
|
import { Button } from "@components/Button";
|
||||||
|
|
||||||
|
export function ButtonDemo() {
|
||||||
|
return <Button>Button</Button>;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user