Skip to content

Commit

Permalink
refactor(Toaster): remove ToasterPortal
Browse files Browse the repository at this point in the history
  • Loading branch information
amje committed Dec 25, 2024
1 parent 2e4fb5f commit 68ba993
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
14 changes: 9 additions & 5 deletions src/components/Toaster/ToasterComponent/ToasterComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

import React from 'react';

import {Portal} from '../../Portal';
import {useMobile} from '../../mobile';
import {block} from '../../utils/cn';
import {ToastsContext} from '../Provider/ToastsContext';
import {ToastList} from '../ToastList/ToastList';
import {useToaster} from '../hooks/useToaster';

import {ToasterPortal} from './ToasterPortal';

interface Props {
className?: string;
mobile?: boolean;
hasPortal?: boolean;
}

const b = block('toaster');

export function ToasterComponent({className, mobile, hasPortal = true}: Props) {
const defaultMobile = useMobile();
const {remove} = useToaster();
Expand All @@ -29,9 +31,11 @@ export function ToasterComponent({className, mobile, hasPortal = true}: Props) {
}

return (
<ToasterPortal className={className || ''} mobile={mobile ?? defaultMobile}>
{toaster}
</ToasterPortal>
<Portal>
<div className={b({mobile: mobile ?? defaultMobile}, className)} aria-live="assertive">
{toaster}
</div>
</Portal>
);
}

Expand Down
25 changes: 0 additions & 25 deletions src/components/Toaster/ToasterComponent/ToasterPortal.tsx

This file was deleted.

0 comments on commit 68ba993

Please sign in to comment.