Skip to content

Commit

Permalink
feat: fix drawer provider, add browsers list config
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Mar 6, 2024
1 parent 431664a commit f0858ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Browsers that we support
defaults
not IE 11
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Icon } from '@/shared/ui/Icon/Icon';
import NotificationIcon from '@/shared/assets/icons/notification-20-20.svg';
import { Popover } from '@/shared/ui/Popups';
import { Drawer } from '@/shared/ui/Drawer/Drawer';
import { AnimationProvider } from '@/shared/lib/components/AnimationProvider';
import { NotificationList } from '../../../../entities/Notification';
import cls from './NotificationButton.module.scss';

Expand All @@ -29,20 +28,15 @@ export const NotificationButton = memo(() => {
return (
<div>
<BrowserView>
<Popover
direction="bottom left"
trigger={trigger}
>
<Popover direction="bottom left" trigger={trigger}>
<NotificationList className={cls.notifications} />
</Popover>
</BrowserView>
<MobileView>
{trigger}
<AnimationProvider>
<Drawer isOpen={isOpen} onClose={onCloseDrawer}>
<NotificationList />
</Drawer>
</AnimationProvider>
<Drawer isOpen={isOpen} onClose={onCloseDrawer}>
<NotificationList />
</Drawer>
</MobileView>
</div>
);
Expand Down
12 changes: 9 additions & 3 deletions src/shared/ui/Drawer/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {
} from 'react';
import { classNames } from '@/shared/lib/classNames/classNames';
import { useTheme } from '@/app/providers/ThemeProvider';
import { useAnimationLibs } from '@/shared/lib/components/AnimationProvider';
import { AnimationProvider, useAnimationLibs } from '@/shared/lib/components/AnimationProvider';
import { Overlay } from '../Overlay/Overlay';
import cls from './Drawer.module.scss';
import { Portal } from '../Portal/Portal';
Expand Down Expand Up @@ -96,12 +96,18 @@ export const DrawerContent = memo((props: DrawerProps) => {
);
});

export const Drawer = memo((props: DrawerProps) => {
const DrawerAsync = (props: DrawerProps) => {
const { isLoaded } = useAnimationLibs();

if (!isLoaded) {
return null;
}

return <DrawerContent {...props} />;
});
};

export const Drawer = (props: DrawerProps) => (
<AnimationProvider>
<DrawerAsync {...props} />
</AnimationProvider>
);

0 comments on commit f0858ae

Please sign in to comment.