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

feat: real dark #4356

Merged
merged 25 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
displayName: install
- script: npm run test:all
env:
PROGRESS: none
PROGRESS: none
UMI_UI: none
displayName: test

- job: Windows
Expand All @@ -55,6 +56,7 @@ jobs:
- script: npm run test:all
env:
PROGRESS: none
UMI_UI: none
displayName: test
- script: npm run build
env:
Expand All @@ -75,4 +77,5 @@ jobs:
- script: npm run
env:
PROGRESS: none
UMI_UI: none
displayName: build
73 changes: 57 additions & 16 deletions config/config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { IConfig, IPlugin } from 'umi-types';
import defaultSettings from './defaultSettings'; // https://umijs.org/config/

import slash from 'slash2';
import webpackPlugin from './plugin.config';
import themePluginConfig from './themePluginConfig';

// import darkTheme from '@ant-design/dark-theme';

const { pwa, primaryColor } = defaultSettings;

// preview.pro.ant.design only do not use in your production ;
// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env;
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, TEST } = process.env;
const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site';

const plugins: IPlugin[] = [
[
'umi-plugin-react',
Expand Down Expand Up @@ -37,8 +40,7 @@ const plugins: IPlugin[] = [
importWorkboxFrom: 'local',
},
}
: false,
// default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
: false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
// dll features https://webpack.js.org/plugins/dll-plugin/
// dll: {
// include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
Expand All @@ -55,15 +57,55 @@ const plugins: IPlugin[] = [
autoAddMenu: true,
},
],
]; // 针对 preview.pro.ant.design 的 GA 统计代码
];

if (isAntDesignProPreview) {
// 针对 preview.pro.ant.design 的 GA 统计代码
plugins.push([
'umi-plugin-ga',
{
code: 'UA-72788897-6',
},
]);
plugins.push(['umi-plugin-antd-theme', themePluginConfig]);
}

if (!TEST) {
plugins.push([
'umi-plugin-antd-theme',
{
theme: [
{
key: 'dark',
fileName: 'dark.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme: 'dark',
},
{
key: 'dust',
fileName: 'dust.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#F5222D',
},
},
{
key: 'dust',
theme: 'dark',
fileName: 'dark-dust.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#F5222D',
},
},
{
key: 'volcano',
theme: 'dark',
fileName: 'dark-volcano.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#FA541C',
},
},
],
},
]);
}

export default {
Expand Down Expand Up @@ -134,6 +176,7 @@ export default {
],
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme: {
// ...darkTheme,
'primary-color': primaryColor,
},
define: {
Expand Down Expand Up @@ -179,14 +222,12 @@ export default {
manifest: {
basePath: '/',
},
chainWebpack: webpackPlugin,
/*
proxy: {
'/server/api/': {
target: 'https://preview.pro.ant.design/',
changeOrigin: true,
pathRewrite: { '^/server': '' },
},
},
*/
// chainWebpack: webpackPlugin,
// proxy: {
// '/server/api/': {
// target: 'https://preview.pro.ant.design/',
// changeOrigin: true,
// pathRewrite: { '^/server': '' },
// },
// },
} as IConfig;
44 changes: 0 additions & 44 deletions config/plugin.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Change theme plugin
// eslint-disable-next-line eslint-comments/abdeils - enable - pair;
/* eslint-disable import/no-extraneous-dependencies */
import ThemeColorReplacer from 'webpack-theme-color-replacer';
import generate from '@ant-design/colors/lib/generate';
import path from 'path';

function getModulePackageName(module: { context: string }) {
Expand All @@ -25,33 +20,6 @@ function getModulePackageName(module: { context: string }) {
}

export default (config: any) => {
// preview.pro.ant.design only do not use in your production;
if (
process.env.ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ||
process.env.NODE_ENV !== 'production'
) {
config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [
{
fileName: 'css/theme-colors-[contenthash:8].css',
matchColors: getAntdSerials('#1890ff'), // 主色系列
// 改变样式选择器,解决样式覆盖问题
changeSelector(selector: string): string {
switch (selector) {
case '.ant-calendar-today .ant-calendar-date':
return ':not(.ant-calendar-selected-date)' + selector;
case '.ant-btn:focus,.ant-btn:hover':
return '.ant-btn:focus:not(.ant-btn-primary),.ant-btn:hover:not(.ant-btn-primary)';
case '.ant-btn.active,.ant-btn:active':
return '.ant-btn.active:not(.ant-btn-primary),.ant-btn:active:not(.ant-btn-primary)';
default:
return selector;
}
},
// isJsUgly: true,
},
]);
}

// optimize chunks
config.optimization
// share the same chunks across different modules
Expand Down Expand Up @@ -90,15 +58,3 @@ export default (config: any) => {
},
});
};

const getAntdSerials = (color: string) => {
const lightNum = 9;
const devide10 = 10;
// 淡化(即less的tint)
const lightens = new Array(lightNum).fill(undefined).map((_, i: number) => {
return ThemeColorReplacer.varyColor.lighten(color, i / devide10);
});
const colorPalettes = generate(color);
const rgb = ThemeColorReplacer.varyColor.toNum3(color.replace('#', '')).join(',');
return lightens.concat(colorPalettes).concat(rgb);
};
115 changes: 115 additions & 0 deletions config/themePluginConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
export default {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme: [
{
key: 'dark',
fileName: 'dark.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme: 'dark',
},
{
key: 'dust',
fileName: 'dust.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#F5222D',
},
},
{
key: 'volcano',
fileName: 'volcano.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#FA541C',
},
},
{
key: 'sunset',
fileName: 'sunset.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#FAAD14',
},
},
{
key: 'cyan',
fileName: 'cyan.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#13C2C2',
},
},
{
key: 'green',
fileName: 'green.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#52C41A',
},
},
{
key: 'geekblue',
fileName: 'geekblue.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#2F54EB',
},
},
{
key: 'purple',
fileName: 'purple.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#722ED1',
},
},

{
key: 'dust',
theme: 'dark',
fileName: 'dark-dust.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#F5222D',
},
},
{
key: 'volcano',
theme: 'dark',
fileName: 'dark-volcano.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#FA541C',
},
},
{
key: 'sunset',
theme: 'dark',
fileName: 'dark-sunset.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#FAAD14',
},
},
{
key: 'cyan',
theme: 'dark',
fileName: 'dark-cyan.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#13C2C2',
},
},
{
key: 'green',
theme: 'dark',
fileName: 'dark-green.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#52C41A',
},
},
{
key: 'geekblue',
theme: 'dark',
fileName: 'dark-geekblue.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#2F54EB',
},
},
{
key: 'purple',
theme: 'dark',
fileName: 'dark-purple.css',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifyVars: {
'@primary-color': '#722ED1',
},
},
],
};
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"not ie <= 10"
],
"dependencies": {
"@ant-design/colors": "^3.1.0",
"@ant-design/pro-layout": "^4.5.16",
"@ant-design/dark-theme": "1.0.3",
"@ant-design/pro-layout": "4.8.0",
"@antv/data-set": "^0.10.2",
"antd": "^3.23.6",
"classnames": "^2.2.6",
Expand All @@ -73,12 +73,11 @@
"react-dom": "^16.8.6",
"react-helmet": "^5.2.1",
"redux": "^4.0.1",
"slash2": "^2.0.0",
"umi": "^2.9.6",
"umi-plugin-pro-block": "^1.3.4",
"umi-plugin-react": "^1.10.1",
"umi-request": "^1.2.7",
"webpack-theme-color-replacer": "^1.2.15"
"umi": "^2.8.7",
"umi-plugin-antd-theme": "^1.0.1",
"umi-plugin-pro-block": "^1.3.2",
"umi-plugin-react": "^1.9.5",
"umi-request": "^1.0.8"
},
"devDependencies": {
"@ant-design/pro-cli": "^1.0.13",
Expand Down
7 changes: 4 additions & 3 deletions src/components/CopyBlock/index.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '~antd/es/style/themes/default.less';

.copy-block {
position: fixed;
right: 80px;
Expand All @@ -10,10 +12,9 @@
width: 40px;
height: 40px;
font-size: 20px;
background: #fff;
background: @input-bg;
border-radius: 40px;
box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.2), 0 4px 5px 0 rgba(0, 0, 0, 0.14),
0 1px 10px 0 rgba(0, 0, 0, 0.12);
box-shadow: @card-shadow;
cursor: pointer;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderDropdown/index.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import '~antd/es/style/themes/default.less';

.container > * {
background-color: #fff;
background-color: @popover-bg;
border-radius: 4px;
box-shadow: @shadow-1-down;
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/NoticeIcon/NoticeList.less
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
cursor: pointer;
transition: all 0.3s;
user-select: none;
&:hover {
color: @heading-color;
}

&:only-child {
width: 100%;
}
Expand Down
Loading