Skip to content

Commit

Permalink
fix drawer | add browserlist config
Browse files Browse the repository at this point in the history
  • Loading branch information
Bender101 committed Nov 6, 2023
1 parent 3b5c003 commit d2c1383
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Browsers that we support

defaults

not IE 11
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Popover } from "@/shared/ui/Popups";
import { Drawer } from "@/shared/ui/Drawer/Drawer";
import { BrowserView, MobileView } from "react-device-detect";
import cls from "./NotificationButton.module.scss";
import { AnimationProvider } from "@/shared/lib/components/AnimationProvider";

interface NotificationButtonProps {
className?: string;
Expand Down Expand Up @@ -45,11 +44,10 @@ export const NotificationButton = memo((props: NotificationButtonProps) => {
</BrowserView>
<MobileView>
{trigger}
<AnimationProvider>
<Drawer isOpen={isOpen} onClose={onCloseDrawer}>
<NotificationList />
</Drawer>
</AnimationProvider>

<Drawer isOpen={isOpen} onClose={onCloseDrawer}>
<NotificationList />
</Drawer>
</MobileView>
</div>
);
Expand Down
17 changes: 14 additions & 3 deletions src/shared/ui/Drawer/Drawer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { classNames } from "@/shared/lib/classNames/classNames";
import React, { memo, ReactNode, useCallback, useEffect } from "react";
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 @@ -93,12 +96,20 @@ export const DrawerContent = memo((props: DrawerProps) => {
);
});

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

if (!isLoaded) {
return null;
}

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

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

0 comments on commit d2c1383

Please sign in to comment.