Skip to content

Commit

Permalink
fixup! fixup! Feat(web-react): Introduce Uncontrollable Toast
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelklibani committed Apr 11, 2024
1 parent b9ebc32 commit 45ee4d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/web-react/src/components/Toast/UncontrolledToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ import Toast from './Toast';
import ToastBar from './ToastBar';
import { AUTOCLOSE_TIMEOUT } from './constants';
import { useUncontrolledToast } from './useUncontrolledToast';
import { ChildrenProps, StyleProps } from '../../types';

interface UncontrolledToastProps {
interface UncontrolledToastProps extends ChildrenProps, StyleProps {
alignmentX?: 'left' | 'center' | 'right';
alignmentY?: 'top' | 'bottom';
closeLabel?: string;
hasIcon?: boolean;
isDismissible?: boolean;
}

const UncontrolledToast = ({ alignmentX, alignmentY, closeLabel, hasIcon, isDismissible }: UncontrolledToastProps) => {
const UncontrolledToast = ({
alignmentX,
alignmentY,
closeLabel,
hasIcon,
isDismissible,
...restProps
}: UncontrolledToastProps) => {
const { close, color, iconName, autoClose, message, id, isOpen } = useUncontrolledToast();

useEffect(() => {
Expand All @@ -38,6 +46,7 @@ const UncontrolledToast = ({ alignmentX, alignmentY, closeLabel, hasIcon, isDism
isDismissible={isDismissible}
onClose={close}
isOpen={!!isOpen && !!message}
{...restProps}
>
{message}
</ToastBar>
Expand Down

0 comments on commit 45ee4d0

Please sign in to comment.