-
{extra.date}
- {icon &&
}
+
+ {isMobile ? (
+
+ {first3.map((extra, index) => (
+
+
-
- );
- })}
+ ))}
+
+ ) : (
+
+ {first3.map((extra, index) => (
+
+ ))}
+
+ )}
);
}
+
diff --git a/.dumi/pages/index/components/ComponentsList.tsx b/.dumi/pages/index/components/ComponentsList.tsx
index 8104bb3f73..322b565092 100644
--- a/.dumi/pages/index/components/ComponentsList.tsx
+++ b/.dumi/pages/index/components/ComponentsList.tsx
@@ -1,5 +1,5 @@
/* eslint-disable react/jsx-pascal-case */
-import React from 'react';
+import React, { useContext } from 'react';
import {
Space,
Typography,
@@ -10,12 +10,15 @@ import {
Modal,
FloatButton,
Progress,
+ Carousel,
} from 'antd';
import dayjs from 'dayjs';
import { CustomerServiceOutlined, QuestionCircleOutlined, SyncOutlined } from '@ant-design/icons';
import { css } from '@emotion/react';
import useSiteToken from '../../../hooks/useSiteToken';
import useLocale from '../../../hooks/useLocale';
+import SiteContext from './SiteContext';
+import { useCarouselStyle } from './util';
const SAMPLE_CONTENT_EN =
'Ant Design 5.0 use CSS-in-JS technology to provide dynamic & mix theme ability. And which use component level CSS-in-JS solution get your application a better performance.';
@@ -54,6 +57,7 @@ const locales = {
const useStyle = () => {
const { token } = useSiteToken();
+ const { carousel } = useCarouselStyle();
return {
card: css`
@@ -80,13 +84,25 @@ const useStyle = () => {
filter: blur(40px);
opacity: 0.1;
`,
+ mobileCard: css`
+ height: 395px;
+ `,
+ carousel,
};
};
+interface ComponentItemProps {
+ title: React.ReactNode;
+ node: React.ReactNode;
+ type: 'new' | 'update';
+ index: number;
+}
+
export default function ComponentsList() {
const { token } = useSiteToken();
const styles = useStyle();
const [locale] = useLocale(locales);
+ const { isMobile } = useContext(SiteContext);
const COMPONENTS: {
title: React.ReactNode;
@@ -110,12 +126,16 @@ export default function ComponentsList() {
node: (
),
@@ -149,7 +169,7 @@ export default function ComponentsList() {
@@ -211,49 +231,61 @@ export default function ComponentsList() {
),
},
],
- [],
+ [isMobile],
);
- return (
+ const ComponentItem = ({ title, node, type, index }: ComponentItemProps) => {
+ const tagColor = type === 'new' ? 'processing' : 'warning';
+ const tagText = type === 'new' ? locale.new : locale.update;
+
+ return (
+
+ {/* Decorator */}
+
+
+ {/* Title */}
+
+
+ {title}
+
+ {tagText}
+
+
+
+ {node}
+
+
+ );
+ };
+
+ return isMobile ? (
+
+
+ {COMPONENTS.map(({ title, node, type }, index) => (
+
+ ))}
+
+
+ ) : (
- {COMPONENTS.map(({ title, node, type }, index) => {
- const tagColor = type === 'new' ? 'processing' : 'warning';
- const tagText = type === 'new' ? locale.new : locale.update;
-
- return (
-
- {/* Decorator */}
-
-
- {/* Title */}
-
-
- {title}
-
- {tagText}
-
-
-
- {node}
-
-
- );
- })}
+ {COMPONENTS.map(({ title, node, type }, index) => (
+
+ ))}
);
diff --git a/.dumi/pages/index/components/DesignFramework.tsx b/.dumi/pages/index/components/DesignFramework.tsx
index c606b27c40..d4bbad6318 100644
--- a/.dumi/pages/index/components/DesignFramework.tsx
+++ b/.dumi/pages/index/components/DesignFramework.tsx
@@ -1,10 +1,11 @@
import { Col, Row, Typography } from 'antd';
-import React from 'react';
+import React, { useContext } from 'react';
import { css } from '@emotion/react';
import { Link, useLocation } from 'dumi';
import useLocale from '../../../hooks/useLocale';
import useSiteToken from '../../../hooks/useSiteToken';
import * as utils from '../../../theme/utils';
+import SiteContext from './SiteContext';
const SECONDARY_LIST = [
{
@@ -98,6 +99,8 @@ export default function DesignFramework() {
const style = useStyle();
const { pathname, search } = useLocation();
const isZhCN = utils.isZhCN(pathname);
+ const { isMobile } = useContext(SiteContext);
+ const colSpan = isMobile ? 24 : 8;
const MAINLY_LIST = [
{
@@ -124,7 +127,7 @@ export default function DesignFramework() {
const desc = locale[`${key}Desc` as keyof typeof locale];
return (
-
+
@@ -149,7 +152,7 @@ export default function DesignFramework() {
const desc = locale[`${key}Desc` as keyof typeof locale];
return (
-
+
diff --git a/.dumi/pages/index/components/Group.tsx b/.dumi/pages/index/components/Group.tsx
index 627ee6b0fd..2b4587c923 100644
--- a/.dumi/pages/index/components/Group.tsx
+++ b/.dumi/pages/index/components/Group.tsx
@@ -1,6 +1,8 @@
import * as React from 'react';
+import { useContext } from 'react';
import { Typography } from 'antd';
import useSiteToken from '../../../hooks/useSiteToken';
+import SiteContext from './SiteContext';
export interface GroupMaskProps {
style?: React.CSSProperties;
@@ -49,6 +51,7 @@ export interface GroupProps {
export default function Group(props: GroupProps) {
const { id, title, titleColor, description, children, decoration, background, collapse } = props;
const { token } = useSiteToken();
+ const { isMobile } = useContext(SiteContext);
const marginStyle: React.CSSProperties = collapse
? {}
@@ -56,7 +59,7 @@ export default function Group(props: GroupProps) {
maxWidth: 1208,
marginInline: 'auto',
boxSizing: 'border-box',
- paddingInline: token.marginXXL,
+ paddingInline: isMobile ? token.margin : token.marginXXL,
};
const childNode = (
<>
@@ -69,11 +72,17 @@ export default function Group(props: GroupProps) {
color: titleColor,
// Special for the title
fontFamily: `AliPuHui, ${token.fontFamily}`,
+ fontSize: isMobile ? token.fontSizeHeading2 : token.fontSizeHeading1,
}}
>
{title}
-
+
{description}
diff --git a/.dumi/pages/index/components/SiteContext.tsx b/.dumi/pages/index/components/SiteContext.tsx
new file mode 100644
index 0000000000..9767a89b50
--- /dev/null
+++ b/.dumi/pages/index/components/SiteContext.tsx
@@ -0,0 +1,11 @@
+import * as React from 'react';
+
+export interface SiteContextProps {
+ isMobile: boolean;
+}
+
+const SiteContext = React.createContext
({
+ isMobile: false,
+});
+
+export default SiteContext;
diff --git a/.dumi/pages/index/components/Theme/MobileCarousel.tsx b/.dumi/pages/index/components/Theme/MobileCarousel.tsx
new file mode 100644
index 0000000000..12fdeae6d4
--- /dev/null
+++ b/.dumi/pages/index/components/Theme/MobileCarousel.tsx
@@ -0,0 +1,119 @@
+import * as React from 'react';
+import { useState } from 'react';
+import { css } from '@emotion/react';
+import { Typography, Carousel } from 'antd';
+import { useCarouselStyle } from '../util';
+import useSiteToken from '../../../../hooks/useSiteToken';
+
+const useStyle = () => {
+ const { carousel } = useCarouselStyle();
+ return {
+ carousel,
+ container: css`
+ position: relative;
+ `,
+ title: css`
+ position: absolute;
+ top: 15%;
+ z-index: 1;
+ width: 100%;
+ text-align: center;
+ `,
+ };
+};
+
+const mobileImageConfigList = [
+ {
+ imageSrc:
+ 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*KsMrRZaciFcAAAAAAAAAAAAADrJ8AQ/original',
+ titleColor: 'rgba(0,0,0,.88)',
+ },
+ {
+ imageSrc:
+ 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*3FkqR6XRNgoAAAAAAAAAAAAADrJ8AQ/original',
+ titleColor: '#fff',
+ },
+ {
+ imageSrc:
+ 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*cSX_RbD3k9wAAAAAAAAAAAAADrJ8AQ/original',
+ titleColor: '#fff',
+ },
+ {
+ imageSrc:
+ 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*MldsRZeax6EAAAAAAAAAAAAADrJ8AQ/original',
+ titleColor: '#fff',
+ },
+ {
+ imageSrc:
+ 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*xCAmSL0xlZ8AAAAAAAAAAAAADrJ8AQ/original',
+ titleColor: '#fff',
+ },
+ {
+ imageSrc:
+ 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*vCfCSbiI_VIAAAAAAAAAAAAADrJ8AQ/original',
+ titleColor: '#fff',
+ },
+ {
+ imageSrc:
+ 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*xCAmSL0xlZ8AAAAAAAAAAAAADrJ8AQ/original',
+ titleColor: '#fff',
+ },
+ {
+ imageSrc:
+ 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*BeDBTY9UnXIAAAAAAAAAAAAADrJ8AQ/original',
+ titleColor: '#fff',
+ },
+ {
+ imageSrc:
+ 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*Q63XTbk8YaMAAAAAAAAAAAAADrJ8AQ/original',
+ titleColor: '#fff',
+ },
+];
+
+export interface MobileCarouselProps {
+ id?: string;
+ title?: React.ReactNode;
+ description?: React.ReactNode;
+}
+
+export default function MobileCarousel(props: MobileCarouselProps) {
+ const styles = useStyle();
+ const { id, title, description } = props;
+ const { token } = useSiteToken();
+ const [currentSlider, setCurrentSlider] = useState(0);
+
+ return (
+
+
+
+ {title}
+
+
+ {description}
+
+
+
+ {mobileImageConfigList.map((item, index) => (
+
+
+
+ ))}
+
+
+ );
+}
diff --git a/.dumi/pages/index/components/Theme/index.tsx b/.dumi/pages/index/components/Theme/index.tsx
index 3820acf491..0f809d7dde 100644
--- a/.dumi/pages/index/components/Theme/index.tsx
+++ b/.dumi/pages/index/components/Theme/index.tsx
@@ -30,6 +30,9 @@ import RadiusPicker from './RadiusPicker';
import Group from '../Group';
import BackgroundImage from './BackgroundImage';
import { DEFAULT_COLOR, getAvatarURL, getClosetColor, PINK_COLOR } from './colorUtil';
+import SiteContext from '../SiteContext';
+import { useCarouselStyle } from '../util';
+import MobileCarousel from './MobileCarousel';
const { Header, Content, Sider } = Layout;
@@ -81,6 +84,7 @@ const locales = {
// ============================= Style =============================
const useStyle = () => {
const { token } = useSiteToken();
+ const { carousel } = useCarouselStyle();
return {
demo: css`
@@ -177,6 +181,7 @@ const useStyle = () => {
width: 800px;
margin: 0 auto;
`,
+ carousel,
};
};
@@ -278,6 +283,7 @@ export default function Theme() {
const { compact, themeType, ...themeToken } = themeData;
const isLight = themeType !== 'dark';
const [form] = Form.useForm();
+ const { isMobile } = React.useContext(SiteContext);
// const algorithmFn = isLight ? theme.defaultAlgorithm : theme.darkAlgorithm;
const algorithmFn = React.useMemo(() => {
@@ -487,8 +493,22 @@ export default function Theme() {
const posStyle: React.CSSProperties = {
position: 'absolute',
};
+ const leftTopImageStyle = {
+ left: '50%',
+ transform: 'translate3d(-900px, 0, 0)',
+ top: -100,
+ height: 500,
+ };
+ const rightBottomImageStyle = {
+ right: '50%',
+ transform: 'translate3d(750px, 0, 0)',
+ bottom: -100,
+ height: 287,
+ };
- return (
+ return isMobile ? (
+
+ ) : (
, boolean] {
return [data, loading];
}
+
+export const useCarouselStyle = () => ({
+ carousel: css`
+ .slick-dots.slick-dots-bottom {
+ bottom: -22px;
+ li {
+ width: 6px;
+ height: 6px;
+ background: #e1eeff;
+ border-radius: 50%;
+ button {
+ height: 6px;
+ background: #e1eeff;
+ border-radius: 50%;
+ }
+ &.slick-active {
+ background: #4b9cff;
+ button {
+ background: #4b9cff;
+ }
+ }
+ }
+ }
+ `,
+});
diff --git a/.dumi/pages/index/index.tsx b/.dumi/pages/index/index.tsx
index a64fa9ce83..ee0992c09d 100644
--- a/.dumi/pages/index/index.tsx
+++ b/.dumi/pages/index/index.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useEffect, useMemo } from 'react';
import { useLocale as useDumiLocale } from 'dumi';
import { ConfigProvider } from 'antd';
import useLocale from '../../hooks/useLocale';
@@ -9,6 +9,7 @@ import Theme from './components/Theme';
import BannerRecommends from './components/BannerRecommends';
import ComponentsList from './components/ComponentsList';
import DesignFramework from './components/DesignFramework';
+import SiteContext from './components/SiteContext';
const locales = {
cn: {
@@ -33,44 +34,61 @@ const Homepage: React.FC = () => {
const localeStr = localeId === 'zh-CN' ? 'cn' : 'en';
const [siteData] = useSiteData();
+ const [isMobile, setIsMobile] = React.useState(false);
+
+ const updateMobileMode = () => {
+ setIsMobile(window.innerWidth < 768);
+ };
+
+ useEffect(() => {
+ updateMobileMode();
+ window.addEventListener('resize', updateMobileMode);
+ return () => {
+ window.removeEventListener('resize', updateMobileMode);
+ };
+ }, []);
+
+ const siteValue = useMemo(() => ({ isMobile }), [isMobile]);
return (
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
- {/* Image Left Top */}
-
- >
- }
- >
-
-
-
-
+
+
+
+
+
+
+ {/* Image Left Top */}
+
+ >
+ }
+ >
+
+
+
+
+
);
};
diff --git a/.dumi/theme/slots/Footer/index.tsx b/.dumi/theme/slots/Footer/index.tsx
index 0d8c866620..b2b683b485 100644
--- a/.dumi/theme/slots/Footer/index.tsx
+++ b/.dumi/theme/slots/Footer/index.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useContext } from 'react';
import RcFooter from 'rc-footer';
import { Link, FormattedMessage } from 'dumi';
import type { FooterColumn } from 'rc-footer/lib/column';
@@ -23,6 +23,7 @@ import useLocation from '../../../hooks/useLocation';
import useLocale from '../../../hooks/useLocale';
import useSiteToken from '../../../hooks/useSiteToken';
import AdditionalInfo from './AdditionalInfo';
+import SiteContext from '../SiteContext';
const locales = {
cn: {
@@ -35,6 +36,7 @@ const locales = {
const useStyle = () => {
const { token } = useSiteToken();
+ const { isMobile } = useContext(SiteContext);
const background = new TinyColor(getAlphaColor('#f0f3fa', '#fff'))
.onBackground(token.colorBgContainer)
.toHexString();
@@ -59,7 +61,10 @@ const useStyle = () => {
}
.rc-footer-column {
- margin-bottom: 0;
+ margin-bottom: ${isMobile ? 60 : 0}px;
+ :last-child {
+ margin-bottom: ${isMobile ? 20 : 0}px;
+ }
}
.rc-footer-container {
@@ -69,8 +74,10 @@ const useStyle = () => {
}
.rc-footer-bottom {
- font-size: ${token.fontSize}px;
box-shadow: inset 0 106px 36px -116px rgba(0, 0, 0, 0.14);
+ .rc-footer-bottom-container {
+ font-size: ${token.fontSize}px;
+ }
}
`,
};
@@ -369,7 +376,10 @@ const Footer = () => {
css={style.footer}
bottom={
<>
- Made with ❤ by {locale.owner}
+
+ Made with ❤ by
+
+ {locale.owner}
>
}
/>
diff --git a/package.json b/package.json
index 7bfebfdd7b..bc01e23b08 100644
--- a/package.json
+++ b/package.json
@@ -116,6 +116,7 @@
"@babel/runtime": "^7.18.3",
"@ctrl/tinycolor": "^3.4.0",
"@rc-component/tour": "~1.0.1-2",
+ "antd-token-previewer": "^1.1.0-21",
"classnames": "^2.2.6",
"copy-to-clipboard": "^3.2.0",
"dayjs": "^1.11.1",
@@ -193,7 +194,6 @@
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
"antd-img-crop": "^4.2.8",
- "antd-token-previewer": "^1.1.0-6",
"array-move": "^4.0.0",
"bundlesize2": "^0.0.31",
"chalk": "^4.0.0",