Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from ant-design:master #41

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5ddec3a
chore: CI of PR welcome (#44184)
zombieJ Aug 11, 2023
56f2bc5
fix: (tabs)Unexpected color change in the click area of the mobile ta…
electroluxcode Aug 14, 2023
72b449a
docs: update faq (#44198)
zombieJ Aug 14, 2023
ee984fe
fix: Modal open should not block dropdown hidden (#44204)
zombieJ Aug 14, 2023
d1bd2d0
docs: Update recommendation (#44207)
afc163 Aug 14, 2023
e0e373f
fix(badge): fix badge number is rtl (#43998)
NotEvenANeko Aug 14, 2023
41cb8be
fix(DatePicker): optimize RangePicker's range area style (#44206)
kiner-tang Aug 14, 2023
16f0738
chore(deps-dev): bump lint-staged from 13.3.0 to 14.0.0 (#44212)
dependabot[bot] Aug 14, 2023
d493594
docs: fix menu sider-current demo (#44222)
MadCcc Aug 15, 2023
aff2bb7
chore: update pagination (#44226)
zombieJ Aug 15, 2023
9ec8534
docs(cascader): fix allowClear default value in doc (#44230)
zbw-zbw Aug 15, 2023
4fb448f
doc: upload doc line break (#44234)
1587315093 Aug 15, 2023
3f0e747
docs: fix theme editor page (#44232)
MadCcc Aug 15, 2023
8a65ad6
docs: fix font color (#44236)
MadCcc Aug 15, 2023
83e3b52
docs(Tabs): update animated prop's description (#44227)
kovsu Aug 15, 2023
a92a883
docs: render china mirror link before hydration (#44233)
afc163 Aug 16, 2023
9ba9da2
fix: ColorPicker HEX input cursor jump bug (#44137)
gouge666 Aug 16, 2023
808452e
fix(DataPicker):fix picker content is not centered (#44245)
Zian502 Aug 17, 2023
f1c38bf
site(Calendar): add lunar calendar demo (#44166)
kiner-tang Aug 17, 2023
3525966
docs: Update faq.zh-CN.md (#44274)
afc163 Aug 17, 2023
7179dc8
docs: update footer links (#44272)
afc163 Aug 17, 2023
73cfd37
fix: `Descriptions` key prop issue (#44278)
RedJue Aug 17, 2023
affd62f
chore(deps-dev): bump @testing-library/jest-dom from 5.17.0 to 6.0.0 …
dependabot[bot] Aug 17, 2023
ce687c5
fix(ColorPicker): color clear deformation (#44258) (#44273)
kouchao Aug 18, 2023
3b913cf
site: add internationalization for docs (#44263)
li-jia-nan Aug 18, 2023
7226c53
docs: add third-party library to the development section (#44283)
ArtyomVancyan Aug 18, 2023
8177c52
docs: add changelog 5.8.4 (#44293)
xrkffgg Aug 18, 2023
80bd54f
chore: redirect with rest url (#44298)
iola1999 Aug 18, 2023
8afbe69
docs(demo): Replace backticks with single quotes (#44302)
thinkasany Aug 20, 2023
65fd05c
style: add prettier-plugin-sort-imports (#44287)
crazyair Aug 21, 2023
3b5e3e8
docs(tabs): remove useless string in Description (#44307)
thinkasany Aug 21, 2023
b50928f
chore: split previewer (#44310)
MadCcc Aug 21, 2023
e02e53b
docs: link preload => prefetch (#44320)
afc163 Aug 21, 2023
21a2265
docs: show mirror modal on page load (#44291)
MadCcc Aug 21, 2023
b26e3a7
fix: WaterMark clip logic (#44321)
zombieJ Aug 21, 2023
da699b1
docs: add fallback for previewer (#44327)
MadCcc Aug 21, 2023
06d1c9a
docs: font flash in home page (#44333)
afc163 Aug 22, 2023
af301a9
fix(date-picker):fix format type processing for showTime. (#44306)
Zian502 Aug 22, 2023
80e1bc8
style: remove importOrderSeparation from prettier config (#44336)
crazyair Aug 22, 2023
70d9a90
docs: fix anchor positioning (#44348)
MadCcc Aug 22, 2023
0295322
docs: prevent highlight code initially (#44344)
afc163 Aug 22, 2023
4d12efe
chore: Update pr-contributor-welcome.yml (#44340)
afc163 Aug 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions .dumi/mirror-modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
(function createMirrorModal() {
if (
(navigator.languages.includes('zh') || navigator.languages.includes('zh-CN')) &&
/-cn\/?$/.test(window.location.pathname) &&
!['ant-design.gitee.io', 'ant-design.antgroup.com'].includes(window.location.hostname)
) {
const ANTD_DOT_NOT_SHOW_MIRROR_MODAL = 'ANT_DESIGN_DO_NOT_OPEN_MIRROR_MODAL';

const lastShowTime = window.localStorage.getItem(ANTD_DOT_NOT_SHOW_MIRROR_MODAL);
if (
lastShowTime &&
lastShowTime !== 'true' &&
Date.now() - new Date(lastShowTime).getTime() < 7 * 24 * 60 * 60 * 1000
) {
return;
}

const style = document.createElement('style');
style.innerHTML = `
@keyframes mirror-fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

@keyframes mirror-zoom-in {
from {
transform: scale(0.8);
}
to {
transform: scale(1);
}
}

.mirror-modal-mask {
position: fixed;
inset: 0;
height: '100vh';
width: '100vw';
background: rgba(0, 0, 0, 0.3);
z-index: 9999;
animation: mirror-fade-in 0.3s forwards;
}

.mirror-modal-dialog {
position: fixed;
inset: 0;
top: 120px;
margin-left: auto;
margin-right: auto;
width: 400px;
height: 120px;
display: flex;
align-items: center;
flex-direction: column;
border-radius: 8px;
border: 1px solid #eee;
background: #fff;
padding: 20px 24px;
box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
animation: mirror-zoom-in 0.3s forwards;
}

.mirror-modal-title {
font-size: 16px;
font-weight: 500;
align-self: flex-start;
margin-bottom: 8px;
}

.mirror-modal-content {
font-size: 14px;
align-self: flex-start;
margin-bottom: 16px;
}

.mirror-modal-btns {
align-self: flex-end;
margin-top: auto;
display: flex;
align-items: center;
}

.mirror-modal-btn {
border-radius: 6px;
cursor: pointer;
height: 32px;
box-sizing: border-box;
font-size: 14px;
padding: 4px 16px;
display: inline-flex;
align-items: center;
text-decoration: none;
transition: all 0.2s;
}

.mirror-modal-confirm-btn {
background: #1677ff;
color: #fff;
}

.mirror-modal-confirm-btn:hover {
background: #4096ff;
}

.mirror-modal-confirm-btn:active {
background: #0958d9;
}

.mirror-modal-cancel-btn {
border: 1px solid #eee;
color: #000;
margin-right: 8px;
}

.mirror-modal-cancel-btn:hover {
border-color: #4096ff;
color: #4096ff
}

.mirror-modal-cancel-btn:active {
border-color: #0958d9;
color: #0958d9;
}
`;
document.head.append(style);

const modal = document.createElement('div');
modal.className = 'mirror-modal-mask';

const dialog = document.createElement('div');
dialog.className = 'mirror-modal-dialog';
modal.append(dialog);

const title = document.createElement('div');
title.className = 'mirror-modal-title';
title.innerText = '提示';
dialog.append(title);

const content = document.createElement('div');
content.className = 'mirror-modal-content';
content.innerText = '国内用户推荐访问国内镜像以获得极速体验~';
dialog.append(content);

const btnWrapper = document.createElement('div');
btnWrapper.className = 'mirror-modal-btns';
dialog.append(btnWrapper);

const cancelBtn = document.createElement('a');
cancelBtn.className = 'mirror-modal-cancel-btn mirror-modal-btn';
cancelBtn.innerText = '7 天内不再显示';
btnWrapper.append(cancelBtn);
cancelBtn.addEventListener('click', () => {
window.localStorage.setItem(ANTD_DOT_NOT_SHOW_MIRROR_MODAL, new Date().toISOString());
document.body.removeChild(modal);
document.head.removeChild(style);
document.body.style.overflow = '';
});

const confirmBtn = document.createElement('a');
confirmBtn.className = 'mirror-modal-confirm-btn mirror-modal-btn';
confirmBtn.href = window.location.href.replace(window.location.host, 'ant-design.antgroup.com');
confirmBtn.innerText = '🚀 立刻前往';
btnWrapper.append(confirmBtn);

document.body.append(modal);
document.body.style.overflow = 'hidden';
}
})();
5 changes: 0 additions & 5 deletions .dumi/pages/theme-editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ const CustomTheme = () => {
const storedConfig = localStorage.getItem(ANT_DESIGN_V5_THEME_EDITOR_THEME);
if (storedConfig) {
const themeConfig = JSON.parse(storedConfig);
const originThemeConfig = {
json: themeConfig,
text: undefined,
};
setThemeConfigContent(originThemeConfig);
setTheme(themeConfig);
}
}, []);
Expand Down
2 changes: 1 addition & 1 deletion .dumi/theme/builtins/IconSearch/Category.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Category: React.FC<CategoryProps> = (props) => {
const { icons, title, newIcons, theme } = props;
const intl = useIntl();
const [justCopied, setJustCopied] = React.useState<string | null>(null);
const copyId = React.useRef<NodeJS.Timeout | null>(null);
const copyId = React.useRef<ReturnType<typeof setTimeout> | null>(null);
const onCopied = React.useCallback((type: string, text: string) => {
message.success(
<span>
Expand Down
48 changes: 6 additions & 42 deletions .dumi/theme/builtins/Previewer/CodePreviewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import type { Project } from '@stackblitz/sdk';
import stackblitzSdk from '@stackblitz/sdk';
import classNames from 'classnames';
import { FormattedMessage, useSiteData } from 'dumi';
import toReactElement from 'jsonml-to-react-element';
import JsonML from 'jsonml.js/lib/utils';
import LZString from 'lz-string';
import Prism from 'prismjs';
import React, { useContext, useEffect, useRef, useState } from 'react';
import CopyToClipboard from 'react-copy-to-clipboard';
import { Alert, Badge, Space, Tooltip } from 'antd';
Expand All @@ -31,28 +28,6 @@ import { ping } from '../../utils';

const { ErrorBoundary } = Alert;

function toReactComponent(jsonML: any) {
return toReactElement(jsonML, [
[
(node: any) => JsonML.isElement(node) && JsonML.getTagName(node) === 'pre',
(node: any, index: any) => {
// ref: /~https://github.com/benjycui/bisheng/blob/master/packages/bisheng/src/bisheng-plugin-highlight/lib/browser.js#L7
const attr = JsonML.getAttributes(node);
return React.createElement(
'pre',
{
key: index,
className: `language-${attr.lang}`,
},
React.createElement('code', {
dangerouslySetInnerHTML: { __html: attr.highlighted },
}),
);
},
],
]);
}

function compress(string: string): string {
return LZString.compressToBase64(string)
.replace(/\+/g, '-') // Convert '+' to '-'
Expand Down Expand Up @@ -130,13 +105,6 @@ const CodePreviewer: React.FC<AntdPreviewerProps> = (props) => {

const [showOnlineUrl, setShowOnlineUrl] = useState<boolean>(false);

const highlightedCodes = {
jsx: Prism.highlight(jsx, Prism.languages.javascript, 'jsx'),
tsx: Prism.highlight(entryCode, Prism.languages.javascript, 'jsx'),
};

const highlightedStyle = style ? Prism.highlight(style, Prism.languages.css, 'css') : '';

useEffect(() => {
const regexp = /preview-(\d+)-ant-design/; // matching PR preview addresses
setShowOnlineUrl(
Expand Down Expand Up @@ -538,17 +506,11 @@ createRoot(document.getElementById('container')).render(<Demo />);
{codeExpand && (
<section className={highlightClass} key="code">
<CodePreview
codes={highlightedCodes}
toReactComponent={toReactComponent}
sourceCode={entryCode}
jsxCode={jsx}
styleCode={style}
onCodeTypeChange={(type) => setCodeType(type)}
/>
{highlightedStyle ? (
<div key="style" className="highlight">
<pre>
<code className="css" dangerouslySetInnerHTML={{ __html: highlightedStyle }} />
</pre>
</div>
) : null}
</section>
)}
</section>
Expand All @@ -560,7 +522,9 @@ createRoot(document.getElementById('container')).render(<Demo />);
// resulting in some response delays like following issue:
// /~https://github.com/ant-design/ant-design/issues/39995
// So we insert style tag into head tag.
if (!style) return;
if (!style) {
return;
}
const styleTag = document.createElement('style');
styleTag.type = 'text/css';
styleTag.innerHTML = style;
Expand Down
22 changes: 22 additions & 0 deletions .dumi/theme/builtins/Previewer/Previewer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import type { IPreviewerProps } from 'dumi';
import { useTabMeta } from 'dumi';

import CodePreviewer from './CodePreviewer';
import DesignPreviewer from './DesignPreviewer';

export interface AntdPreviewerProps extends IPreviewerProps {
originDebug?: IPreviewerProps['debug'];
}

const Previewer: React.FC<AntdPreviewerProps> = (props) => {
const tab = useTabMeta();

if (tab?.frontmatter.title === 'Design') {
return <DesignPreviewer {...props} />;
}

return <CodePreviewer {...props} />;
};

export default Previewer;
49 changes: 34 additions & 15 deletions .dumi/theme/builtins/Previewer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
import React, { Suspense } from 'react';
import type { IPreviewerProps } from 'dumi';
import { useTabMeta } from 'dumi';
import React from 'react';
import CodePreviewer from './CodePreviewer';
import DesignPreviewer from './DesignPreviewer';
import { Skeleton, Alert } from 'antd';
import { createStyles } from 'antd-style';

export interface AntdPreviewerProps extends IPreviewerProps {
originDebug?: IPreviewerProps['debug'];
}
const { ErrorBoundary } = Alert;

const Previewer: React.FC<AntdPreviewerProps> = (props) => {
const tab = useTabMeta();
const Previewer = React.lazy(() => import('./Previewer'));

if (tab?.frontmatter.title === 'Design') {
return <DesignPreviewer {...props} />;
}
const useStyle = createStyles(({ css }) => ({
skeletonWrapper: css`
width: 100% !important;
height: 500px;
margin-bottom: 16px;
`,
}));

return <CodePreviewer {...props} />;
export default (props: IPreviewerProps) => {
const { styles } = useStyle();
return (
<ErrorBoundary>
<Suspense
fallback={
<Skeleton.Node
active
className={styles.skeletonWrapper}
style={{
width: '100%',
height: '100%',
}}
>
{' '}
</Skeleton.Node>
}
>
<Previewer {...props} />
</Suspense>
</ErrorBoundary>
);
};

export default Previewer;
4 changes: 2 additions & 2 deletions .dumi/theme/builtins/TokenCompare/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames';
import { TinyColor } from '@ctrl/tinycolor';
import { createStyles } from 'antd-style';
import tokenMeta from 'antd/es/version/token-meta.json';
import { theme, Space } from 'antd';
import { Space, theme } from 'antd';
import useLocale from '../../../hooks/useLocale';

const useStyle = createStyles(({ token, css }) => {
Expand All @@ -29,7 +29,7 @@ const useStyle = createStyles(({ token, css }) => {
display: flex;
align-items: center;
justify-content: center;

color: rgba(0,0,0,0.88);
border-right: 1px solid rgba(0, 0, 0, 0.1);
`,

Expand Down
Loading