-
Notifications
You must be signed in to change notification settings - Fork 2.9k
docs: Add usable documentation #28155
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
89f6434
docs: Add usable documentation
ling1726 d06e050
update api md file
ling1726 9c8dfad
Add unstable notice
ling1726 0b81c79
props table, better offset story
ling1726 1d7cd9a
hack to add toast stories to storybook
ling1726 b2e7f12
remove console.log
ling1726 21354fa
remove hack
ling1726 7261fe8
fix toaster limit
ling1726 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 42 additions & 5 deletions
47
packages/react-components/react-toast/stories/Toast/CustomTimeout.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,59 @@ | ||
| import * as React from 'react'; | ||
| import { Toaster, useToastController, ToastTitle, Toast } from '@fluentui/react-toast'; | ||
| import { useId } from '@fluentui/react-components'; | ||
| import { Toaster, useToastController, ToastTitle, Toast, ToastTrigger } from '@fluentui/react-toast'; | ||
| import { useId, Button, Link, SpinButton, Field } from '@fluentui/react-components'; | ||
|
|
||
| export const CustomTimeout = () => { | ||
| const [timeout, setDismissTimeout] = React.useState(1000); | ||
| const toasterId = useId('toaster'); | ||
| const { dispatchToast } = useToastController(toasterId); | ||
| const notify = () => | ||
| dispatchToast( | ||
| <Toast> | ||
| <ToastTitle intent="info">Custom timeout 1000ms</ToastTitle> | ||
| <ToastTitle | ||
| action={ | ||
| <ToastTrigger> | ||
| <Link>Dismiss</Link> | ||
| </ToastTrigger> | ||
| } | ||
| intent="info" | ||
| > | ||
| {timeout >= 0 ? `Custom timeout ${timeout}ms` : `Dismiss manually`} | ||
| </ToastTitle> | ||
| </Toast>, | ||
| { timeout: 1000 }, | ||
| { timeout }, | ||
| ); | ||
|
|
||
| return ( | ||
| <> | ||
| <Field label="Timeout" hint="Timeout is in milliseconds"> | ||
| <SpinButton | ||
| value={timeout} | ||
| onChange={(e, data) => { | ||
| if (data.value) { | ||
| setDismissTimeout(data.value); | ||
| } else if (data.displayValue !== undefined) { | ||
| const newValue = parseFloat(data.displayValue); | ||
| if (!Number.isNaN(newValue)) { | ||
| setDismissTimeout(newValue); | ||
| } | ||
| } | ||
| }} | ||
| /> | ||
| </Field> | ||
| <br /> | ||
| <Toaster toasterId={toasterId} /> | ||
| <button onClick={notify}>Make toast</button> | ||
| <Button onClick={notify}>Make toast</Button> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| CustomTimeout.parameters = { | ||
| docs: { | ||
| description: { | ||
| story: [ | ||
| 'The timeout of toasts can be customized in milliseconds. Using a negative timeout value results in the toast', | ||
| 'never being auto-dismissed.', | ||
| ].join('\n'), | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.