Skip to content

Commit

Permalink
docs(primitives): add storybook documentation (#2094)
Browse files Browse the repository at this point in the history
<!--
  How to write a good PR title:
- Follow [the Conventional Commits
specification](https://www.conventionalcommits.org/en/v1.0.0/).
  - Give as much context as necessary and as little as possible
  - Prefix it with [WIP] while it’s a work in progress
-->

## Self Checklist

- [x] I wrote a PR title in **English** and added an appropriate
**label** to the PR.
- [x] I wrote the commit message in **English** and to follow [**the
Conventional Commits
specification**](https://www.conventionalcommits.org/en/v1.0.0/).
- [x] I [added the
**changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)
about the changes that needed to be released. (or didn't have to)
- [x] I wrote or updated **documentation** related to the changes. (or
didn't have to)
- [x] I wrote or updated **tests** related to the changes. (or didn't
have to)
- [x] I tested the changes in various browsers. (or didn't have to)
  - Windows: Chrome, Edge, (Optional) Firefox
  - macOS: Chrome, Edge, Safari, (Optional) Firefox

## Summary
<!-- Please brief explanation of the changes made -->

Dialog/TooltipPrimitive의 스토리북 문서를 추가합니다.

## Details
<!-- Please elaborate description of the changes -->

- 스토리북에 primitive 컴포넌트를 추가해서 다른 팀원들이 컴포넌트의 존재를 알 수 있도록 했습니다.
- 컴포넌트명이 radix-ui와 완벽하게 동일하지는 않기 때문에, 사용자의 이해를 돕고자 mdx를 사용, Anatomy 항목을
추가했습니다.
- 스토리북 전체: stories.mdx -> .mdx 로 일괄 변경했습니다.

### Breaking change? (Yes/No)
<!-- If Yes, please describe the impact and migration path for users -->

No
  • Loading branch information
sungik-choi authored Mar 20, 2024
1 parent d5f85e2 commit 67d6f4b
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/bezier-react/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function getAbsolutePath(value: string) {

export default {
stories: [
'../src/**/*.stories.(tsx|mdx)',
'../src/**/*.mdx',
'../src/**/*.stories.tsx',
],

addons: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Canvas, Meta } from '@storybook/blocks'

import * as DialogPrimitive from './DialogPrimitive.stories'

<Meta of={DialogPrimitive} />

# DialogPrimitive

`DialogPrimitive` is wrapper component for the radix-ui `Dialog` component. For more information, see [radix-ui documentation](https://www.radix-ui.com/primitives/docs/components/dialog).

<Canvas of={DialogPrimitive.Primary} />

## Anatomy

`DialogPrimitive` is a composition of several components:

```tsx
<DialogPrimitive>
<DialogPrimitiveTrigger />
<DialogPrimitivePortal>
<DialogPrimitiveOverlay />
<DialogPrimitiveContent>
<DialogPrimitiveTitle />
<DialogPrimitiveDescription />
<DialogPrimitiveClose />
</DialogPrimitiveContent>
</DialogPrimitivePortal>
</DialogPrimitive>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react'

import {
type Meta,
type StoryObj,
} from '@storybook/react'

import {
DialogPrimitive,
DialogPrimitiveClose,
DialogPrimitiveContent,
DialogPrimitiveDescription,
DialogPrimitiveOverlay,
DialogPrimitivePortal,
DialogPrimitiveTitle,
DialogPrimitiveTrigger,
} from './DialogPrimitive'

function DialogComposition() {
return (
<DialogPrimitive>
<DialogPrimitiveTrigger>Trigger</DialogPrimitiveTrigger>
<DialogPrimitivePortal>
<DialogPrimitiveOverlay style={{
position: 'fixed',
inset: 0,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
}}
/>
<DialogPrimitiveContent style={{
position: 'fixed',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
backgroundColor: 'white',
}}
>
<DialogPrimitiveTitle>Title</DialogPrimitiveTitle>
<DialogPrimitiveDescription>Description</DialogPrimitiveDescription>
<div>Content</div>
<DialogPrimitiveClose>Close</DialogPrimitiveClose>
</DialogPrimitiveContent>
</DialogPrimitivePortal>
</DialogPrimitive>
)
}

const meta: Meta<typeof DialogComposition> = {
component: DialogComposition,
}

export const Primary: StoryObj = {}

export default meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Canvas, Meta } from '@storybook/blocks'

import * as TooltipPrimitive from './TooltipPrimitive.stories'

<Meta of={TooltipPrimitive} />

# TooltipPrimitive

`TooltipPrimitive` is wrapper component for the radix-ui `Tooltip` component. For more information, see [radix-ui documentation](https://www.radix-ui.com/primitives/docs/components/tooltip).

<Canvas of={TooltipPrimitive.Primary} />

## Anatomy

`TooltipPrimitive` is a composition of several components:

```tsx
<TooltipPrimitiveProvider>
<TooltipPrimitive>
<TooltipPrimitiveTrigger />
<TooltipPrimitivePortal>
<TooltipPrimitiveContent>
<TooltipPrimitiveArrow />
</TooltipPrimitiveContent>
</TooltipPrimitivePortal>
</TooltipPrimitive>
</TooltipPrimitiveProvider>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react'

import {
type Meta,
type StoryObj,
} from '@storybook/react'

import {
TooltipPrimitive,
TooltipPrimitiveArrow,
TooltipPrimitiveContent,
TooltipPrimitivePortal,
TooltipPrimitiveProvider,
TooltipPrimitiveTrigger,
} from './TooltipPrimitive'

function TooltipComposition() {
return (
<TooltipPrimitiveProvider>
<TooltipPrimitive>
<TooltipPrimitiveTrigger>Trigger</TooltipPrimitiveTrigger>
<TooltipPrimitivePortal>
<TooltipPrimitiveContent>
Content
<TooltipPrimitiveArrow />
</TooltipPrimitiveContent>
</TooltipPrimitivePortal>
</TooltipPrimitive>
</TooltipPrimitiveProvider>
)
}

const meta: Meta<typeof TooltipComposition> = {
component: TooltipComposition,
}

export const Primary: StoryObj = {}

export default meta

0 comments on commit 67d6f4b

Please sign in to comment.