Skip to content

Commit

Permalink
Feat: Change homepage style
Browse files Browse the repository at this point in the history
  • Loading branch information
whats2000 committed Aug 10, 2024
1 parent 604944e commit 7dfa9fd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
14 changes: 8 additions & 6 deletions src/components/collection/CollectionPageBase.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next';
import { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Select, SelectProps } from 'antd';
import { GlobalToken, Select, SelectProps, theme } from 'antd';
import styled from 'styled-components';

import PageHeader from '#/common/PageHeader.tsx';
Expand All @@ -15,9 +15,10 @@ import getImageUrl from '@/utils/getImageUrl.ts';
import useApi from '@/hooks/useApi.ts';
import { StatusShowingGroup } from '#/common/StatusShowingGroup.tsx';

const Container = styled.div`
const Container = styled.div<{ $token: GlobalToken }>`
padding: 50px 40px;
background-color: #6f9b9c;
color: #fff;
background-color: ${(props) => props.$token.colorPrimary};
@media (max-width: 400px) {
padding: 50px 10px;
Expand Down Expand Up @@ -45,6 +46,7 @@ const CollectionPageBase = ({
);

const navigate = useNavigate();
const { token } = theme.useToken();

const [isModalOpen, setIsModalOpen] = useState(false);
const [selectedItem, setSelectedItem] = useState<{
Expand Down Expand Up @@ -141,10 +143,10 @@ const CollectionPageBase = ({
<>
<PageHeader
backgroundComponent={<HeaderImage imageUrl={getImageUrl(imageUrl)} />}
maskColor={'#6f9b9c'}
maskColor={token.colorPrimary}
headerTextArray={[t(`${pageType}Collection.title`)]}
/>
<Container>
<Container $token={token}>
<SelectWrapper>
<StyledSelect
size={'large'}
Expand All @@ -157,7 +159,7 @@ const CollectionPageBase = ({
</SelectWrapper>
<CardsSection
title={t(`${pageType}Collection.title`)}
darkMode={true}
type={'primary'}
imageContentSections={bindEventImageContents}
useStaticDataApi={true}
/>
Expand Down
38 changes: 22 additions & 16 deletions src/components/common/CardsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Card, Button, Flex } from 'antd';
import { Card, Button, Flex, theme, GlobalToken } from 'antd';
import { Link } from 'react-router-dom';
import styled, { css } from 'styled-components';
import { LazyLoadImage } from 'react-lazy-load-image-component';
Expand All @@ -10,16 +10,18 @@ import getImageUrl from '@/utils/getImageUrl.ts';
import { fadeIn } from '@/styles/animation.ts';
import { STATIC_DATA_API } from '@/constants';

const Section = styled.section<{ $darkMode: boolean }>`
background-color: #ecf0f1;
padding: 50px 20px;
const Section = styled.section<{
$type: 'default' | 'dark' | 'primary';
$token: GlobalToken;
}>`
background-color: ${(props) =>
props.$type === 'dark'
? props.$token.colorPrimaryBg
: props.$type === 'primary'
? props.$token.colorPrimary
: props.$token.colorBgBase};
${(props) =>
props.$darkMode &&
`
background-color: #6f9b9c;
color: #fff;
`};
padding: 50px 20px;
`;

const CardContainer = styled.div`
Expand Down Expand Up @@ -132,7 +134,7 @@ const StyledButton = styled(Button)`

interface CardsSectionProps {
title: string;
darkMode?: boolean;
type?: 'default' | 'dark' | 'primary';
imageContentSections: IImageContent[];
useStaticDataApi?: boolean;
}
Expand All @@ -147,14 +149,15 @@ interface CardsSectionProps {
*/
const CardsSection: React.FC<CardsSectionProps> = ({
title,
darkMode = false,
type = 'default',
imageContentSections,
useStaticDataApi = false,
}: CardsSectionProps) => {
}) => {
const { animate, ref } = useAnimateOnScroll();
const { token } = theme.useToken();

return (
<Section ref={ref} $darkMode={darkMode}>
<Section ref={ref} $type={type} $token={token}>
<SectionTitle $fadeIn={animate}>{title}</SectionTitle>
<CardContainer>
{imageContentSections.map((section, index) => (
Expand Down Expand Up @@ -190,7 +193,10 @@ const CardsSection: React.FC<CardsSectionProps> = ({
section.buttons.map((button, idx) =>
button.link ? (
<Link key={idx} to={button.link}>
<Button type={button.type || 'primary'} ghost={darkMode}>
<Button
type={button.type || 'primary'}
ghost={type === 'dark'}
>
{button.text}
</Button>
</Link>
Expand All @@ -201,7 +207,7 @@ const CardsSection: React.FC<CardsSectionProps> = ({
ghost={
button.type !== 'link' &&
button.type !== 'text' &&
darkMode
type === 'dark'
}
href={button.href}
target={button.href ? '_blank' : ''}
Expand Down
3 changes: 1 addition & 2 deletions src/components/common/CarouselSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fadeIn } from '@/styles/animation.ts';
import { STATIC_DATA_API } from '@/constants';

const Section = styled.section`
background-color: #b1dde6;
background-color: #ecf0f1;
padding: 50px 20px;
@media (max-width: 400px) {
Expand All @@ -37,7 +37,6 @@ const SectionSubtitle = styled.h3<{ $fadeIn: boolean }>`
font-weight: bold;
margin-top: 20px;
opacity: 0;
color: #6f9b9c;
border-radius: 10px;
${(props) =>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const HomePage = () => {
/>
<CardsSection
title={t('home.feature.title')}
darkMode={true}
type={'dark'}
imageContentSections={t('home.feature.card', { returnObjects: true })}
/>
<CarouselSection
Expand Down

0 comments on commit 7dfa9fd

Please sign in to comment.