fix(ui-toolkit): test toast configuration (#3877)
This commit is contained in:
parent
a4512e6064
commit
48109b584c
@ -7,10 +7,11 @@ import { ToastPosition, useToastsConfiguration, useToasts } from './use-toasts';
|
|||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { Intent } from '../../utils/intent';
|
import { Intent } from '../../utils/intent';
|
||||||
|
|
||||||
const testToast = {
|
const TEST_TOAST = {
|
||||||
id: 'test-toast',
|
id: 'test-toast',
|
||||||
intent: Intent.Primary,
|
intent: Intent.Primary,
|
||||||
content: <>{t('This is an example of a toast notification')}</>,
|
content: <>{t('This is an example of a toast notification')}</>,
|
||||||
|
onClose: () => useToasts.getState().remove('test-toast'),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ToastPositionSetter = () => {
|
export const ToastPositionSetter = () => {
|
||||||
@ -20,7 +21,7 @@ export const ToastPositionSetter = () => {
|
|||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
(position: ToastPosition) => {
|
(position: ToastPosition) => {
|
||||||
setPostion(position);
|
setPostion(position);
|
||||||
setToast(testToast);
|
setToast(TEST_TOAST);
|
||||||
},
|
},
|
||||||
[setToast, setPostion]
|
[setToast, setPostion]
|
||||||
);
|
);
|
||||||
|
@ -109,12 +109,12 @@ export enum ToastPosition {
|
|||||||
BottomCenter,
|
BottomCenter,
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToastConfiguration = {
|
type ToastsConfiguration = {
|
||||||
position: ToastPosition;
|
position: ToastPosition;
|
||||||
setPosition: (position: ToastPosition) => void;
|
setPosition: (position: ToastPosition) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useToastsConfiguration = create<ToastConfiguration>()(
|
export const useToastsConfiguration = create<ToastsConfiguration>()(
|
||||||
persist(
|
persist(
|
||||||
immer((set) => ({
|
immer((set) => ({
|
||||||
position: ToastPosition.BottomRight,
|
position: ToastPosition.BottomRight,
|
||||||
|
Loading…
Reference in New Issue
Block a user