-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated documentation for
Toast
component (#2261)
Co-authored-by: Rohan <[email protected]> Co-authored-by: Mayank <[email protected]> Co-authored-by: Uyen Doan <[email protected]> Co-authored-by: Rohan <[email protected]>
- Loading branch information
1 parent
f03975a
commit 090aa3d
Showing
19 changed files
with
442 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.demo-container { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from 'react'; | ||
import { useToaster, Button } from '@itwin/itwinui-react'; | ||
|
||
export default () => { | ||
const toaster = useToaster(); | ||
const buttonRef = React.useRef(null); | ||
|
||
React.useEffect(() => { | ||
toaster.setSettings({ | ||
placement: 'top-end', | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<div className='demo-container'> | ||
<Button | ||
ref={buttonRef} | ||
onClick={() => | ||
toaster.positive('This is a positive toast message', { | ||
animateOutTo: buttonRef.current, | ||
}) | ||
} | ||
> | ||
Anchor to button | ||
</Button> | ||
</div> | ||
); | ||
}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from 'react'; | ||
import { useToaster, Button, Flex, ProgressRadial } from '@itwin/itwinui-react'; | ||
|
||
export default () => { | ||
const toaster = useToaster(); | ||
|
||
const displayProcessToast = () => { | ||
const { close } = toaster.informational( | ||
<Flex> | ||
<ProgressRadial size='small' /> | ||
Your process is running... | ||
</Flex>, | ||
); | ||
|
||
setTimeout(() => { | ||
close(); | ||
toaster.positive('Process completed', { | ||
hasCloseButton: true, | ||
}); | ||
}, 1000); | ||
}; | ||
|
||
return <Button onClick={displayProcessToast}>Start process</Button>; | ||
}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.demo-container { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
gap: var(--iui-size-xs); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from 'react'; | ||
import { useToaster, Button } from '@itwin/itwinui-react'; | ||
|
||
export default () => { | ||
const toaster = useToaster(); | ||
|
||
return ( | ||
<div className='demo-container'> | ||
<Button onClick={() => toaster.positive('Job 1 processing completed.')}> | ||
Open toast 1 | ||
</Button> | ||
<Button onClick={() => toaster.positive('Job 2 processing completed.')}> | ||
Open toast 2 | ||
</Button> | ||
<Button onClick={() => toaster.closeAll()}>Close All</Button> | ||
</div> | ||
); | ||
}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from 'react'; | ||
import { useToaster, Button } from '@itwin/itwinui-react'; | ||
|
||
export default () => { | ||
const toaster = useToaster(); | ||
|
||
return ( | ||
<div className='demo-container'> | ||
<Button | ||
onClick={() => | ||
toaster.positive('This is a positive message', { | ||
hasCloseButton: true, | ||
}) | ||
} | ||
> | ||
Open toast | ||
</Button> | ||
</div> | ||
); | ||
}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from 'react'; | ||
import { useToaster, Button } from '@itwin/itwinui-react'; | ||
|
||
export default () => { | ||
const toaster = useToaster(); | ||
|
||
const displayToast = () => { | ||
toaster.positive('Job processing completed.', { | ||
link: { | ||
title: 'Link', | ||
onClick: () => { | ||
alert('Link was clicked!'); | ||
}, | ||
}, | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className='demo-container'> | ||
<Button onClick={displayToast}>Toast with link</Button> | ||
</div> | ||
); | ||
}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.demo-container { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
} |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.demo-container { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
gap: var(--iui-size-xs); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from 'react'; | ||
import { useToaster, Button, Select } from '@itwin/itwinui-react'; | ||
|
||
export default () => { | ||
const toaster = useToaster(); | ||
|
||
return ( | ||
<div className='demo-container'> | ||
<Select | ||
triggerProps={{ | ||
'aria-label': 'Order', | ||
}} | ||
placeholder='Select order' | ||
options={[ | ||
{ value: 'ascending', label: 'Ascending' }, | ||
{ value: 'descending', label: 'Descending' }, | ||
{ value: 'auto', label: 'Auto' }, | ||
]} | ||
onChange={(value) => | ||
toaster.setSettings({ | ||
order: value, | ||
}) | ||
} | ||
/> | ||
<Button onClick={() => toaster.informational('This is a toast message.')}> | ||
Open toast | ||
</Button> | ||
</div> | ||
); | ||
}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.demo-container { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
gap: var(--iui-size-xs); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as React from 'react'; | ||
import { useToaster, Button, Select } from '@itwin/itwinui-react'; | ||
|
||
export default () => { | ||
const toaster = useToaster(); | ||
|
||
return ( | ||
<div className='demo-container'> | ||
<Select | ||
placeholder='Select placement' | ||
triggerProps={{ | ||
'aria-label': 'Placement', | ||
}} | ||
options={[ | ||
{ value: 'top', label: 'Top' }, | ||
{ value: 'top-start', label: 'Top start' }, | ||
{ value: 'top-end', label: 'Top end' }, | ||
{ value: 'bottom', label: 'Bottom' }, | ||
{ value: 'bottom-start', label: 'Bottom start' }, | ||
{ value: 'bottom-end', label: 'Bottom end' }, | ||
]} | ||
onChange={(value) => | ||
toaster.setSettings({ | ||
placement: value, | ||
}) | ||
} | ||
/> | ||
<Button onClick={() => toaster.informational('This is a toast message.')}> | ||
Open toast | ||
</Button> | ||
</div> | ||
); | ||
}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.demo-container { | ||
display: flex; | ||
gap: var(--iui-size-xs); | ||
} |
Oops, something went wrong.