Skip to content

Commit e094a56

Browse files
author
Kubit
committed
Improve drawer component
1 parent c389b9f commit e094a56

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/components/drawer/drawerControlled.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ import { DrawerVariantStylesType } from './types/drawerTheme';
1818

1919
/* Constants for useScrollEffect */
2020
const SCROLL_DISTANCE = 5;
21-
/* Constants for useZoomEffect (footer) */
21+
22+
/* Constants for useZoomEffect */
23+
const MAX_ZOOM = 2.4;
2224
const FOOTER_EDIT_STYLES: CssProperty[] = [
2325
{ cssPropertyName: 'position', cssPropertyValue: 'static' },
2426
];
25-
26-
const MAX_ZOOM = 2.4;
27+
const CONTAINER_STYLES_EDIT: CssProperty[] = [
28+
{ cssPropertyName: 'overflow-y', cssPropertyValue: 'auto' },
29+
];
30+
const CONTENT_STYLES_EDIT: CssProperty[] = [
31+
{ cssPropertyName: 'overflow-y', cssPropertyValue: 'visible' },
32+
{ cssPropertyName: 'max-height', cssPropertyValue: 'none' },
33+
{ cssPropertyName: 'min-height', cssPropertyValue: 'auto' },
34+
];
2735

2836
const DrawerControlledComponent = React.forwardRef(
2937
<V extends string | unknown>(
@@ -47,7 +55,9 @@ const DrawerControlledComponent = React.forwardRef(
4755
| null
4856
| undefined;
4957

58+
handleDrawerZoomEffect(innerRef.current);
5059
handleTitleShadowEffect(drawerTitle);
60+
handleContentZoomEffect(drawerContent);
5161
handleContentScrollEffect(drawerContent);
5262
handleFooterZoomEffect(drawerFooter);
5363
handleContentScrollDetection(drawerContent);
@@ -78,6 +88,8 @@ const DrawerControlledComponent = React.forwardRef(
7888
scrollCallback: handleScroll,
7989
});
8090

91+
const handleDrawerZoomEffect = useZoomEffect(CONTAINER_STYLES_EDIT, MAX_ZOOM);
92+
const handleContentZoomEffect = useZoomEffect(CONTENT_STYLES_EDIT, MAX_ZOOM);
8193
const handleFooterZoomEffect = useZoomEffect(FOOTER_EDIT_STYLES, MAX_ZOOM);
8294

8395
const { hasScroll: contentHasScroll, handleScrollDetection: handleContentScrollDetection } =

src/components/drawer/drawerStandAlone.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
21
import React from 'react';
32

43
import { Footer } from '@/components/footer/footer';
@@ -55,7 +54,7 @@ const DrawerStandAloneComponent = (
5554
<DrawerTitleContentFooterContainerStyled blocked={blocked} styles={props.styles}>
5655
<DrawerTitleStyled
5756
data-drawer-title
58-
as={Text as any}
57+
as={Text}
5958
component={titleComponent as unknown as TextComponentType}
6059
customTypography={props.styles.title}
6160
id={titleIdFinal}
@@ -80,7 +79,7 @@ const DrawerStandAloneComponent = (
8079
{props.footer?.content && (props.styles.footer?.variant || props.footer.variant) && (
8180
<DrawerFooterStyled
8281
data-drawer-footer
83-
as={Footer as any}
82+
as={Footer}
8483
customFooterStyles={props.styles}
8584
variant={props.styles.footer?.variant}
8685
{...props.footer}

0 commit comments

Comments
 (0)