Skip to content

Commit

Permalink
docs(website/mdx-components): create table component for toast page (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerAPfledderer authored and colinlienard committed Jun 18, 2024
1 parent 959a398 commit 4582059
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 9 deletions.
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

0 comments on commit 4582059

Please sign in to comment.