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(plugins): auto pass antd theme to ConfigProvider.config #11176

Merged
merged 2 commits into from
May 22, 2023
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
6 changes: 6 additions & 0 deletions examples/plugin-antd-e2e/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ export default {
plugins: [join(__dirname, '../../packages/plugins/src/antd')],
antd: {
momentPicker: true,
theme: {
token: {
colorPrimary: 'green',
borderRadius: 2,
},
},
},
mfsu: false,
};
20 changes: 15 additions & 5 deletions examples/plugin-antd-e2e/cypress/e2e/smoke.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@ describe('Basic Test', () => {
}),
);

it('display mfsu is working', () => {
cy.intercept('GET', '/mf-va_remoteEntry.js').as('EntryLoaded');

it('momentjs replacement is working', () => {
cy.visit('/');

cy.wait('@EntryLoaded');

cy.get<HTMLInputElement>('.ant-picker-input input').should(
'have.value',
'2022-01-01',
);
});

it('static theme passed is working', () => {
cy.visit('/');

cy.contains('Confirm Me').click();

cy.wait(500);

cy.get('.ant-modal-confirm-btns .ant-btn-primary').should(
'have.css',
'border-radius',
'2px',
);
});
});
2 changes: 1 addition & 1 deletion examples/plugin-antd-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"start": "npm run dev"
},
"dependencies": {
"antd": "5.x",
"antd": "^5.6.0-alpha.0",
"lodash.uppercase": "^4.3.0",
"moment": "^2.29.4",
"umi": "workspace:*"
Expand Down
13 changes: 12 additions & 1 deletion examples/plugin-antd-e2e/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DatePicker, version } from 'antd';
import { Button, DatePicker, Modal, version } from 'antd';
import moment from 'moment';

const fileName = 'favicon';
Expand All @@ -18,6 +18,17 @@ export default function HomePage() {
console.log(val);
}}
/>
<Button
type="primary"
onClick={() => {
Modal.confirm({
title: 'Confirm',
content: 'Bla bla ...',
});
}}
>
Confirm Me
</Button>
</div>
);
}
8 changes: 8 additions & 0 deletions packages/plugins/templates/antd/runtime.ts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ export function rootContainer(rawContainer) {
iconPrefixCls: finalConfigProvider.iconPrefixCls,
});
};

if (finalConfigProvider.theme) {
// Pass config theme to static method
ConfigProvider.config({
theme: finalConfigProvider.theme,
});
}

container = <ConfigProvider {...finalConfigProvider}>{container}</ConfigProvider>;
{{/configProvider}}

Expand Down
Loading
Loading