mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-24 11:05:17 +08:00
refactor(components): refactor icon (#3528)
This commit is contained in:
parent
d71c87344a
commit
6a57d547d0
@ -1,5 +1,5 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Icon from '../src/index.vue'
|
||||
import Icon from '../src/icon.vue'
|
||||
|
||||
describe('Icon.vue', () => {
|
||||
test('render', () => {
|
||||
|
@ -1,13 +1,8 @@
|
||||
import Icon from './src/index.vue'
|
||||
import { withInstall } from '@element-plus/utils/with-install'
|
||||
|
||||
import type { App } from 'vue'
|
||||
import type { SFCWithInstall } from '@element-plus/utils/types'
|
||||
import Icon from './src/icon.vue'
|
||||
|
||||
Icon.install = (app: App): void => {
|
||||
app.component(Icon.name, Icon)
|
||||
}
|
||||
export const ElIcon = withInstall(Icon)
|
||||
export default ElIcon
|
||||
|
||||
const _Icon = Icon as SFCWithInstall<typeof Icon>
|
||||
|
||||
export default _Icon
|
||||
export const ElIcon = _Icon
|
||||
export * from './src/icon'
|
||||
|
11
packages/components/icon/src/icon.ts
Normal file
11
packages/components/icon/src/icon.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import type { ExtractPropTypes } from 'vue'
|
||||
|
||||
export const iconProps = {
|
||||
size: {
|
||||
type: Number,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
},
|
||||
} as const
|
||||
export type IconProps = ExtractPropTypes<typeof iconProps>
|
@ -6,21 +6,19 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, computed } from 'vue'
|
||||
import { iconProps } from './icon'
|
||||
|
||||
import type { CSSProperties } from 'vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ElIcon',
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
size: {
|
||||
type: Number,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
|
||||
props: iconProps,
|
||||
|
||||
setup(props) {
|
||||
return {
|
||||
style: computed(() => {
|
||||
style: computed<CSSProperties>(() => {
|
||||
if (!props.size && !props.color) {
|
||||
return {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user