Skip to content

Commit

Permalink
docs(react): update doc for Delay (#198)
Browse files Browse the repository at this point in the history
* docs(react): update doc for Delay

* docs: update

* Create orange-pants-vanish.md
  • Loading branch information
manudeli authored Oct 7, 2023
1 parent 56687a3 commit b05b4e2
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-pants-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@suspensive/react": patch
---

docs(react): update doc for Delay
53 changes: 51 additions & 2 deletions packages/react/src/Delay.en.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,63 @@ sidebar_position: 5
title: <Delay/>
---

This component delays when children are exposed.
### props.ms

This component delays the exposure of children by ms. In the code below, exposure of children is delayed by 200ms.

```tsx
import { Delay } from '@suspensive/react'

const Example = () => (
<Delay ms={2000}>
<Delay ms={200}>
<Delayed />
</Delay>
)
```

:::info

#### Delayed loading UI sometimes provides better usability

```tsx
import { Delay, Suspense } from '@suspensive/react'

const Example = () => (
<Suspense
fallback={
<Delay ms={200}>
<Skeleton />
</Delay>
}
>
...
</Suspense>
)
```

:::

:::tip

### Default ms

`<Delay/>` are more powerful when used with `<SuspensiveProvider/>`. Control multiple `<Delay/>`s default ms with `<SuspensiveProvider/>`. Details are introduced in [`<SuspensiveProvider/>` page](./SuspensiveProvider.i18n).

:::

## withDelay

We can use withDelay to wrap component by `<Delay/>` easily.
we don't need to make unncessary code to wrap it if we use withDelay like below.
withDelay's 2nd parameter is props of `<Delay/>` without children

```tsx
import { withDelay } from '@suspensive/react'

const Example = withDelay(
function Component() {
return <>...</>
},
{ ms: 200 }
)
```
53 changes: 51 additions & 2 deletions packages/react/src/Delay.ko.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,63 @@ sidebar_position: 5
title: <Delay/>
---

이 컴포넌트는 children이 노출되는 시점을 지연시킵니다.
### props.ms

이 컴포넌트는 children이 노출되는 시점을 ms만큼 지연시킵니다. 아래와 같은 코드에서는 200ms만큼 children 노출이 지연됩니다.

```tsx
import { Delay } from '@suspensive/react'

const Example = () => (
<Delay ms={2000}>
<Delay ms={200}>
<Delayed />
</Delay>
)
```

:::info

#### 로딩 UI가 지연되어 노출되는 것이 때에 따라 더 좋은 사용성을 제공합니다

```tsx
import { Delay, Suspense } from '@suspensive/react'

const Example = () => (
<Suspense
fallback={
<Delay ms={200}>
<Skeleton />
</Delay>
}
>
...
</Suspense>
)
```

:::

:::tip

### Default ms

`<Delay/>``<SuspensiveProvider/>`와 함께 사용할 때 더욱 강력해집니다. `<SuspensiveProvider/>`를 사용하여 여러 `<Delay/>` default ms를 제어합니다. 자세한 내용은 [`<SuspensiveProvider/>` 페이지](./SuspensiveProvider.i18n)에 소개되어 있습니다.

:::

## withDelay

withDelay를 사용하면 컴포넌트를 `<Delay/>`로 쉽게 래핑할 수 있습니다.
아래와 같이 withDelay를 사용하면 이를 감싸기 위해 불필요한 코드를 만들 필요가 없습니다.
withDelay의 두 번째 인자는 children이 없는 `<Delay/>`의 props입니다.

```tsx
import { withDelay } from '@suspensive/react'

const Example = withDelay(
function Component() {
return <>...</>
},
{ ms: 200 }
)
```

2 comments on commit b05b4e2

@vercel
Copy link

@vercel vercel bot commented on b05b4e2 Oct 7, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

visualization – ./websites/visualization

visualization-suspensive.vercel.app
visualization-git-main-suspensive.vercel.app
visualization.suspensive.org

@vercel
Copy link

@vercel vercel bot commented on b05b4e2 Oct 7, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

docs – ./websites/docs

docs-git-main-suspensive.vercel.app
docs-suspensive.vercel.app
www.suspensive.org
suspensive.org
docs.suspensive.org

Please sign in to comment.