refactor(components): refactor icon (#5934)

This commit is contained in:
三咲智子 2022-02-13 23:26:44 +08:00 committed by GitHub
parent 8f15dc1d56
commit 9ac025b5d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,36 +4,26 @@
</i>
</template>
<script lang="ts">
import { defineComponent, computed } from 'vue'
<script lang="ts" setup>
import { computed } from 'vue'
import { isUndefined, addUnit } from '@element-plus/utils'
import { useNamespace } from '@element-plus/hooks'
import { iconProps } from './icon'
import type { CSSProperties } from 'vue'
export default defineComponent({
defineOptions({
name: 'ElIcon',
inheritAttrs: false,
})
const props = defineProps(iconProps)
const ns = useNamespace('icon')
props: iconProps,
const style = computed<CSSProperties>(() => {
if (!props.size && !props.color) return {}
setup(props) {
const ns = useNamespace('icon')
const style = computed<CSSProperties>(() => {
if (!props.size && !props.color) return {}
return {
fontSize: isUndefined(props.size) ? undefined : addUnit(props.size),
'--color': props.color,
}
})
return {
ns,
style,
}
},
return {
fontSize: isUndefined(props.size) ? undefined : addUnit(props.size),
'--color': props.color,
}
})
</script>