Skip to content

Commit

Permalink
Added Select for order and placemenet
Browse files Browse the repository at this point in the history
  • Loading branch information
smmr-dn committed Sep 30, 2024
1 parent 6801195 commit a84693a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
6 changes: 6 additions & 0 deletions examples/Toast.order.css
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);
}
15 changes: 12 additions & 3 deletions examples/Toast.order.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,30 @@
* 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';
import { useToaster, Button, Select } from '@itwin/itwinui-react';

export default () => {
const toaster = useToaster();
const [selectedOrder, setSelectedOrder] = React.useState('auto');

React.useEffect(() => {
toaster.setSettings({
order: 'ascending',
order: selectedOrder,
});
}, []);

return (
<div className='demo-container'>
<Select
placeholder='Select order'
options={[
{ value: 'ascending', label: 'Ascending' },
{ value: 'descending', label: 'Descending' },
{ value: 'auto', label: 'Auto' },
]}
></Select>
<Button onClick={() => toaster.informational('This is a toast message.')}>
Ascending toast
Open toast
</Button>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions examples/Toast.placement.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
display: flex;
align-items: center;
flex-direction: column;
gap: var(--iui-size-xs);
}
21 changes: 17 additions & 4 deletions examples/Toast.placement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,34 @@
* 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';
import { useToaster, Button, Select } from '@itwin/itwinui-react';

export default () => {
const toaster = useToaster();
const [selectedPlacement, setSelectedPlacement] = React.useState('top');

React.useEffect(() => {
toaster.setSettings({
placement: 'bottom-end',
placement: selectedPlacement,
});
}, []);
}, [selectedPlacement]);

return (
<div className='demo-container'>
<Select
placeholder='Select 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) => setSelectedPlacement(value)}
></Select>
<Button onClick={() => toaster.informational('This is a toast message.')}>
Bottom-end toast
Open toast
</Button>
</div>
);
Expand Down

0 comments on commit a84693a

Please sign in to comment.