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

chore: add 'themeName' option for ElementUiResolver #662

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/core/resolvers/element-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,43 @@ export interface ElementUiResolverOptions {
* exclude component name, if match do not resolve the name
*/
exclude?: RegExp

/**
* theme name, like '@qzdata/element-theme-qzdata'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* theme name, like '@qzdata/element-theme-qzdata'
* theme name

*/
Copy link
Member

Choose a reason for hiding this comment

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

Add @default element-ui/packages/theme-chalk

themeName?: string
}

function getSideEffects(
partialName: string,
options: ElementUiResolverOptions,
): SideEffectsInfo | undefined {
const { importStyle = 'css' } = options
const { importStyle = 'css', themeName } = options
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const { importStyle = 'css', themeName } = options
const { importStyle = 'css', themeName = 'element-ui/packages/theme-chalk' } = options


if (!importStyle)
return

if (importStyle === 'sass') {
if (themeName) {
return [
`${themeName}/src/base.scss`,
`${themeName}/src/${partialName}.scss`,
]
}

Comment on lines +36 to +42
Copy link
Member

Choose a reason for hiding this comment

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

We can remove if (themeName) { check if there's a default value.

return [
'element-ui/packages/theme-chalk/src/base.scss',
`element-ui/packages/theme-chalk/src/${partialName}.scss`,
]
}
else {
if (themeName) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here

return [
`${themeName}/lib/base.css`,
`${themeName}/lib/${partialName}.css`,
]
}

return [
'element-ui/lib/theme-chalk/base.css',
`element-ui/lib/theme-chalk/${partialName}.css`,
Expand Down