Skip to content

Commit

Permalink
refactor: make slider of home page fullWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
pooriaset committed Dec 11, 2024
1 parent 8a501a0 commit d088d7e
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 71 deletions.
45 changes: 0 additions & 45 deletions src/app/[locale]/(main)/(container)/(homepage)/loading.tsx

This file was deleted.

7 changes: 4 additions & 3 deletions src/app/[locale]/(main)/(container)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ const Layout: FC<Layout> = async ({ children }) => {
return (
<>
<MobileView>
<Box
<Container
maxWidth="xl"
sx={{
mt: 3,
paddingBottom: MOBILE_FOOTER_HEIGHT,
}}
>
{children}
</Box>
</Container>
</MobileView>
<DesktopView>
<Container
maxWidth="xl"
sx={{
mt: 3,
pb: { xs: `${MOBILE_FOOTER_HEIGHT}px`, md: 0 },
minHeight: '70vh',
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ChevronLeft } from '@mui/icons-material';
import { Box, Grid, Link, Stack } from '@mui/material';
import { grey } from '@mui/material/colors';
import React, { FC } from 'react';
import Image from '../../../../../../components/common/Image';
import Image from '@/components/common/Image';

export interface IMainCategory {
id: number | string;
Expand Down
63 changes: 63 additions & 0 deletions src/app/[locale]/(main)/(homepage)/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { VariableProductItemSkeleton } from '@/components/VariableProductItem';
import {
Card,
CardContent,
Container,
Grid,
Skeleton,
Stack,
} from '@mui/material';

const Loading = () => {
return (
<Grid container spacing={2}>
<Grid item xs={12}>
<Skeleton variant="rectangular" height={350} />
</Grid>

<Grid item xs={12}>
<Container maxWidth="xl">
<Grid container spacing={2}>
<Grid item xs={12}>
<Grid container spacing={2}>
{new Array(4).fill(1).map((item, index) => {
return (
<Grid key={index} item xs={12} md={6} lg={4} xl={3}>
<Stack alignItems="end">
<Skeleton
width="100%"
variant="rectangular"
height={120}
/>
<Skeleton variant="text" width={60} />
</Stack>
</Grid>
);
})}
</Grid>
</Grid>
{new Array(3).fill(1).map((item) => (
<Grid item xs={12} key={item}>
<Card variant="outlined">
<CardContent>
<Grid container spacing={2}>
{new Array(6).fill(1).map((item, index) => {
return (
<Grid key={index} item xs={12} md={6} lg={3} xl={2}>
<VariableProductItemSkeleton />
</Grid>
);
})}
</Grid>
</CardContent>
</Card>
</Grid>
))}
</Grid>
</Container>
</Grid>
</Grid>
);
};

export default Loading;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
menuOrderSortOptions,
newestSortOption,
} from '@/static/sortOptions';
import { Grid } from '@mui/material';
import { Container, Grid, Stack } from '@mui/material';
import { getTranslations } from 'next-intl/server';
import Header from './components/Header';
import MainCategories from './components/MainCategories';
Expand Down Expand Up @@ -124,25 +124,31 @@ export default async function Home() {
<MainSlider items={sliders} />
</Grid>
<Grid item xs={12}>
<MainCategories items={categories} />
</Grid>
<Grid item xs={12}>
<ProductsSlider
title={t('header.navigation.bestSelling')}
items={bestSellingProducts}
/>
</Grid>
<Grid item xs={12}>
<ProductsSlider
title={t('header.navigation.newest')}
items={latestProducts}
/>
</Grid>
<Grid item xs={12}>
<ProductsSlider
title={t('header.navigation.selectedProducts')}
items={menuOrderProducts}
/>
<Container maxWidth="xl">
<Grid container spacing={2}>
<Grid item xs={12}>
<MainCategories items={categories} />
</Grid>
<Grid item xs={12}>
<ProductsSlider
title={t('header.navigation.bestSelling')}
items={bestSellingProducts}
/>
</Grid>
<Grid item xs={12}>
<ProductsSlider
title={t('header.navigation.newest')}
items={latestProducts}
/>
</Grid>
<Grid item xs={12}>
<ProductsSlider
title={t('header.navigation.selectedProducts')}
items={menuOrderProducts}
/>
</Grid>
</Grid>
</Container>
</Grid>
</Grid>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(main)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ISliderItem } from '@/app/[locale]/(main)/(container)/(homepage)/components/MainSlider/types';
import { ISliderItem } from '@/app/[locale]/(main)/(homepage)/components/MainSlider/types';
import { Footer } from '@/components/Footer';
import { Header } from '@/components/Header';
import { DesktopHeader } from '@/components/Header/components';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/components/TopBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ISliderItem } from '@/app/[locale]/(main)/(container)/(homepage)/components/MainSlider/types';
import { ISliderItem } from '@/app/[locale]/(main)/(homepage)/components/MainSlider/types';
import Image from 'next/image';
import React, { FC } from 'react';

Expand Down

0 comments on commit d088d7e

Please sign in to comment.