Skip to content

Commit dfd0106

Browse files
authored
site: rewrite inline-style => cssinjs (ant-design#48018)
1 parent 20561d6 commit dfd0106

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

.dumi/theme/builtins/ComponentMeta/index.tsx

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
/* eslint-disable lodash/import-scope */
21
import React from 'react';
32
import { GithubOutlined } from '@ant-design/icons';
43
import { Descriptions, theme, Tooltip, Typography, type GetProp } from 'antd';
54
import { createStyles, css } from 'antd-style';
6-
import { kebabCase } from 'lodash';
5+
import kebabCase from 'lodash/kebabCase';
76
import CopyToClipboard from 'react-copy-to-clipboard';
87

98
import useLocale from '../../../hooks/useLocale';
@@ -27,26 +26,41 @@ const useStyle = createStyles(({ token }) => ({
2726
code: css`
2827
cursor: pointer;
2928
position: relative;
30-
display: inline-block;
31-
border-radius: 3px;
29+
display: inline-flex;
30+
align-items: center;
31+
column-gap: 4px;
32+
border-radius: 4px;
3233
padding-inline: ${token.paddingXS}px;
3334
transition: all ${token.motionDurationSlow} !important;
34-
3535
&:hover {
3636
background: ${token.controlItemBgHover};
3737
}
3838
`,
39+
import: css`
40+
color: ${token.magenta8};
41+
`,
42+
component: css`
43+
color: ${token.colorText};
44+
`,
45+
from: css`
46+
color: ${token.magenta8};
47+
`,
48+
antd: css`
49+
color: ${token.green8};
50+
`,
51+
semicolon: css`
52+
color: ${token.colorText};
53+
`,
3954
}));
4055

4156
export interface ComponentMetaProps {
4257
component: string;
4358
source: string | true;
4459
}
4560

46-
const ComponentMeta = (props: ComponentMetaProps) => {
61+
const ComponentMeta: React.FC<ComponentMetaProps> = (props) => {
4762
const { component, source } = props;
4863
const { token } = theme.useToken();
49-
5064
const [locale] = useLocale(locales);
5165

5266
const { styles } = useStyle();
@@ -83,17 +97,17 @@ const ComponentMeta = (props: ComponentMetaProps) => {
8397

8498
// ======================== Render ========================
8599
const importList = [
86-
<span key="import" style={{ color: token.magenta8 }}>
100+
<span key="import" className={styles.import}>
87101
import
88102
</span>,
89-
<span key="component" style={{ color: token.colorText }}>{` { ${component} } `}</span>,
90-
<span key="from" style={{ color: token.magenta8 }}>
103+
<span key="component" className={styles.component}>{`{ ${component} }`}</span>,
104+
<span key="from" className={styles.from}>
91105
from
92106
</span>,
93-
<span key="antd" style={{ color: token.green8 }}>
94-
{`'antd'`}
107+
<span key="antd" className={styles.antd}>
108+
{`"antd"`}
95109
</span>,
96-
<span key="semicolon" style={{ color: token.colorText }}>
110+
<span key="semicolon" className={styles.semicolon}>
97111
;
98112
</span>,
99113
];
@@ -104,9 +118,7 @@ const ComponentMeta = (props: ComponentMetaProps) => {
104118
colon={false}
105119
column={1}
106120
style={{ marginTop: token.margin }}
107-
labelStyle={{
108-
paddingInlineEnd: token.padding,
109-
}}
121+
labelStyle={{ paddingInlineEnd: token.padding }}
110122
items={
111123
[
112124
{
@@ -118,9 +130,9 @@ const ComponentMeta = (props: ComponentMetaProps) => {
118130
onOpenChange={onOpenChange}
119131
>
120132
<span>
121-
<CopyToClipboard text={`import { ${component} } from 'antd';`} onCopy={onCopy}>
133+
<CopyToClipboard text={`import { ${component} } from "antd";`} onCopy={onCopy}>
122134
<Typography.Text className={styles.code} onClick={onCopy}>
123-
{importList.map((txt, index) => (index === 0 ? txt : [' ', txt]))}
135+
{importList}
124136
</Typography.Text>
125137
</CopyToClipboard>
126138
</span>

scripts/visual-regression/build.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable compat/compat */
2-
/* eslint-disable no-console, no-await-in-loop, import/no-extraneous-dependencies, lodash/import-scope, no-restricted-syntax */
2+
/* eslint-disable no-console, no-await-in-loop, import/no-extraneous-dependencies, no-restricted-syntax */
33
import { assert } from 'console';
44
import fs from 'fs';
55
import os from 'os';
@@ -8,7 +8,7 @@ import { Readable } from 'stream';
88
import { finished } from 'stream/promises';
99
import chalk from 'chalk';
1010
import fse from 'fs-extra';
11-
import _ from 'lodash';
11+
import difference from 'lodash/difference';
1212
import minimist from 'minimist';
1313
import pixelmatch from 'pixelmatch';
1414
import { PNG } from 'pngjs';
@@ -367,7 +367,7 @@ async function boot() {
367367
chalk.blue(`📊 Text report from pr #${prId} comparing to ${targetBranch}@${targetCommitSha}\n`),
368368
);
369369
// new images
370-
const newImgs = _.difference(currentImgFileList, baseImgFileList);
370+
const newImgs = difference(currentImgFileList, baseImgFileList);
371371
if (newImgs.length) {
372372
console.log(chalk.green(`🆕 ${newImgs.length} images added from this pr`));
373373
console.log(chalk.green('🆕 Added images list:\n'));

0 commit comments

Comments
 (0)