Skip to content

Commit

Permalink
feat(antdsite): add themeConfig.themeColors and you can set theme col…
Browse files Browse the repository at this point in the history
…ors of ant design.
  • Loading branch information
wangyi7099 committed Aug 5, 2019
1 parent 93f1649 commit 84873c8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
5 changes: 3 additions & 2 deletions packages/antdsite/__default__/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
lang: 'en-US',
head: [],
themeConfig: {
themeColors: null,
repo: null,
docsRepo: null,
docsDir: 'docs',
Expand All @@ -20,6 +21,6 @@ module.exports = {
showBackToTop: true,
maxTocDeep: 3,
search: true,
searchMaxSuggestions: 10,
},
searchMaxSuggestions: 10
}
};
12 changes: 7 additions & 5 deletions packages/antdsite/lib/gatsby/onCreateWebpackConfig.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const { resolveLayouts } = require('../util');
const { resolveLayouts, setThemeColors } = require('../util');

module.exports = ({ stage, actions, loaders }) => {
resolveLayouts(actions);
setThemeColors(actions);

if (stage === 'develop') {
actions.setWebpackConfig({
module: {
rules: [
{
test: /react-hot-loader/,
use: [loaders.js()],
},
],
},
use: [loaders.js()]
}
]
}
});
}
};
32 changes: 29 additions & 3 deletions packages/antdsite/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,35 @@ module.exports.resolveLayouts = function(actions) {
actions.setWebpackConfig({
resolve: {
alias: {
[`antdsite-${layout}`]: layoutPath,
},
},
[`antdsite-${layout}`]: layoutPath
}
}
});
});
};

module.exports.setThemeColors = function(actions) {
const config = module.exports.getFinalConfig();
const { themeColors } = config.themeConfig;

if (themeColors) {
actions.setWebpackConfig({
module: {
rules: [
{
test: /\.less$/,
use: [
{
loader: 'less-loader', // compiles Less to CSS
options: {
modifyVars: themeColors,
javascriptEnabled: true
}
}
]
}
]
}
});
}
};
5 changes: 5 additions & 0 deletions packages/antdsite/src/default-theme/assets/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,8 @@ a {
.drawer {
z-index: 1029;
}

// fix back-top icon background-size 1% bug when modifying the theme.
.ant-back-top-icon {
background-size: 100% 100% !important;
}

0 comments on commit 84873c8

Please sign in to comment.