Skip to content

Commit 84873c8

Browse files
committed
feat(antdsite): add themeConfig.themeColors and you can set theme colors of ant design.
1 parent 93f1649 commit 84873c8

4 files changed

Lines changed: 44 additions & 10 deletions

File tree

packages/antdsite/__default__/default-config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
lang: 'en-US',
88
head: [],
99
themeConfig: {
10+
themeColors: null,
1011
repo: null,
1112
docsRepo: null,
1213
docsDir: 'docs',
@@ -20,6 +21,6 @@ module.exports = {
2021
showBackToTop: true,
2122
maxTocDeep: 3,
2223
search: true,
23-
searchMaxSuggestions: 10,
24-
},
24+
searchMaxSuggestions: 10
25+
}
2526
};
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
const { resolveLayouts } = require('../util');
1+
const { resolveLayouts, setThemeColors } = require('../util');
22

33
module.exports = ({ stage, actions, loaders }) => {
44
resolveLayouts(actions);
5+
setThemeColors(actions);
6+
57
if (stage === 'develop') {
68
actions.setWebpackConfig({
79
module: {
810
rules: [
911
{
1012
test: /react-hot-loader/,
11-
use: [loaders.js()],
12-
},
13-
],
14-
},
13+
use: [loaders.js()]
14+
}
15+
]
16+
}
1517
});
1618
}
1719
};

packages/antdsite/lib/util.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,35 @@ module.exports.resolveLayouts = function(actions) {
117117
actions.setWebpackConfig({
118118
resolve: {
119119
alias: {
120-
[`antdsite-${layout}`]: layoutPath,
121-
},
122-
},
120+
[`antdsite-${layout}`]: layoutPath
121+
}
122+
}
123123
});
124124
});
125125
};
126+
127+
module.exports.setThemeColors = function(actions) {
128+
const config = module.exports.getFinalConfig();
129+
const { themeColors } = config.themeConfig;
130+
131+
if (themeColors) {
132+
actions.setWebpackConfig({
133+
module: {
134+
rules: [
135+
{
136+
test: /\.less$/,
137+
use: [
138+
{
139+
loader: 'less-loader', // compiles Less to CSS
140+
options: {
141+
modifyVars: themeColors,
142+
javascriptEnabled: true
143+
}
144+
}
145+
]
146+
}
147+
]
148+
}
149+
});
150+
}
151+
};

packages/antdsite/src/default-theme/assets/common.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,8 @@ a {
145145
.drawer {
146146
z-index: 1029;
147147
}
148+
149+
// fix back-top icon background-size 1% bug when modifying the theme.
150+
.ant-back-top-icon {
151+
background-size: 100% 100% !important;
152+
}

0 commit comments

Comments
 (0)