Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 143x 143x 143x 1912x 1912x 1912x 1912x 143x | import { DrawerProps, SxProps } from "@mui/material";
import GiveMotionWrapper from "@shared/Motion/GiveMotionWrapper";
import PanelWrapper from "@shared/SidePanel/components/PanelWrapper";
import {
FirstPanelContainer,
SecondPanelContainer,
} from "@shared/SidePanel/GiveSidePanel.style";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { ReactNode } from "react";
import { ErrorFallback, SidePanelButton } from "./SidePanelAtoms";
import ErrorCatcher from "@common/Error/ErrorCatcher";
export const MIN_ALLOWED_SCREEN_SIZE_FOR_DOUBLE_PANELS = 1280;
export const NEW_BASE_PANEL_WIDTH = 600;
export interface IGiveSidePanelProps extends DrawerProps {
isSecondPanelOpen?: boolean;
secondPanel?: ReactNode;
isSingleOnly?: boolean;
width?: number;
secondPanelWidth?: number;
containerProps?: { firstPanel?: SxProps; secondPanel?: SxProps };
floatingContent?: ReactNode;
isFirstPannelHidden?: boolean;
overRideIsMobile?: boolean;
mobileStyle?: any;
}
const GiveSidePanel = ({
isSecondPanelOpen = false,
isSingleOnly = false,
children,
secondPanel,
width = NEW_BASE_PANEL_WIDTH,
secondPanelWidth,
containerProps,
floatingContent,
isFirstPannelHidden = false,
overRideIsMobile,
...rest
}: IGiveSidePanelProps) => {
const { isMobileView } = useCustomThemeV2();
const isSinglePanelOnly =
isMobileView ||
window.innerWidth < MIN_ALLOWED_SCREEN_SIZE_FOR_DOUBLE_PANELS ||
isSingleOnly;
const isDoublePanelMode = isFirstPannelHidden
? false
: isSecondPanelOpen && !isSinglePanelOnly;
return (
<PanelWrapper
isMobileView={overRideIsMobile || isMobileView}
isDoublePanelMode={isDoublePanelMode}
isSecondPanelVisible={isFirstPannelHidden || isSecondPanelOpen}
width={width}
secondPanelWidth={
secondPanel && secondPanelWidth ? secondPanelWidth : width
}
drawerProps={rest}
isSinglePanelOnly={isSinglePanelOnly}
>
<ErrorCatcher errorID="sidepanel-base" Fallback={ErrorFallback}>
{floatingContent ? floatingContent : <></>}
{isFirstPannelHidden ? (
<></>
) : (
(isDoublePanelMode || !isSecondPanelOpen) && (
<FirstPanelContainer
sx={containerProps?.firstPanel}
isMobileView={isMobileView}
containerWidth={width}
>
{children}
</FirstPanelContainer>
)
)}
<GiveMotionWrapper
type="slide"
inView={isSecondPanelOpen}
duration={195}
direction={isMobileView ? "up" : "left"}
>
<SecondPanelContainer
isSinglePanelOnly={isSinglePanelOnly}
isMobileView={isMobileView}
containerWidth={secondPanelWidth || width}
sx={containerProps?.secondPanel}
>
{secondPanel}
</SecondPanelContainer>
</GiveMotionWrapper>
</ErrorCatcher>
</PanelWrapper>
);
};
GiveSidePanel.Button = SidePanelButton;
export default GiveSidePanel;
|