Skip to content

Feat css var #5327

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

Merged
merged 90 commits into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
60e2597
style: affix & util
tangjinzhou Feb 25, 2022
5ec5334
feat(alert): add customIcon slot
tangjinzhou Feb 25, 2022
2a53638
feat(anchor): ts type
tangjinzhou Feb 25, 2022
c846570
style: auto-complete
tangjinzhou Feb 25, 2022
5bdb45d
feat: avatar add crossOrigin & maxPopoverTrigger
tangjinzhou Feb 25, 2022
7c59c18
style(backTop): v-show instead v-if
tangjinzhou Feb 25, 2022
6c167c2
style: badge
tangjinzhou Feb 25, 2022
c5e9904
style: breadcrumb
tangjinzhou Feb 25, 2022
16b3b5f
feat: button add global size
tangjinzhou Feb 26, 2022
2573fe4
feat: update i18n
tangjinzhou Feb 26, 2022
afafbd6
feat: picker add disabledTime
tangjinzhou Feb 26, 2022
0e61cb7
test: update snap
tangjinzhou Feb 26, 2022
b68569f
doc: update img url
tangjinzhou Feb 27, 2022
bc43a4b
style: fix Card tabs of left position
tangjinzhou Feb 27, 2022
e44e73a
doc: update cascader doc
tangjinzhou Feb 27, 2022
4e0293e
feat: collapse
tangjinzhou Feb 27, 2022
a4b8c68
style: comment
tangjinzhou Feb 27, 2022
5da035d
style: configprovider
tangjinzhou Feb 27, 2022
27e7ed6
feat: date-picker add soem icon slot
tangjinzhou Feb 27, 2022
0283a4c
style: update descriptions style
tangjinzhou Feb 27, 2022
c528d74
feat: add divider orientationMargin
tangjinzhou Feb 27, 2022
259f5fd
doc: update drawer
tangjinzhou Feb 27, 2022
c4c691b
feat: dropdown add destroyPopupOnHide & loading
tangjinzhou Feb 27, 2022
0ec4ebc
style: update empty
tangjinzhou Feb 27, 2022
cb95d12
feat: form add labelWrap
tangjinzhou Feb 28, 2022
a01fceb
style: update grid
tangjinzhou Feb 28, 2022
ad42b92
test: update grid snap
tangjinzhou Feb 28, 2022
1eec85f
fix: image ts error
tangjinzhou Feb 28, 2022
1a2991f
fix: mentions cannot select, close #5233
tangjinzhou Feb 25, 2022
fe3eed6
doc: update pagination change info, close #5293
tangjinzhou Feb 28, 2022
263e7c3
fix: table dynamic expand error, close #5295
tangjinzhou Feb 28, 2022
346fe51
style: remove not use
tangjinzhou Feb 28, 2022
f8fc3ef
release 3.0.0-beta.11
tangjinzhou Feb 28, 2022
7c8add9
doc: update typo
tangjinzhou Feb 28, 2022
85767de
feat: input add showCount
tangjinzhou Mar 1, 2022
efea6b0
feat: inputNumber add prefix slot
tangjinzhou Mar 1, 2022
4320dd6
style: update layout
tangjinzhou Mar 1, 2022
f882d3e
style: update list
tangjinzhou Mar 1, 2022
ab74f26
feat: add locale i18
tangjinzhou Mar 1, 2022
bfbcdaf
style: update locale ts
tangjinzhou Mar 1, 2022
c341258
style: update mentions
tangjinzhou Mar 1, 2022
32fc4fc
feat: menu divider add dashed
tangjinzhou Mar 2, 2022
4904fa7
perf: menu
tangjinzhou Mar 2, 2022
0202c44
Merge branch 'next' into feat-css-var
tangjinzhou Mar 2, 2022
07a7f47
perf: menu animate
tangjinzhou Mar 3, 2022
41d8d0e
Merge remote-tracking branch 'origin/next' into feat-css-var
tangjinzhou Mar 5, 2022
d38ecce
feat: modal method add wrapClassName
tangjinzhou Mar 5, 2022
e610e8a
style: update pageheader
tangjinzhou Mar 5, 2022
a36d858
feat: update pagination ts
tangjinzhou Mar 5, 2022
a041b5b
feat: confirm add showCancel & promise
tangjinzhou Mar 5, 2022
dc21ce5
doc: update popover
tangjinzhou Mar 5, 2022
c9188ec
style: update progress
tangjinzhou Mar 5, 2022
788ee2f
style: radio
tangjinzhou Mar 5, 2022
72e5afa
style: update rate、result、row
tangjinzhou Mar 5, 2022
741ec4c
feat: select add fieldNames
tangjinzhou Mar 6, 2022
2bd5fc1
feat: add skeleton button & input
tangjinzhou Mar 6, 2022
93a06a4
feat: spin tip support slot
tangjinzhou Mar 6, 2022
524135c
style: slider & space
tangjinzhou Mar 6, 2022
2e3dcab
stype: update steps ts type
tangjinzhou Mar 6, 2022
cc387b9
style: update switch
tangjinzhou Mar 6, 2022
79ff7ac
feat: table add tree filter
tangjinzhou Mar 7, 2022
7a1c6b6
test: update input sanp
tangjinzhou Mar 7, 2022
ee778a2
feat: table add filterMode...
tangjinzhou Mar 8, 2022
ba9c766
fix: tree autoExpandParent bug
tangjinzhou Mar 8, 2022
a635000
test: update input snap
tangjinzhou Mar 8, 2022
9014749
doc: tabs add destroyInactiveTabPane
tangjinzhou Mar 8, 2022
c35578a
style: update tag
tangjinzhou Mar 8, 2022
7d3a70d
style: update timeline & time-picker
tangjinzhou Mar 8, 2022
f1384d1
fix: Tooltip arrowPointAtCenter 1px shift bug
tangjinzhou Mar 8, 2022
e777bc1
feat: typography add enterEnterIcon triggerType
tangjinzhou Mar 8, 2022
82b0b67
doc: update tree-select
tangjinzhou Mar 8, 2022
5bd34df
fix: deps and TypeScript types
tangjinzhou Mar 8, 2022
efffdcb
style: udpate transfer
tangjinzhou Mar 10, 2022
d783c4e
style: update style
tangjinzhou Mar 10, 2022
414338b
doc: add colorScheme
tangjinzhou Mar 10, 2022
d3a1be0
chore: add css var builg
tangjinzhou Mar 10, 2022
eef66b1
doc: sort api
tangjinzhou Mar 10, 2022
91eb74b
style: lint code
tangjinzhou Mar 10, 2022
a2977c2
doc: add css var
tangjinzhou Mar 10, 2022
982f64e
test: update snap
tangjinzhou Mar 10, 2022
ff3eefa
chore: add pre script
tangjinzhou Mar 11, 2022
61a4db3
chore: update lint
tangjinzhou Mar 11, 2022
5bea601
perf: collapse animate
tangjinzhou Mar 11, 2022
a61ec0a
perf: collapse tree
tangjinzhou Mar 11, 2022
275996e
perf: typography shaking when edit
tangjinzhou Mar 11, 2022
3a2a672
doc: update auto-complete demo
tangjinzhou Mar 11, 2022
b82dd34
fix: table tree not have animate
tangjinzhou Mar 11, 2022
e565423
feat: deprecated dropdown center placement
tangjinzhou Mar 11, 2022
af06b76
feat: deprecated dropdown center placement
tangjinzhou Mar 11, 2022
60f99aa
test: update snap
tangjinzhou Mar 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
195 changes: 195 additions & 0 deletions .antd-tools.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
const fs = require('fs');
const path = require('path');
const defaultVars = require('./scripts/default-vars');
const darkVars = require('./scripts/dark-vars');
const compactVars = require('./scripts/compact-vars');

function generateThemeFileContent(theme) {
return `const { ${theme}ThemeSingle } = require('./theme');\nconst defaultTheme = require('./default-theme');\n
module.exports = {
...defaultTheme,
...${theme}ThemeSingle
}`;
}

// We need compile additional content for antd user
function finalizeCompile() {
if (fs.existsSync(path.join(__dirname, './lib'))) {
// Build a entry less file to dist/antd.less
const componentsPath = path.join(process.cwd(), 'components');
let componentsLessContent = '';
// Build components in one file: lib/style/components.less
fs.readdir(componentsPath, (err, files) => {
files.forEach(file => {
if (fs.existsSync(path.join(componentsPath, file, 'style', 'index.less'))) {
componentsLessContent += `@import "../${path.posix.join(
file,
'style',
'index-pure.less',
)}";\n`;
}
});
fs.writeFileSync(
path.join(process.cwd(), 'lib', 'style', 'components.less'),
componentsLessContent,
);
});
}
}

function buildThemeFile(theme, vars) {
// Build less entry file: dist/antd.${theme}.less
if (theme !== 'default') {
fs.writeFileSync(
path.join(process.cwd(), 'dist', `antd.${theme}.less`),
`@import "../lib/style/${theme}.less";\n@import "../lib/style/components.less";`,
);
// eslint-disable-next-line no-console
console.log(`Built a entry less file to dist/antd.${theme}.less`);
} else {
fs.writeFileSync(
path.join(process.cwd(), 'dist', `default-theme.js`),
`module.exports = ${JSON.stringify(vars, null, 2)};\n`,
);
return;
}

// Build ${theme}.js: dist/${theme}-theme.js, for less-loader

fs.writeFileSync(
path.join(process.cwd(), 'dist', `theme.js`),
`const ${theme}ThemeSingle = ${JSON.stringify(vars, null, 2)};\n`,
{
flag: 'a',
},
);

fs.writeFileSync(
path.join(process.cwd(), 'dist', `${theme}-theme.js`),
generateThemeFileContent(theme),
);

// eslint-disable-next-line no-console
console.log(`Built a ${theme} theme js file to dist/${theme}-theme.js`);
}

function finalizeDist() {
if (fs.existsSync(path.join(__dirname, './dist'))) {
// Build less entry file: dist/antd.less
fs.writeFileSync(
path.join(process.cwd(), 'dist', 'antd.less'),
'@import "../lib/style/default.less";\n@import "../lib/style/components.less";',
);
// eslint-disable-next-line no-console
fs.writeFileSync(
path.join(process.cwd(), 'dist', 'theme.js'),
`const defaultTheme = require('./default-theme.js');\n`,
);
// eslint-disable-next-line no-console
console.log('Built a entry less file to dist/antd.less');
buildThemeFile('default', defaultVars);
buildThemeFile('dark', darkVars);
buildThemeFile('compact', compactVars);
buildThemeFile('variable', {});
fs.writeFileSync(
path.join(process.cwd(), 'dist', `theme.js`),
`
function getThemeVariables(options = {}) {
let themeVar = {
'hack': \`true;@import "\${require.resolve('antd/lib/style/color/colorPalette.less')}";\`,
...defaultTheme
};
if(options.dark) {
themeVar = {
...themeVar,
...darkThemeSingle
}
}
if(options.compact){
themeVar = {
...themeVar,
...compactThemeSingle
}
}
return themeVar;
}

module.exports = {
darkThemeSingle,
compactThemeSingle,
getThemeVariables
}`,
{
flag: 'a',
},
);
}
}

function isComponentStyleEntry(file) {
return file.path.match(/style(\/|\\)index\.tsx/);
}

function needTransformStyle(content) {
return content.includes('../../style/index.less') || content.includes('./index.less');
}

module.exports = {
compile: {
includeLessFile: [/(\/|\\)components(\/|\\)style(\/|\\)default.less$/],
transformTSFile(file) {
if (isComponentStyleEntry(file)) {
let content = file.contents.toString();

if (needTransformStyle(content)) {
const cloneFile = file.clone();

// Origin
content = content.replace('../../style/index.less', '../../style/default.less');
cloneFile.contents = Buffer.from(content);

return cloneFile;
}
}
},
transformFile(file) {
if (isComponentStyleEntry(file)) {
const indexLessFilePath = file.path.replace('index.tsx', 'index.less');

if (fs.existsSync(indexLessFilePath)) {
// We put origin `index.less` file to `index-pure.less`
const pureFile = file.clone();
pureFile.contents = Buffer.from(fs.readFileSync(indexLessFilePath, 'utf8'));
pureFile.path = pureFile.path.replace('index.tsx', 'index-pure.less');

// Rewrite `index.less` file with `root-entry-name`
const indexLessFile = file.clone();
indexLessFile.contents = Buffer.from(
[
// Inject variable
'@root-entry-name: default;',
// Point to origin file
"@import './index-pure.less';",
].join('\n\n'),
);
indexLessFile.path = indexLessFile.path.replace('index.tsx', 'index.less');

return [indexLessFile, pureFile];
}
}

return [];
},
lessConfig: {
modifyVars: {
'root-entry-name': 'default',
},
},
finalize: finalizeCompile,
},
dist: {
finalize: finalizeDist,
},
generateThemeFileContent,
bail: true,
};
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ es/
lib/
_site/
dist/
components/version/version.tsx
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ vetur/
report.html

site/src/router/demoRoutes.js

components/version/version.tsx
~component-api.json
68 changes: 68 additions & 0 deletions antd-tools/apiCollection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Read all the api from current documents

const glob = require('glob');
const fs = require('fs');

const COMPONENT_NAME = /components\/([^/]*)/;
const PROP_NAME = /^\s*\|\s*([^\s|]*)/;

const components = {};

function mappingPropLine(component, line) {
const propMatch = line.match(PROP_NAME);
if (!propMatch) return;

const propName = propMatch[1];
if (!/^[a-z]/.test(propName)) return;

components[component] = Array.from(new Set([...(components[component] || []), propName]));
}

function apiReport(entities) {
const apis = {};
Object.keys(entities).forEach(component => {
const apiList = entities[component];
apiList.forEach(api => {
if (typeof apis[api] === 'function') {
apis[api] = [];
}
apis[api] = [...(apis[api] || []), component];
});
});

return apis;
}

function printReport(apis) {
const apiList = Object.keys(apis).map(api => ({
name: api,
componentList: apis[api],
}));
apiList.sort((a, b) => b.componentList.length - a.componentList.length);
// eslint-disable-next-line no-console
console.log('| name | components | comments |');
// eslint-disable-next-line no-console
console.log('| ---- | ---------- | -------- |');
apiList.forEach(({ name, componentList }) => {
// eslint-disable-next-line no-console
console.log('|', name, '|', componentList.join(', '), '| |');
});
}

module.exports = () => {
glob('components/*/*.md', (error, files) => {
files.forEach(filePath => {
// Read md file to parse content
const content = fs.readFileSync(filePath, 'utf8');
const component = filePath.match(COMPONENT_NAME)[1];

// Parse lines to get API
const lines = content.split(/[\r\n]+/);
lines.forEach(line => {
mappingPropLine(component, line);
});
});

printReport(apiReport(components));
});
};
1 change: 0 additions & 1 deletion antd-tools/cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
'use strict';

require('colorful').colorful();
require('colorful').isatty = true;
const gulp = require('gulp');
const program = require('commander');

Expand Down
17 changes: 17 additions & 0 deletions antd-tools/getNpm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const runCmd = require('./runCmd');

module.exports = function (done) {
if (process.env.NPM_CLI) {
done(process.env.NPM_CLI);
return;
}
runCmd('which', ['tnpm'], code => {
let npm = 'npm';
if (!code) {
npm = 'tnpm';
}
done(npm);
});
};
Loading