2023-10-21 16:39:59 +08:00
|
|
|
import React, { Suspense } from 'react';
|
2024-07-15 09:22:02 +08:00
|
|
|
import { ConfigProvider, Flex, Typography } from 'antd';
|
2024-01-06 18:05:25 +08:00
|
|
|
import { createStyles } from 'antd-style';
|
2024-07-28 10:43:45 +08:00
|
|
|
import classNames from 'classnames';
|
2024-06-11 16:07:13 +08:00
|
|
|
import { useLocation } from 'dumi';
|
2024-07-27 16:13:25 +08:00
|
|
|
|
2023-08-25 19:08:52 +08:00
|
|
|
import useLocale from '../../../../hooks/useLocale';
|
2024-07-15 09:22:02 +08:00
|
|
|
import LinkButton from '../../../../theme/common/LinkButton';
|
2023-08-25 19:08:52 +08:00
|
|
|
import SiteContext from '../../../../theme/slots/SiteContext';
|
|
|
|
import * as utils from '../../../../theme/utils';
|
2024-04-06 16:11:17 +08:00
|
|
|
import GroupMaskLayer from '../GroupMaskLayer';
|
2023-08-25 19:08:52 +08:00
|
|
|
|
2023-10-21 16:39:59 +08:00
|
|
|
const ComponentsBlock = React.lazy(() => import('./ComponentsBlock'));
|
|
|
|
|
2023-08-25 19:08:52 +08:00
|
|
|
const locales = {
|
|
|
|
cn: {
|
|
|
|
slogan: '助力设计开发者「更灵活」地搭建出「更美」的产品,让用户「快乐工作」~',
|
|
|
|
start: '开始使用',
|
|
|
|
designLanguage: '设计语言',
|
|
|
|
},
|
|
|
|
en: {
|
|
|
|
slogan:
|
|
|
|
'Help designers/developers building beautiful products more flexible and working with happiness',
|
|
|
|
start: 'Getting Started',
|
|
|
|
designLanguage: 'Design Language',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-08-27 19:57:19 +08:00
|
|
|
const useStyle = () => {
|
2023-08-25 19:08:52 +08:00
|
|
|
const { direction } = React.useContext(ConfigProvider.ConfigContext);
|
2024-07-28 10:43:45 +08:00
|
|
|
const { isMobile } = React.useContext(SiteContext);
|
2023-08-25 19:08:52 +08:00
|
|
|
const isRTL = direction === 'rtl';
|
2023-10-20 23:05:04 +08:00
|
|
|
return createStyles(({ token, css, cx }) => {
|
2024-04-06 16:11:17 +08:00
|
|
|
const textShadow = `0 0 4px ${token.colorBgContainer}`;
|
2023-08-25 19:08:52 +08:00
|
|
|
|
2023-10-20 23:05:04 +08:00
|
|
|
const mask = cx(css`
|
|
|
|
position: absolute;
|
|
|
|
inset: 0;
|
2023-10-21 16:39:59 +08:00
|
|
|
backdrop-filter: blur(4px);
|
2023-10-25 10:54:42 +08:00
|
|
|
opacity: 1;
|
2023-11-28 11:03:22 +08:00
|
|
|
background-color: rgba(255, 255, 255, 0.2);
|
2023-11-22 17:57:53 +08:00
|
|
|
transition: all 1s ease;
|
|
|
|
pointer-events: none;
|
2023-10-20 23:05:04 +08:00
|
|
|
`);
|
|
|
|
|
2023-08-27 19:57:19 +08:00
|
|
|
return {
|
|
|
|
holder: css`
|
2023-11-28 15:31:36 +08:00
|
|
|
height: 640px;
|
2023-08-27 19:57:19 +08:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
position: relative;
|
|
|
|
overflow: hidden;
|
|
|
|
perspective: 800px;
|
2023-10-23 15:02:51 +08:00
|
|
|
/* fix safari bug by removing blur style */
|
|
|
|
transform: translateZ(1000px);
|
2023-08-27 19:57:19 +08:00
|
|
|
row-gap: ${token.marginXL}px;
|
2023-10-20 23:05:04 +08:00
|
|
|
|
|
|
|
&:hover .${mask} {
|
2023-10-25 10:54:42 +08:00
|
|
|
opacity: 0;
|
2023-10-20 23:05:04 +08:00
|
|
|
}
|
2023-08-27 19:57:19 +08:00
|
|
|
`,
|
2023-08-25 19:08:52 +08:00
|
|
|
|
2023-10-20 23:05:04 +08:00
|
|
|
mask,
|
|
|
|
|
2023-08-27 19:57:19 +08:00
|
|
|
typography: css`
|
|
|
|
text-align: center;
|
|
|
|
position: relative;
|
|
|
|
z-index: 1;
|
|
|
|
padding-inline: ${token.paddingXL}px;
|
|
|
|
text-shadow: ${new Array(5)
|
|
|
|
.fill(null)
|
|
|
|
.map(() => textShadow)
|
|
|
|
.join(', ')};
|
2023-08-25 19:08:52 +08:00
|
|
|
|
2023-08-27 19:57:19 +08:00
|
|
|
h1 {
|
|
|
|
font-family: AliPuHui, ${token.fontFamily} !important;
|
|
|
|
font-weight: 900 !important;
|
|
|
|
font-size: ${token.fontSizeHeading2 * 2}px !important;
|
|
|
|
line-height: ${token.lineHeightHeading2} !important;
|
|
|
|
}
|
2023-08-25 19:08:52 +08:00
|
|
|
|
2023-08-27 19:57:19 +08:00
|
|
|
p {
|
|
|
|
font-size: ${token.fontSizeLG}px !important;
|
|
|
|
font-weight: normal !important;
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
`,
|
2023-08-25 19:08:52 +08:00
|
|
|
|
2023-08-27 19:57:19 +08:00
|
|
|
block: css`
|
|
|
|
position: absolute;
|
|
|
|
inset-inline-end: 0;
|
|
|
|
top: -38px;
|
|
|
|
transform: ${isRTL ? 'rotate3d(24, 83, -45, 57deg)' : 'rotate3d(24, -83, 45, 57deg)'};
|
|
|
|
`,
|
|
|
|
child: css`
|
|
|
|
position: relative;
|
2023-12-04 15:12:49 +08:00
|
|
|
width: 100%;
|
2024-03-31 21:19:04 +08:00
|
|
|
max-width: 1200px;
|
|
|
|
margin: 0 auto;
|
2023-08-27 19:57:19 +08:00
|
|
|
z-index: 1;
|
|
|
|
`,
|
2024-01-06 18:05:25 +08:00
|
|
|
btnWrap: css`
|
|
|
|
margin-bottom: ${token.marginXL}px;
|
|
|
|
`,
|
2024-07-28 10:43:45 +08:00
|
|
|
bgImg: css`
|
|
|
|
position: absolute;
|
|
|
|
width: 240px;
|
|
|
|
`,
|
|
|
|
bgImgTop: css`
|
|
|
|
top: 0;
|
|
|
|
inset-inline-start: ${isMobile ? '-120px' : 0};
|
|
|
|
`,
|
|
|
|
bgImgBottom: css`
|
|
|
|
bottom: 120px;
|
|
|
|
inset-inline-end: ${isMobile ? 0 : '40%'};
|
|
|
|
`,
|
2023-08-27 19:57:19 +08:00
|
|
|
};
|
|
|
|
})();
|
|
|
|
};
|
2023-09-10 12:27:10 +08:00
|
|
|
|
2024-07-28 10:43:45 +08:00
|
|
|
const PreviewBanner: React.FC<Readonly<React.PropsWithChildren>> = (props) => {
|
2023-08-25 19:08:52 +08:00
|
|
|
const { children } = props;
|
|
|
|
const [locale] = useLocale(locales);
|
|
|
|
const { styles } = useStyle();
|
|
|
|
const { isMobile } = React.useContext(SiteContext);
|
|
|
|
const { pathname, search } = useLocation();
|
|
|
|
const isZhCN = utils.isZhCN(pathname);
|
|
|
|
|
|
|
|
return (
|
2024-04-06 16:11:17 +08:00
|
|
|
<GroupMaskLayer>
|
2023-08-25 19:08:52 +08:00
|
|
|
{/* Image Left Top */}
|
|
|
|
<img
|
|
|
|
alt="bg"
|
2024-07-28 10:43:45 +08:00
|
|
|
src="https://gw.alipayobjects.com/zos/bmw-prod/49f963db-b2a8-4f15-857a-270d771a1204.svg"
|
|
|
|
draggable={false}
|
|
|
|
className={classNames(styles.bgImg, styles.bgImgTop)}
|
2023-08-25 19:08:52 +08:00
|
|
|
/>
|
|
|
|
{/* Image Right Top */}
|
|
|
|
<img
|
|
|
|
alt="bg"
|
2024-07-28 10:43:45 +08:00
|
|
|
src="https://gw.alipayobjects.com/zos/bmw-prod/e152223c-bcae-4913-8938-54fda9efe330.svg"
|
|
|
|
draggable={false}
|
|
|
|
className={classNames(styles.bgImg, styles.bgImgBottom)}
|
2023-08-25 19:08:52 +08:00
|
|
|
/>
|
|
|
|
|
|
|
|
<div className={styles.holder}>
|
|
|
|
{/* Mobile not show the component preview */}
|
2023-10-21 16:39:59 +08:00
|
|
|
<Suspense fallback={null}>
|
2023-11-22 17:57:53 +08:00
|
|
|
{isMobile ? null : (
|
|
|
|
<div className={styles.block}>
|
|
|
|
<ComponentsBlock />
|
|
|
|
</div>
|
|
|
|
)}
|
2023-10-21 16:39:59 +08:00
|
|
|
</Suspense>
|
2023-10-20 23:05:04 +08:00
|
|
|
<div className={styles.mask} />
|
2023-08-25 19:08:52 +08:00
|
|
|
<Typography className={styles.typography}>
|
|
|
|
<h1>Ant Design 5.0</h1>
|
|
|
|
<p>{locale.slogan}</p>
|
|
|
|
</Typography>
|
2024-01-06 18:05:25 +08:00
|
|
|
<Flex gap="middle" className={styles.btnWrap}>
|
2024-07-15 09:22:02 +08:00
|
|
|
<LinkButton
|
|
|
|
size="large"
|
|
|
|
type="primary"
|
|
|
|
to={utils.getLocalizedPathname('/components/overview/', isZhCN, search)}
|
|
|
|
>
|
|
|
|
{locale.start}
|
|
|
|
</LinkButton>
|
|
|
|
<LinkButton
|
|
|
|
size="large"
|
|
|
|
to={utils.getLocalizedPathname('/docs/spec/introduce/', isZhCN, search)}
|
|
|
|
>
|
|
|
|
{locale.designLanguage}
|
|
|
|
</LinkButton>
|
2024-01-06 18:05:25 +08:00
|
|
|
</Flex>
|
2023-08-25 19:08:52 +08:00
|
|
|
<div className={styles.child}>{children}</div>
|
|
|
|
</div>
|
2024-04-06 16:11:17 +08:00
|
|
|
</GroupMaskLayer>
|
2023-08-25 19:08:52 +08:00
|
|
|
);
|
2023-09-10 12:27:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default PreviewBanner;
|