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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(element-plus): supports icons #426

Merged
merged 1 commit into from Jun 20, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/core/resolvers/element-plus.ts
Expand Up @@ -85,6 +85,13 @@ function resolveComponent(name: string, options: ElementPlusResolverOptionsResol
if (!name.match(/^El[A-Z]/))
return

if (name.match(/^ElIcon.+/)) {
return {
name: name.replace(/^ElIcon/, ''),
from: '@element-plus/icons-vue',
}
}

const partialName = kebabCase(name.slice(2))// ElTableColumn -> table-column
const { version, ssr } = options

Expand Down
10 changes: 4 additions & 6 deletions test/resolvers/__snapshots__/element-plus.test.ts.snap
Expand Up @@ -3,19 +3,17 @@
exports[`Element Plus Resolver > components and directives should be transformed 1`] = `
{
"code": "/* unplugin-vue-components disabled */import { ElLoadingDirective as __unplugin_directives_0 } from 'element-plus/es';import 'element-plus/es/components/loading/style/css';
import { Apple as __unplugin_components_1 } from '@element-plus/icons-vue';
import { ElButton as __unplugin_components_0 } from 'element-plus/es';import 'element-plus/es/components/button/style/css';

(_ctx, _cache) => {
const _component_el_button = __unplugin_components_0
const _component_el_icon_apple = __unplugin_components_1
const _directive_loading = __unplugin_directives_0

return (_openBlock(), _createElementBlock(_Fragment, null, [
_createVNode(_component_el_button, null, {
default: _withCtx(() => [
_hoisted_1
]),
_: 1 /* STABLE */
}),
_createVNode(_component_el_button),
_createVNode(_component_el_icon_apple),
_withDirectives(_createElementVNode(\\"div\\", null, null, 512 /* NEED_PATCH */), [
[_directive_loading, true]
])
Expand Down
9 changes: 3 additions & 6 deletions test/resolvers/element-plus.test.ts
Expand Up @@ -7,15 +7,12 @@ describe('Element Plus Resolver', () => {
const code = `
(_ctx, _cache) => {
const _component_el_button = _resolveComponent("el-button")
const _component_el_icon_apple = _resolveComponent("el-icon-apple")
const _directive_loading = _resolveDirective("loading")

return (_openBlock(), _createElementBlock(_Fragment, null, [
_createVNode(_component_el_button, null, {
default: _withCtx(() => [
_hoisted_1
]),
_: 1 /* STABLE */
}),
_createVNode(_component_el_button),
_createVNode(_component_el_icon_apple),
_withDirectives(_createElementVNode("div", null, null, 512 /* NEED_PATCH */), [
[_directive_loading, true]
])
Expand Down