site: update site/demo style (#50107)

* site: update site/demo style

* fix: fix lint
This commit is contained in:
lijianan 2024-07-27 16:13:25 +08:00 committed by GitHub
parent cd4199e83f
commit f56fee1333
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 104 additions and 50 deletions

View File

@ -1,6 +1,6 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { Badge, Carousel, Skeleton, Typography } from 'antd'; import { Badge, Carousel, Flex, Skeleton, Typography } from 'antd';
import { createStyles, useTheme } from 'antd-style'; import { createStyles } from 'antd-style';
import classNames from 'classnames'; import classNames from 'classnames';
import useLocale from '../../../hooks/useLocale'; import useLocale from '../../../hooks/useLocale';
@ -57,6 +57,9 @@ const useStyle = createStyles(({ token, css, cx }) => {
} }
`, `,
carousel, carousel,
bannerBg: css`
height: ${token.fontSize}px;
`,
}; };
}); });
@ -66,8 +69,8 @@ interface RecommendItemProps {
icons: Icon[]; icons: Icon[];
className?: string; className?: string;
} }
const RecommendItem: React.FC<RecommendItemProps> = ({ extra, index, icons, className }) => { const RecommendItem: React.FC<RecommendItemProps> = ({ extra, index, icons, className }) => {
const token = useTheme();
const { styles } = useStyle(); const { styles } = useStyle();
if (!extra) { if (!extra) {
@ -87,10 +90,10 @@ const RecommendItem: React.FC<RecommendItemProps> = ({ extra, index, icons, clas
<Typography.Paragraph type="secondary" style={{ flex: 'auto' }}> <Typography.Paragraph type="secondary" style={{ flex: 'auto' }}>
{extra.description} {extra.description}
</Typography.Paragraph> </Typography.Paragraph>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> <Flex justify="space-between" align="center">
<Typography.Text>{extra.date}</Typography.Text> <Typography.Text>{extra.date}</Typography.Text>
{icon && <img src={icon.href} style={{ height: token.fontSize }} alt="banner" />} {icon && <img src={icon.href} draggable={false} className={styles.bannerBg} alt="banner" />}
</div> </Flex>
</a> </a>
); );

View File

@ -12,7 +12,7 @@ import {
Tour, Tour,
Typography, Typography,
} from 'antd'; } from 'antd';
import { createStyles, css, useTheme } from 'antd-style'; import { createStyles, css } from 'antd-style';
import classNames from 'classnames'; import classNames from 'classnames';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
@ -104,6 +104,13 @@ const useStyle = () => {
justify-content: center; justify-content: center;
`, `,
carousel, carousel,
componentsList: css`
width: 100%;
overflow: hidden;
`,
mobileComponentsList: css`
margin: 0 ${token.margin}px;
`,
}; };
})(); })();
}; };
@ -142,7 +149,6 @@ interface ComponentItemProps {
} }
const ComponentsList: React.FC = () => { const ComponentsList: React.FC = () => {
const token = useTheme();
const { styles } = useStyle(); const { styles } = useStyle();
const [locale] = useLocale(locales); const [locale] = useLocale(locales);
const { isMobile } = useContext(SiteContext); const { isMobile } = useContext(SiteContext);
@ -260,21 +266,33 @@ const ComponentsList: React.FC = () => {
); );
return isMobile ? ( return isMobile ? (
<div style={{ margin: '0 16px' }}> <div className={styles.mobileComponentsList}>
<Carousel className={styles.carousel}> <Carousel className={styles.carousel}>
{COMPONENTS.map<React.ReactNode>(({ title, node, type }, index) => ( {COMPONENTS.map<React.ReactNode>(({ title, node, type }, index) => (
<ComponentItem title={title} node={node} type={type} index={index} key={index} /> <ComponentItem
title={title}
node={node}
type={type}
index={index}
key={`mobile-item-${index}`}
/>
))} ))}
</Carousel> </Carousel>
</div> </div>
) : ( ) : (
<div style={{ width: '100%', overflow: 'hidden', display: 'flex', justifyContent: 'center' }}> <Flex justify="center" className={styles.componentsList}>
<div style={{ display: 'flex', alignItems: 'stretch', columnGap: token.paddingLG }}> <Flex align="stretch" gap="large">
{COMPONENTS.map<React.ReactNode>(({ title, node, type }, index) => ( {COMPONENTS.map<React.ReactNode>(({ title, node, type }, index) => (
<ComponentItem title={title} node={node} type={type} index={index} key={index} /> <ComponentItem
title={title}
node={node}
type={type}
index={index}
key={`desktop-item-${index}`}
/>
))} ))}
</div> </Flex>
</div> </Flex>
); );
}; };

View File

@ -134,7 +134,7 @@ const DesignFramework: React.FC = () => {
<Col key={index} span={colSpan}> <Col key={index} span={colSpan}>
<Link to={path}> <Link to={path}>
<div className={styles.card}> <div className={styles.card}>
<img alt={title} src={img} /> <img draggable={false} alt={title} src={img} />
<Typography.Title <Typography.Title
level={4} level={4}
@ -158,7 +158,12 @@ const DesignFramework: React.FC = () => {
return ( return (
<Col key={index} span={colSpan}> <Col key={index} span={colSpan}>
<a className={styles.cardMini} target="_blank" href={url} rel="noreferrer"> <a className={styles.cardMini} target="_blank" href={url} rel="noreferrer">
<img alt={title} src={img} style={{ transform: `scale(${imgScale})` }} /> <img
draggable={false}
alt={title}
src={img}
style={{ transform: `scale(${imgScale})` }}
/>
<Typography.Title <Typography.Title
level={4} level={4}

View File

@ -2,6 +2,7 @@ import React, { Suspense } from 'react';
import { ConfigProvider, Flex, Typography } from 'antd'; import { ConfigProvider, Flex, Typography } from 'antd';
import { createStyles } from 'antd-style'; import { createStyles } from 'antd-style';
import { useLocation } from 'dumi'; import { useLocation } from 'dumi';
import useLocale from '../../../../hooks/useLocale'; import useLocale from '../../../../hooks/useLocale';
import LinkButton from '../../../../theme/common/LinkButton'; import LinkButton from '../../../../theme/common/LinkButton';
import SiteContext from '../../../../theme/slots/SiteContext'; import SiteContext from '../../../../theme/slots/SiteContext';
@ -117,12 +118,14 @@ const PreviewBanner: React.FC<React.PropsWithChildren> = (props) => {
<GroupMaskLayer> <GroupMaskLayer>
{/* Image Left Top */} {/* Image Left Top */}
<img <img
draggable={false}
style={{ position: 'absolute', left: isMobile ? -120 : 0, top: 0, width: 240 }} style={{ position: 'absolute', left: isMobile ? -120 : 0, top: 0, width: 240 }}
src="https://gw.alipayobjects.com/zos/bmw-prod/49f963db-b2a8-4f15-857a-270d771a1204.svg" src="https://gw.alipayobjects.com/zos/bmw-prod/49f963db-b2a8-4f15-857a-270d771a1204.svg"
alt="bg" alt="bg"
/> />
{/* Image Right Top */} {/* Image Right Top */}
<img <img
draggable={false}
style={{ position: 'absolute', right: isMobile ? 0 : '40%', bottom: 120, width: 240 }} style={{ position: 'absolute', right: isMobile ? 0 : '40%', bottom: 120, width: 240 }}
src="https://gw.alipayobjects.com/zos/bmw-prod/e152223c-bcae-4913-8938-54fda9efe330.svg" src="https://gw.alipayobjects.com/zos/bmw-prod/e152223c-bcae-4913-8938-54fda9efe330.svg"
alt="bg" alt="bg"

View File

@ -64,10 +64,11 @@ const BackgroundImage: React.FC<BackgroundImageProps> = ({ colorPrimary, isLight
<source srcSet={entity.webp} type="image/webp" /> <source srcSet={entity.webp} type="image/webp" />
<source srcSet={entity.url} type="image/jpeg" /> <source srcSet={entity.url} type="image/jpeg" />
<img <img
draggable={false}
className={cls} className={cls}
style={{ ...style, opacity: isLight ? opacity : 0 }} style={{ ...style, opacity: isLight ? opacity : 0 }}
src={entity.url} src={entity.url}
alt="" alt="bg"
/> />
</picture> </picture>
); );

View File

@ -113,7 +113,7 @@ const MobileCarousel: React.FC<MobileCarouselProps> = (props) => {
<Carousel className={styles.carousel} afterChange={setCurrentSlider}> <Carousel className={styles.carousel} afterChange={setCurrentSlider}>
{mobileImageConfigList.map((item, index) => ( {mobileImageConfigList.map((item, index) => (
<div key={index}> <div key={index}>
<img src={item.imageSrc} className={styles.img} alt="" /> <img draggable={false} src={item.imageSrc} className={styles.img} alt="carousel" />
</div> </div>
))} ))}
</Carousel> </Carousel>

View File

@ -78,12 +78,13 @@ const Homepage: React.FC = () => {
<Group <Group
title={locale.designTitle} title={locale.designTitle}
description={locale.designDesc} description={locale.designDesc}
background={isRootDark ? 'rgb(57, 63, 74)' : '#F5F8FF'} background={isRootDark ? '#393F4A' : '#F5F8FF'}
decoration={ decoration={
<img <img
draggable={false}
className={styles.image} className={styles.image}
src="https://gw.alipayobjects.com/zos/bmw-prod/ba37a413-28e6-4be4-b1c5-01be1a0ebb1c.svg" src="https://gw.alipayobjects.com/zos/bmw-prod/ba37a413-28e6-4be4-b1c5-01be1a0ebb1c.svg"
alt="" alt="bg"
/> />
} }
> >

View File

@ -28,7 +28,7 @@ function matchDeprecated(v: string): MatchDeprecatedResult {
} }
const useStyle = createStyles(({ token, css }) => ({ const useStyle = createStyles(({ token, css }) => ({
ref: css` linkRef: css`
margin-inline-start: ${token.marginXS}px; margin-inline-start: ${token.marginXS}px;
`, `,
bug: css` bug: css`
@ -57,6 +57,16 @@ const useStyle = createStyles(({ token, css }) => ({
} }
} }
`, `,
extraLink: css`
font-size: ${token.fontSize}px;
`,
drawerContent: {
position: 'relative',
[`> ${token.antCls}-drawer-body`]: {
scrollbarWidth: 'thin',
scrollbarColor: 'unset',
},
},
})); }));
export interface ComponentChangelogProps { export interface ComponentChangelogProps {
@ -117,7 +127,7 @@ const ParseChangelog: React.FC<{ changelog: string; refs: string[]; styles: any
<span>{parsedChangelog}</span> <span>{parsedChangelog}</span>
{/* Refs */} {/* Refs */}
{refs?.map((ref) => ( {refs?.map((ref) => (
<a className={styles.ref} key={ref} href={ref} target="_blank" rel="noreferrer"> <a className={styles.linkRef} key={ref} href={ref} target="_blank" rel="noreferrer">
#{ref.match(/^.*\/(\d+)$/)?.[1]} #{ref.match(/^.*\/(\d+)$/)?.[1]}
</a> </a>
))} ))}
@ -223,27 +233,21 @@ const ComponentChangelog: React.FC<ComponentChangelogProps> = (props) => {
return ( return (
<> <>
<Button <Button icon={<HistoryOutlined />} onClick={() => setShow(true)}>
icon={<HistoryOutlined />}
onClick={() => {
setShow(true);
}}
>
{locale.changelog} {locale.changelog}
</Button> </Button>
<Drawer <Drawer
destroyOnClose
className={styles.drawerContent}
title={locale.changelog} title={locale.changelog}
extra={ extra={
<Link style={{ fontSize: 14 }} to={`/changelog${lang === 'cn' ? '-cn' : ''}`}> <Link className={styles.extraLink} to={`/changelog${lang === 'cn' ? '-cn' : ''}`}>
{locale.full} {locale.full}
</Link> </Link>
} }
open={show} open={show}
width={width} width={width}
onClose={() => { onClose={() => setShow(false)}
setShow(false);
}}
destroyOnClose
> >
<Timeline items={timelineItems} /> <Timeline items={timelineItems} />
</Drawer> </Drawer>

View File

@ -35,7 +35,6 @@ const ThemeSwitch: React.FC<ThemeSwitchProps> = (props) => {
icon={<ThemeIcon />} icon={<ThemeIcon />}
aria-label="Theme Switcher" aria-label="Theme Switcher"
badge={{ dot: true }} badge={{ dot: true }}
style={{ zIndex: 1010 }}
> >
<Link <Link
to={getLocalizedPathname('/theme-editor', isZhCN(pathname), search)} to={getLocalizedPathname('/theme-editor', isZhCN(pathname), search)}

View File

@ -24,6 +24,7 @@ const GlobalStyle: React.FC = () => {
} }
.markdown img { .markdown img {
display: block;
max-width: calc(100% - 32px); max-width: calc(100% - 32px);
max-height: 100%; max-height: 100%;
} }
@ -183,6 +184,8 @@ const GlobalStyle: React.FC = () => {
background-color: ${token.siteMarkdownCodeBg}; background-color: ${token.siteMarkdownCodeBg};
border-radius: ${token.borderRadius}px; border-radius: ${token.borderRadius}px;
> pre.prism-code { > pre.prism-code {
scrollbar-width: thin;
scrollbar-color: unset;
padding: ${token.paddingSM}px ${token.paddingMD}px; padding: ${token.paddingSM}px ${token.paddingMD}px;
font-size: ${token.fontSize}px; font-size: ${token.fontSize}px;
line-height: 2; line-height: 2;

View File

@ -90,7 +90,7 @@ exports[`renders components/affix/demo/on-change.tsx extend context correctly 2`
exports[`renders components/affix/demo/target.tsx extend context correctly 1`] = ` exports[`renders components/affix/demo/target.tsx extend context correctly 1`] = `
<div <div
style="width: 100%; height: 100px; overflow: auto; box-shadow: 0 0 0 1px #40a9ff;" style="width: 100%; height: 100px; overflow: auto; box-shadow: 0 0 0 1px #1677ff;"
> >
<div <div
style="width: 100%; height: 1000px;" style="width: 100%; height: 1000px;"

View File

@ -84,7 +84,7 @@ exports[`renders components/affix/demo/on-change.tsx correctly 1`] = `
exports[`renders components/affix/demo/target.tsx correctly 1`] = ` exports[`renders components/affix/demo/target.tsx correctly 1`] = `
<div <div
style="width:100%;height:100px;overflow:auto;box-shadow:0 0 0 1px #40a9ff" style="width:100%;height:100px;overflow:auto;box-shadow:0 0 0 1px #1677ff;scrollbar-width:thin;scrollbar-color:unset"
> >
<div <div
style="width:100%;height:1000px" style="width:100%;height:1000px"

View File

@ -5,7 +5,9 @@ const containerStyle: React.CSSProperties = {
width: '100%', width: '100%',
height: 100, height: 100,
overflow: 'auto', overflow: 'auto',
boxShadow: '0 0 0 1px #40a9ff', boxShadow: '0 0 0 1px #1677ff',
scrollbarWidth: 'thin',
scrollbarColor: 'unset',
}; };
const style: React.CSSProperties = { const style: React.CSSProperties = {

View File

@ -28,9 +28,9 @@ import { TIME } from './constant';
import type { RangePickerProps } from './interface'; import type { RangePickerProps } from './interface';
import useComponents from './useComponents'; import useComponents from './useComponents';
export default function generateRangePicker<DateType extends AnyObject>( const generateRangePicker = <DateType extends AnyObject = AnyObject>(
generateConfig: GenerateConfig<DateType>, generateConfig: GenerateConfig<DateType>,
) { ) => {
type DateRangePickerProps = RangePickerProps<DateType>; type DateRangePickerProps = RangePickerProps<DateType>;
const RangePicker = forwardRef<PickerRef, DateRangePickerProps>((props, ref) => { const RangePicker = forwardRef<PickerRef, DateRangePickerProps>((props, ref) => {
@ -179,4 +179,6 @@ export default function generateRangePicker<DateType extends AnyObject>(
} }
return RangePicker; return RangePicker;
} };
export default generateRangePicker;

View File

@ -39,7 +39,9 @@ import {
import type { GenericTimePickerProps, PickerProps, PickerPropsWithMultiple } from './interface'; import type { GenericTimePickerProps, PickerProps, PickerPropsWithMultiple } from './interface';
import useComponents from './useComponents'; import useComponents from './useComponents';
const generatePicker = <DateType extends AnyObject>(generateConfig: GenerateConfig<DateType>) => { const generatePicker = <DateType extends AnyObject = AnyObject>(
generateConfig: GenerateConfig<DateType>,
) => {
type DatePickerProps = PickerProps<DateType>; type DatePickerProps = PickerProps<DateType>;
type TimePickerProps = GenericTimePickerProps<DateType>; type TimePickerProps = GenericTimePickerProps<DateType>;

View File

@ -6,7 +6,9 @@ import generateSinglePicker from './generateSinglePicker';
export type { PickerLocale, PickerProps } from './interface'; export type { PickerLocale, PickerProps } from './interface';
function generatePicker<DateType extends AnyObject>(generateConfig: GenerateConfig<DateType>) { const generatePicker = <DateType extends AnyObject = AnyObject>(
generateConfig: GenerateConfig<DateType>,
) => {
// =========================== Picker =========================== // =========================== Picker ===========================
const { DatePicker, WeekPicker, MonthPicker, YearPicker, TimePicker, QuarterPicker } = const { DatePicker, WeekPicker, MonthPicker, YearPicker, TimePicker, QuarterPicker } =
generateSinglePicker(generateConfig); generateSinglePicker(generateConfig);
@ -39,6 +41,6 @@ function generatePicker<DateType extends AnyObject>(generateConfig: GenerateConf
} }
return MergedDatePicker; return MergedDatePicker;
} };
export default generatePicker; export default generatePicker;

View File

@ -10,7 +10,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*DLUwQ4B2_zQAAA
## Design concept ## Design concept
<div class="grid-demo"> <div class="grid-demo">
<img src="https://gw.alipayobjects.com/zos/bmw-prod/9189c9ef-c601-40dc-9960-c11dbb681888.svg" alt="grid design" /> <img draggable="false" src="https://gw.alipayobjects.com/zos/bmw-prod/9189c9ef-c601-40dc-9960-c11dbb681888.svg" alt="grid design" />
</div> </div>
In most business situations, Ant Design needs to solve a lot of information storage problems within the design area, so based on 12 Grids System, we divided the design area into 24 sections. In most business situations, Ant Design needs to solve a lot of information storage problems within the design area, so based on 12 Grids System, we divided the design area into 24 sections.

View File

@ -11,7 +11,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*DLUwQ4B2_zQAAA
## 设计理念 ## 设计理念
<div class="grid-demo"> <div class="grid-demo">
<img src="https://gw.alipayobjects.com/zos/bmw-prod/9189c9ef-c601-40dc-9960-c11dbb681888.svg" alt="grid design" /> <img draggable="false" src="https://gw.alipayobjects.com/zos/bmw-prod/9189c9ef-c601-40dc-9960-c11dbb681888.svg" alt="grid design" />
</div> </div>
在多数业务情况下Ant Design 需要在设计区域内解决大量信息收纳的问题,因此在 12 栅格系统的基础上,我们将整个设计建议区域按照 24 等分的原则进行划分。 在多数业务情况下Ant Design 需要在设计区域内解决大量信息收纳的问题,因此在 12 栅格系统的基础上,我们将整个设计建议区域按照 24 等分的原则进行划分。

View File

@ -747,7 +747,7 @@ exports[`renders components/layout/demo/fixed-sider.tsx correctly 1`] = `
> >
<aside <aside
class="ant-layout-sider ant-layout-sider-dark" class="ant-layout-sider ant-layout-sider-dark"
style="overflow:auto;height:100vh;position:fixed;left:0;top:0;bottom:0;flex:0 0 200px;max-width:200px;min-width:200px;width:200px" style="overflow:auto;height:100vh;position:fixed;left:0;top:0;bottom:0;scrollbar-width:thin;scrollbar-color:unset;flex:0 0 200px;max-width:200px;min-width:200px;width:200px"
> >
<div <div
class="ant-layout-sider-children" class="ant-layout-sider-children"

View File

@ -14,6 +14,17 @@ import { Layout, Menu, theme } from 'antd';
const { Header, Content, Footer, Sider } = Layout; const { Header, Content, Footer, Sider } = Layout;
const siderStyle: React.CSSProperties = {
overflow: 'auto',
height: '100vh',
position: 'fixed',
left: 0,
top: 0,
bottom: 0,
scrollbarWidth: 'thin',
scrollbarColor: 'unset',
};
const items: MenuProps['items'] = [ const items: MenuProps['items'] = [
UserOutlined, UserOutlined,
VideoCameraOutlined, VideoCameraOutlined,
@ -36,9 +47,7 @@ const App: React.FC = () => {
return ( return (
<Layout hasSider> <Layout hasSider>
<Sider <Sider style={siderStyle}>
style={{ overflow: 'auto', height: '100vh', position: 'fixed', left: 0, top: 0, bottom: 0 }}
>
<div className="demo-logo-vertical" /> <div className="demo-logo-vertical" />
<Menu theme="dark" mode="inline" defaultSelectedKeys={['4']} items={items} /> <Menu theme="dark" mode="inline" defaultSelectedKeys={['4']} items={items} />
</Sider> </Sider>