Skip to content

Commit d493843

Browse files
author
Kubit
committed
Improve minwidth styles props on Drawer Component
1 parent f8f72c4 commit d493843

File tree

4 files changed

+47
-50
lines changed

4 files changed

+47
-50
lines changed

src/components/drawer/drawer.styled.ts

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,7 @@ export const DrawerTitleStyled = styled.div.withConfig({
3333
})``;
3434

3535
export const DrawerStyled = styled.div<DrawerStylesType>`
36-
background-color: #fff;
37-
max-height: 100vh;
38-
max-height: var(--100svh, 100vh);
39-
max-height: 100svh;
40-
min-width: 50vw;
41-
max-width: 50vw;
42-
overflow-y: auto;
43-
${() =>
44-
({
45-
theme: {
46-
MEDIA_QUERIES: { onlyDesktop, onlyTablet },
47-
},
48-
}) => css`
49-
${onlyDesktop} {
50-
min-height: 100vh;
51-
min-height: var(--100svh, 100vh);
52-
min-height: 100svh;
53-
}
54-
${onlyTablet} {
55-
min-height: 100vh;
56-
min-height: var(--100svh, 100vh);
57-
min-height: 100svh;
58-
}
59-
`};
36+
${props => props.position && getStyles(props.styles.container?.[props.position])}
6037
6138
${DrawerTitleStyled} {
6239
transition: box-shadow 300ms;
@@ -66,23 +43,6 @@ export const DrawerStyled = styled.div<DrawerStylesType>`
6643
${props => getStyles(props.styles.titleContainer)}
6744
${props => getTypographyStyles(props.styles.titleContainer)}
6845
}
69-
70-
${() =>
71-
({
72-
theme: {
73-
MEDIA_QUERIES: { onlyMobile, onlyTablet },
74-
},
75-
}) => css`
76-
${onlyMobile} {
77-
max-width: inherit;
78-
max-height: inherit;
79-
}
80-
${onlyTablet} {
81-
max-width: 100vw;
82-
min-width: 100vw;
83-
}
84-
`};
85-
${props => props.position && getStyles(props.styles.container?.[props.position])}
8646
`;
8747

8848
export const DrawerNavigationStyled = styled.div<DrawerStylesType>`

src/components/drawer/drawerControlled.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import * as React from 'react';
22

33
import { STYLES_NAME } from '@/constants';
4-
import { useDeviceHeight, useMediaDevice, useScrollEffect, useZoomEffect } from '@/hooks';
5-
import { useStyles } from '@/hooks/useStyles/useStyles';
4+
import {
5+
useDeviceHeight,
6+
useMediaDevice,
7+
useScrollEffect,
8+
useStylesV2,
9+
useZoomEffect,
10+
} from '@/hooks';
611
import { ErrorBoundary, FallbackComponent } from '@/provider/errorBoundary';
712
import { CssProperty } from '@/utils';
813

@@ -25,13 +30,13 @@ const DrawerControlledComponent = React.forwardRef(
2530
ref: React.ForwardedRef<HTMLDivElement> | undefined | null
2631
): JSX.Element => {
2732
useDeviceHeight();
28-
const styles = useStyles<DrawerVariantStylesType, V>(
29-
STYLES_NAME.DRAWER,
30-
props.variant,
31-
props.ctv
32-
);
33+
const styles = useStylesV2<DrawerVariantStylesType, V>({
34+
styleName: STYLES_NAME.DRAWER,
35+
variantName: props.variant,
36+
customTokens: props.ctv,
37+
});
3338
const device = useMediaDevice();
34-
const stylesByDevice = styles[device];
39+
const stylesByDevice = styles?.[device];
3540

3641
const { scrollableRef, shadowRef } = useScrollEffect({
3742
shadowStyles: stylesByDevice.titleContainer?.box_shadow,

src/components/drawer/stories/drawerControlled.stories.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import { ButtonSizeType, ButtonVariantType } from '@/designSystem/kubit/componen
1111
import { themesObject, variantsObject } from '@/designSystem/themesObject';
1212

1313
import { DrawerControlled as Story } from '../index';
14-
import { DrawerLevelPositionTypes, DrawerTitleComponentType } from '../types';
14+
import {
15+
DrawerLevelPositionTypes,
16+
DrawerTitleComponentType,
17+
DrawerVariantPositionTypes,
18+
} from '../types';
1519
import { argtypes } from './controlledArgtypes';
1620

1721
const themeSelected = localStorage.getItem('themeSelected') || 'kubit';
@@ -110,6 +114,12 @@ export const DrawerControlledWithCtv: Story = {
110114
title: {
111115
color: 'red',
112116
},
117+
container: {
118+
[DrawerVariantPositionTypes.DRAWER_RIGHT]: {
119+
min_width: '80vw',
120+
max_width: '80vw',
121+
},
122+
},
113123
},
114124
TABLET: {
115125
title: {

src/designSystem/kubit/components/drawer/styles.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,23 @@ const containerCommonProps: {
2525
[DrawerVariantPositionTypes.DRAWER_RIGHT]: {
2626
border_top_left_radius: RADIUS.radius_50,
2727
border_bottom_left_radius: RADIUS.radius_50,
28+
max_height: SPACINGS.spacing_100_vh,
29+
background: COLORS.NEUTRAL.color_neutral_bg_250,
30+
min_width: '50vw',
31+
max_width: '50vw',
2832
},
2933
[DrawerVariantPositionTypes.DRAWER_LEFT]: {
3034
border_top_right_radius: RADIUS.radius_50,
3135
border_bottom_right_radius: RADIUS.radius_50,
36+
max_height: SPACINGS.spacing_100_vh,
37+
background: COLORS.NEUTRAL.color_neutral_bg_250,
38+
min_width: '50vw',
39+
max_width: '50vw',
3240
},
3341
[DrawerVariantPositionTypes.DRAWER_BOTTOM]: {
3442
border_top_right_radius: RADIUS.radius_50,
3543
border_top_left_radius: RADIUS.radius_50,
44+
background: COLORS.NEUTRAL.color_neutral_bg_250,
3645
},
3746
};
3847
const commonIconContainerProps: CommonStyleType = {
@@ -122,6 +131,11 @@ export const DRAWER_STYLES: DrawerStylesType<DrawerVariantType> = {
122131
[DeviceBreakpointsType.TABLET]: {
123132
container: {
124133
...containerCommonProps,
134+
[DrawerVariantPositionTypes.DRAWER_BOTTOM]: {
135+
...containerCommonProps.DRAWER_BOTTOM,
136+
min_height: 'var(--100svh, 100vh)',
137+
background_color: COLORS.NEUTRAL.color_neutral_bg_250,
138+
},
125139
},
126140
iconContainer: {
127141
...commonIconContainerProps,
@@ -165,6 +179,14 @@ export const DRAWER_STYLES: DrawerStylesType<DrawerVariantType> = {
165179
},
166180
},
167181
[DeviceBreakpointsType.MOBILE]: {
182+
container: {
183+
...containerCommonProps,
184+
[DrawerVariantPositionTypes.DRAWER_BOTTOM]: {
185+
...containerCommonProps.DRAWER_BOTTOM,
186+
min_height: 'var(--100svh, 100vh)',
187+
background_color: COLORS.NEUTRAL.color_neutral_bg_250,
188+
},
189+
},
168190
iconContainer: {
169191
...commonIconContainerProps,
170192
padding_top: SPACINGS.spacing_300,

0 commit comments

Comments
 (0)