docs: migrate UI docs (#13245)
* docs: create a new UI docs project (#13233) * docs: create a new UI docs project * fix installation errors * docs: migrate UI docs content to new project (#13241) * Fix content * added examples for some components * finish adding examples * lint fix * fix build errors * delete empty files * path fixes + refactor * fix build error
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { HookValues } from "@/components/HookValues"
|
||||
import { ComponentReference } from "@/components/ComponentReference"
|
||||
import { ComponentExample } from "@/components/ComponentExample"
|
||||
|
||||
export const metadata = {
|
||||
title: `usePrompt`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
|
||||
|
||||
This hook returns a function that prompts the user to confirm an action.
|
||||
|
||||
In this guide, you'll learn how to use the `usePrompt` hook.
|
||||
|
||||
<ComponentExample name="use-prompt-demo" />
|
||||
|
||||
## Usage
|
||||
|
||||
```tsx
|
||||
import { usePrompt } from "@medusajs/ui"
|
||||
```
|
||||
|
||||
```tsx
|
||||
const dialog = usePrompt()
|
||||
const actionFunction = async () => {
|
||||
const confirmed = await dialog({
|
||||
title: "Are you sure?",
|
||||
description: "Please confirm this action",
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API Reference
|
||||
|
||||
### usePrompt Return Value
|
||||
|
||||
<HookValues hook="usePromptReturn" />
|
||||
|
||||
### Returned Dialog Parameters
|
||||
|
||||
The dialog function returned by `usePrompt` accepts an object having the following properties:
|
||||
|
||||
<ComponentReference mainComponent="RenderPrompt" />
|
||||
|
||||
### Dialog Return Value
|
||||
|
||||
The dialog function returns a Promise that resolves to a boolean indicating whether the user confirmed the action.
|
||||
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
### Prompt with Verification Text
|
||||
|
||||
<ComponentExample name="use-prompt-verification" hideFeedback />
|
||||
@@ -0,0 +1,38 @@
|
||||
import { HookValues } from "@/components/HookValues"
|
||||
import { ComponentExample } from "@/components/ComponentExample"
|
||||
|
||||
export const metadata = {
|
||||
title: `useToggleState`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
This hook tracks a boolean value and toggles between its two states.
|
||||
|
||||
This guide explains how to use the `useToggleState` hook.
|
||||
|
||||
For example, you can use this hook to display a checkbox or a [Switch](../../components/switch/page.mdx) that toggles a [Focus Modal](../../components/focus-modal/page.mdx).
|
||||
|
||||
<ComponentExample name="use-toggle-state-demo" hideFeedback />
|
||||
|
||||
## Usage
|
||||
|
||||
```tsx
|
||||
import { useToggleState } from "@medusajs/ui"
|
||||
```
|
||||
|
||||
```tsx
|
||||
const [state, open, close, toggle] = useToggleState()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API Reference
|
||||
|
||||
### useToggleState Parameters
|
||||
|
||||
<HookValues hook="useToggleStateProps" />
|
||||
|
||||
### useToggleState Return Value
|
||||
|
||||
<HookValues hook="useToggleStateReturn" hideFeedback />
|
||||
Reference in New Issue
Block a user