Skip to content

Commit 4f198b8

Browse files
committed
refactor: read color of section from theme
1 parent 30d0951 commit 4f198b8

File tree

6 files changed

+29
-9
lines changed

6 files changed

+29
-9
lines changed

public/assets/images/logo-dark.svg

Lines changed: 1 addition & 0 deletions
Loading
File renamed without changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use client';
2+
3+
import { Box, darken, styled } from '@mui/material';
4+
import { blueGrey } from '@mui/material/colors';
5+
6+
const ColorfulSection = styled(Box)<{}>(({ theme }) => ({
7+
padding: theme.spacing(2, 0),
8+
backgroundColor:
9+
theme.palette.mode === 'light'
10+
? blueGrey['50']
11+
: darken(blueGrey['900'], 0.5),
12+
width: '100%',
13+
}));
14+
15+
export default ColorfulSection;

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import ProductsSlider from './components/ProductsSlider';
2626
import SlidersContainer from './components/SlidersContainer';
2727
import SlidersSkeleton from './components/SlidersSkeleton';
2828
import { Header } from '@/components/Header';
29+
import ColorfulSection from './components/ColorfulSection';
2930

3031
const getCategories = async () => {
3132
const { data } = await getClient().query<GetMainCategoriesQuery>({
@@ -181,17 +182,11 @@ export default async function Home() {
181182
</SlidersContainer>
182183

183184
{!!_posts.length && (
184-
<Box
185-
sx={{
186-
py: 2,
187-
bgcolor: '#f1f4f7',
188-
width: '100%',
189-
}}
190-
>
185+
<ColorfulSection>
191186
<SlidersContainer>
192187
<PostsSlider items={_posts} />
193188
</SlidersContainer>
194-
</Box>
189+
</ColorfulSection>
195190
)}
196191
</Stack>
197192
</>

src/components/common/Logo.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import React, { FC } from 'react';
22
import Image from './Image';
33
import { ImageProps } from 'next/image';
4+
import { useTheme } from '@mui/material';
45

56
const Logo: FC<Partial<ImageProps>> = (props) => {
7+
const options = {
8+
dark: '/assets/images/logo-dark.svg',
9+
light: '/assets/images/logo-light.svg',
10+
};
11+
12+
const theme = useTheme();
13+
614
return (
715
<Image
816
draggable={false}
917
width={176}
1018
height={32}
1119
alt="Logo"
12-
src="/assets/images/logo.svg"
20+
src={options[theme.palette.mode]}
1321
style={{
1422
width: 'fit-content',
1523
}}

src/config/theme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const themeOptions: ThemeOptions = {
7070
main: green[500],
7171
contrastText: '#fff',
7272
lighter: green[200],
73+
...green,
7374
},
7475
},
7576
shape: {

0 commit comments

Comments
 (0)