Skip to content

Commit 0c12f19

Browse files
committed
chore: centralize z-index of elements
1 parent 4a8072f commit 0c12f19

File tree

9 files changed

+27
-7
lines changed

9 files changed

+27
-7
lines changed

src/app/[locale]/(main)/(container)/cart/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import Loading from '../loading';
3030
import CheckoutBox, { CheckoutBoxProps } from './components/CheckoutBox';
3131
import Header from './components/Header';
3232
import EmptyCart from './components/EmptyCart';
33+
import { Z_INDEX_VALUES } from '@/config/responsive';
3334

3435
const Page = () => {
3536
const t = useTranslations();
@@ -191,7 +192,7 @@ const Page = () => {
191192
sx={{
192193
position: 'sticky',
193194
top: 196,
194-
zIndex: 1299,
195+
zIndex: Z_INDEX_VALUES.cartPageDetailsBox,
195196
}}
196197
>
197198
<Card variant="outlined">

src/app/[locale]/(main)/(container)/products/[...params]/components/MobileBuyBox.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
MOBILE_BUY_BOX_HEIGHT,
33
MOBILE_FOOTER_HEIGHT,
4+
Z_INDEX_VALUES,
45
} from '@/config/responsive';
56
import { Stack } from '@mui/material';
67
import { FC, PropsWithChildren } from 'react';
@@ -20,6 +21,7 @@ const MobileBuyBox: FC<PropsWithChildren<MobileBuyBoxProps>> = ({
2021
backgroundColor: (theme) => theme.palette.background.default,
2122
boxShadow: (theme) => theme.shadows[2],
2223
px: 3,
24+
zIndex: Z_INDEX_VALUES.mobileBuyBox,
2325
}}
2426
spacing={1}
2527
alignItems="center"

src/app/[locale]/(main)/(container)/products/[...params]/components/ProductTabs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Box, Tab, Tabs, Typography } from '@mui/material';
66
import { useTranslations } from 'next-intl';
77
import { FC, SyntheticEvent, useState } from 'react';
88
import { Product } from '../../types/common';
9+
import { Z_INDEX_VALUES } from '@/config/responsive';
910

1011
export interface ProductTabsProps {
1112
content?: string | null;
@@ -40,7 +41,7 @@ const ProductTabs: FC<ProductTabsProps> = ({ content, attributes }) => {
4041
borderBottom: 1,
4142
borderColor: 'divider',
4243
backgroundColor: (theme) => theme.palette.background.default,
43-
zIndex: 1000,
44+
zIndex: Z_INDEX_VALUES.productTabs,
4445
}}
4546
>
4647
<Tabs

src/components/Dialog/Dialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ButtonWithLoading, {
1111
} from '../common/ButtonWithLoading';
1212
import DialogTransition from '../common/DialogTransition';
1313
import { useAppContext } from '@/hooks/useAppContext';
14+
import { Z_INDEX_VALUES } from '@/config/responsive';
1415

1516
export interface DialogProps extends MuiDialogProps {
1617
dialogContentProps?: DialogContentProps;
@@ -46,7 +47,7 @@ const Dialog: FC<DialogProps> = ({
4647
root: isMobile
4748
? {
4849
style: {
49-
zIndex: 2000,
50+
zIndex: Z_INDEX_VALUES.dialog,
5051
},
5152
}
5253
: {},

src/components/Footer/components/MobileFooter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import { Z_INDEX_VALUES } from '@/config/responsive';
34
import { cartAtom } from '@/store/atoms';
45
import {
56
AccountCircleOutlined,
@@ -68,7 +69,7 @@ const MobileFooter = () => {
6869
position: 'fixed',
6970
bottom: 0,
7071
boxShadow: (theme) => theme.shadows[3],
71-
zIndex: 1290,
72+
zIndex: Z_INDEX_VALUES.mobileFooter,
7273
}}
7374
>
7475
<MuiBottomNavigation

src/components/Header/Header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { DesktopHeader, MobileHeader } from './components';
88
import TopBanner, {
99
TopBannerProps,
1010
} from '@/components/Header/components/TopBanner';
11+
import { Z_INDEX_VALUES } from '@/config/responsive';
1112

1213
export interface HeaderProps {
1314
topBanner?: TopBannerProps['data'];
@@ -23,7 +24,7 @@ const Header: FC<HeaderProps> = ({ topBanner }) => {
2324
borderColor: (theme) => theme.palette.divider,
2425
position: 'sticky',
2526
top: 0,
26-
zIndex: 1299,
27+
zIndex: Z_INDEX_VALUES.siteHeader,
2728
}}
2829
>
2930
{topBanner && <TopBanner data={topBanner} />}

src/components/VariantSelector/VariantSelector.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import { Z_INDEX_VALUES } from '@/config/responsive';
34
import { Box } from '@mui/material';
45
import FormControl from '@mui/material/FormControl';
56
import InputLabel from '@mui/material/InputLabel';
@@ -43,7 +44,7 @@ const VariantSelector: FC<VariantSelectorProps> = ({
4344
MenuProps={{
4445
disableScrollLock: true,
4546
sx: {
46-
zIndex: 10,
47+
zIndex: Z_INDEX_VALUES.variantSelectorMenu,
4748
},
4849
}}
4950
>

src/components/common/ProgressBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import { Z_INDEX_VALUES } from '@/config/responsive';
34
import Box from '@mui/material/Box';
45
import LinearProgress from '@mui/material/LinearProgress';
56
import { useEffect, useState } from 'react';
@@ -31,7 +32,7 @@ const ProgressBar = () => {
3132
top: 0,
3233
left: 0,
3334
right: 0,
34-
zIndex: 1300,
35+
zIndex: Z_INDEX_VALUES.progressBar,
3536
}}
3637
>
3738
<LinearProgress variant="determinate" value={progress} />

src/config/responsive.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
export const MOBILE_FOOTER_HEIGHT = 56;
22
export const MOBILE_BUY_BOX_HEIGHT = MOBILE_FOOTER_HEIGHT * 1.8;
3+
4+
export const Z_INDEX_VALUES = {
5+
dialog: 2000,
6+
progressBar: 1300,
7+
siteHeader: 1299,
8+
mobileFooter: 1290,
9+
cartPageDetailsBox: 1298,
10+
mobileBuyBox: 1289,
11+
productTabs: 1288,
12+
variantSelectorMenu: 10,
13+
};

0 commit comments

Comments
 (0)