Skip to content

Commit

Permalink
chore: auto merge branches (#39003)
Browse files Browse the repository at this point in the history
chore: feature merge master
  • Loading branch information
github-actions[bot] committed Nov 25, 2022
2 parents ce5d71d + c224855 commit 5bb2479
Show file tree
Hide file tree
Showing 236 changed files with 7,421 additions and 3,656 deletions.
12 changes: 6 additions & 6 deletions .dumi/hooks/useMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type UseMenuOptions = {

const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] => {
const fullData = useFullSidebarData();
const { pathname } = useLocation();
const { pathname, search } = useLocation();
const sidebarData = useSidebarData();
const { before, after } = options;

Expand Down Expand Up @@ -60,7 +60,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
childItems.push(
...childrenGroup.default.map((item) => ({
label: (
<Link to={item.link}>
<Link to={`${item.link}${search}`}>
{before}
{item.title}
{after}
Expand All @@ -77,7 +77,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
key: type,
children: children?.map((item) => ({
label: (
<Link to={item.link}>
<Link to={`${item.link}${search}`}>
{before}
{item.title}
{after}
Expand All @@ -100,7 +100,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
key: group.title,
children: group.children?.map((item) => ({
label: (
<Link to={item.link}>
<Link to={`${item.link}${search}`}>
{before}
<span key="english">{item.title}</span>
<span className="chinese" key="chinese">
Expand All @@ -117,7 +117,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
result.push(
...group.children?.map((item) => ({
label: (
<Link to={item.link}>
<Link to={`${item.link}${search}`}>
{before}
{item.title}
{after}
Expand All @@ -130,7 +130,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
return result;
}, []) ?? []
);
}, [sidebarData, fullData, pathname]);
}, [sidebarData, fullData, pathname, search]);

return [menuItems, pathname];
};
Expand Down
6 changes: 3 additions & 3 deletions .dumi/pages/index/components/RecommendsOld.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const useStyle = () => {
}
.intro {
transform: translateY(0);
transform: translate3d(0, 0, 0);
h4${token.antCls}-typography {
padding-bottom: 0;
Expand All @@ -48,7 +48,7 @@ const useStyle = () => {
right: 0;
bottom: 0;
left: 0;
transform: translateY(100%);
transform: translate3d(0, 100%, 0);
transition: all ${token.motionDurationSlow};
${token.antCls}-typography {
Expand All @@ -62,7 +62,7 @@ const useStyle = () => {
h4${token.antCls}-typography {
position: absolute;
padding: 0 ${token.paddingMD}px ${token.paddingMD}px;
transform: translateY(-100%);
transform: translate3d(0, -100%, 0);
}
div${token.antCls}-typography {
Expand Down
6 changes: 3 additions & 3 deletions .dumi/pages/index/components/Theme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const useStyle = () => {

logoImgPureColor: css`
img {
transform: translateX(-30px);
transform: translate3d(-30px, 0, 0);
}
`,

Expand Down Expand Up @@ -512,7 +512,7 @@ export default function Theme() {
style={{
...posStyle,
left: '50%',
transform: 'translateX(-900px)',
transform: 'translate3d(-900px, 0, 0)',
top: -100,
height: 500,
}}
Expand All @@ -523,7 +523,7 @@ export default function Theme() {
style={{
...posStyle,
right: '50%',
transform: 'translateX(750px)',
transform: 'translate3d(750px, 0, 0)',
bottom: -100,
height: 287,
}}
Expand Down
16 changes: 3 additions & 13 deletions .dumi/pages/index/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useLayoutEffect, type FC } from 'react';
import React from 'react';
import { useLocale as useDumiLocale } from 'dumi';
import { css } from '@emotion/react';
import useLocale from '../../hooks/useLocale';
Expand All @@ -11,8 +11,6 @@ import BannerRecommends from './components/BannerRecommends';
import ComponentsList from './components/ComponentsList';
import DesignFramework from './components/DesignFramework';
import { ConfigProvider } from 'antd';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';

const useStyle = () => {
const { token } = useSiteToken();
Expand Down Expand Up @@ -44,23 +42,15 @@ const locales = {
},
};

const Homepage: FC = () => {
const [locale, lang] = useLocale(locales);
const Homepage: React.FC = () => {
const [locale] = useLocale(locales);
const { id: localeId } = useDumiLocale();
const localeStr = localeId === 'zh-CN' ? 'cn' : 'en';

const [siteData, loading] = useSiteData();

const style = useStyle();

useLayoutEffect(() => {
if (lang === 'cn') {
dayjs.locale('zh-cn');
} else {
dayjs.locale('en');
}
}, []);

return (
<ConfigProvider theme={{ algorithm: undefined }}>
<section>
Expand Down
10 changes: 5 additions & 5 deletions .dumi/pages/theme-editor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ThemeEditor } from 'antd-token-previewer';
import { useContext } from 'react';
import ThemeContext from '../../theme/slots/ThemeContext';
import { useState } from 'react';
import useLocale from '../../hooks/useLocale';
import { ConfigProvider } from 'antd';
import { ThemeConfig } from 'antd/es/config-provider/context';

const locales = {
cn: {
Expand All @@ -15,13 +15,13 @@ const locales = {

const CustomTheme = () => {
const [locale] = useLocale(locales);
const { setTheme, theme } = useContext(ThemeContext);
const [theme, setTheme] = useState<ThemeConfig>({});

return (
<div>
<ConfigProvider theme={{ algorithm: undefined }}>
<ConfigProvider theme={{ inherit: false }}>
<ThemeEditor
theme={{ name: 'test', key: 'test', config: theme }}
theme={{ name: 'Custom Theme', key: 'test', config: theme }}
simple
style={{ height: 'calc(100vh - 64px)' }}
onThemeChange={(newTheme) => {
Expand Down
4 changes: 2 additions & 2 deletions .dumi/theme/builtins/APITable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { type FC } from 'react';
import React from 'react';

const APITable: FC = () => {
const APITable: React.FC = () => {
// TODO: implement api table, depend on the new markdown data structure passed
return <>API Table</>;
};
Expand Down
4 changes: 2 additions & 2 deletions .dumi/theme/builtins/Previewer/fromDumiProps.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState, type FC } from 'react';
import React, { useEffect, useState } from 'react';
// @ts-ignore
import JsonML from 'jsonml.js/lib/utils';
// @ts-ignore
Expand Down Expand Up @@ -36,7 +36,7 @@ function useShowRiddleButton() {
*/
export default function fromDumiProps<P extends object>(
WrappedComponent: React.ComponentType<P>,
): FC<IPreviewerProps> {
): React.FC<IPreviewerProps> {
const hoc = function DumiPropsAntdPreviewer(props: IPreviewerProps) {
const showRiddleButton = useShowRiddleButton();
const location = useLocation();
Expand Down
10 changes: 5 additions & 5 deletions .dumi/theme/builtins/Previewer/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint jsx-a11y/no-noninteractive-element-interactions: 0 */
import { CheckOutlined, SnippetsOutlined, ThunderboltOutlined } from '@ant-design/icons';
import stackblitzSdk from '@stackblitz/sdk';
import { Alert, Badge, Tooltip } from 'antd';
import { Alert, Badge, Tooltip, Space } from 'antd';
import classNames from 'classnames';
import LZString from 'lz-string';
import React from 'react';
Expand Down Expand Up @@ -375,7 +375,7 @@ createRoot(document.getElementById('container')).render(<Demo />);
/>
</div>
<div className="code-box-description">{introChildren}</div>
<div className="code-box-actions">
<Space wrap size="middle" className="code-box-actions">
{showRiddleButton ? (
<form
className="code-box-code-action"
Expand Down Expand Up @@ -466,7 +466,7 @@ createRoot(document.getElementById('container')).render(<Demo />);
<Tooltip
title={<FormattedMessage id={`app.demo.code.${codeExpand ? 'hide' : 'show'}`} />}
>
<span className="code-expand-icon code-box-code-action">
<div className="code-expand-icon code-box-code-action">
<img
alt="expand code"
src={
Expand All @@ -487,9 +487,9 @@ createRoot(document.getElementById('container')).render(<Demo />);
className={codeExpand ? 'code-expand-icon-show' : 'code-expand-icon-hide'}
onClick={() => this.handleCodeExpand(meta.id)}
/>
</span>
</div>
</Tooltip>
</div>
</Space>
</section>
<section className={highlightClass} key="code">
<CodePreview
Expand Down
6 changes: 3 additions & 3 deletions .dumi/theme/builtins/ResourceCards/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { type FC } from 'react';
import React from 'react';
import { Col, Row } from 'antd';
import { css } from '@emotion/react';
import useSiteToken from '../../../hooks/useSiteToken';
Expand Down Expand Up @@ -70,7 +70,7 @@ export type ResourceCardProps = {
resource: Resource;
};

const ResourceCard: FC<ResourceCardProps> = ({ resource }) => {
const ResourceCard: React.FC<ResourceCardProps> = ({ resource }) => {
const styles = useStyle();

const { title: titleStr, description, cover, src, official } = resource;
Expand Down Expand Up @@ -105,7 +105,7 @@ export type ResourceCardsProps = {
resources: Resource[];
};

const ResourceCards: FC<ResourceCardsProps> = ({ resources }) => {
const ResourceCards: React.FC<ResourceCardsProps> = ({ resources }) => {
return (
<Row style={{ margin: '-12px -12px 0 -12px' }}>
{resources.map((item) => (
Expand Down
114 changes: 114 additions & 0 deletions .dumi/theme/builtins/TokenTable/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import React, { FC, useMemo } from 'react';
import tokenMeta from 'antd/es/version/token-meta.json';
import { getDesignToken } from 'antd-token-previewer';
import { Table, TableProps, Tag } from 'antd';
import useLocale from '../../../hooks/useLocale';
import useSiteToken from '../../../hooks/useSiteToken';
import { css } from '@emotion/react';

type TokenTableProps = {
type: 'seed' | 'map' | 'alias';
lang: 'zh' | 'en';
};

type TokenData = {
name: string;
desc: string;
type: string;
value: any;
};

const defaultToken = getDesignToken();

const locales = {
cn: {
token: 'Token 名称',
description: '描述',
type: '类型',
value: '默认值',
},
en: {
token: 'Token Name',
description: 'Description',
type: 'Type',
value: 'Default Value',
},
};

const useStyle = () => {
const { token } = useSiteToken();

return {
codeSpan: css`
margin: 0 1px;
padding: 0.2em 0.4em;
font-size: 0.9em;
background: ${token.siteMarkdownCodeBg};
border: 1px solid ${token.colorSplit};
border-radius: 3px;
font-family: monospace;
`,
};
};

const TokenTable: FC<TokenTableProps> = ({ type }) => {
const styles = useStyle();
const [locale, lang] = useLocale(locales);
const columns: Exclude<TableProps<TokenData>['columns'], undefined> = [
{
title: locale.token,
key: 'name',
dataIndex: 'name',
},
{
title: locale.description,
key: 'desc',
dataIndex: 'desc',
width: 300,
},
{
title: locale.type,
key: 'type',
dataIndex: 'type',
render: (_, record) => <span css={styles.codeSpan}>{record.type}</span>,
},
{
title: locale.value,
key: 'value',
render: (_, record) => (
<span style={{ display: 'inline-flex', alignItems: 'center' }}>
{typeof record.value === 'string' &&
(record.value.startsWith('#') || record.value.startsWith('rgb')) && (
<span
style={{
background: record.value,
display: 'inline-block',
width: 6,
height: 6,
borderRadius: '50%',
boxShadow: 'inset 0 0 0 1px rgba(0, 0, 0, 0.06)',
marginRight: 4,
}}
></span>
)}
{typeof record.value !== 'string' ? JSON.stringify(record.value) : record.value}
</span>
),
},
];

const data = useMemo<TokenData[]>(() => {
return tokenMeta[type].map((token) => {
return {
name: token.name,
desc: lang === 'cn' ? token.desc : token.descEn,
type: token.type,
value: (defaultToken as any)[token.name],
};
});
}, [type, lang]);

return <Table dataSource={data} columns={columns} pagination={false} bordered />;
};

export default TokenTable;

0 comments on commit 5bb2479

Please sign in to comment.