Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(website/mdx-components): create table component for toast page #1310

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions website/components/mdx-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,44 @@ const components: Record<string, FC<any>> = {
ContextTable(props) {
return <PropTable type="context" {...props} />
},
DefaultValuesTable: ({
tableData,
}: {
tableData: {
headings: string[]
data: Array<[string, string]>
}
}) => {
const { data, headings } = tableData

return (
<table>
<thead>
<tr>
{headings.map((heading) => (
<th key={heading}>{heading}</th>
))}
</tr>
</thead>
<tbody>
{data.map(([prop, value], idx) => (
<tr key={idx}>
<td>
<chakra.code className="prose" layerStyle="inlineCode">
{prop}
</chakra.code>
</td>
<td>
<chakra.code fontSize="sm" whiteSpace="pre-wrap">
{value}
</chakra.code>
</td>
</tr>
))}
</tbody>
</table>
)
},
code(props) {
if (typeof props.children === "string") {
return <components.inlineCode {...props} />
Expand Down
23 changes: 14 additions & 9 deletions website/data/components/toast.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,20 @@ The options you can pass in are:
## Setting custom duration

Every toast has a default visible duration depending on the `type` set. Here's
the table showing the toast type and duration.

| type | duration |
| --------- | ---------- |
| `info` | `5000` |
| `error` | `5000` |
| `success` | `2000` |
| `custom` | `5000` |
| `loading` | `Infinity` |
the following toast types and matching default durations:

<DefaultValuesTable
tableData={{
headings: ['type', 'duration'],
data: [
['info', '5000'],
['error', '5000'],
['success', '2000'],
['custom', '5000'],
['loading', 'Infinity'],
]
}}
/>

You can override the duration of the toast by passing the `duration` property to
the `toast.create(...)` function.
Expand Down
Loading