refactor(components): [space] use useNamespace (#5749)

This commit is contained in:
bqy 2022-02-09 12:13:38 +08:00 committed by GitHub
parent 8f91f98796
commit 99d3f0902b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -7,11 +7,12 @@
<script lang="ts">
import { defineComponent, computed } from 'vue'
import { buildProps } from '@element-plus/utils/props'
import { useNamespace } from '@element-plus/hooks'
const spaceItem = buildProps({
prefixCls: {
type: String,
default: 'el-space',
default: '',
},
} as const)
@ -19,7 +20,9 @@ export default defineComponent({
props: spaceItem,
setup(props) {
const classes = computed(() => [`${props.prefixCls}__item`])
const ns = useNamespace('space')
const classes = computed(() => `${props.prefixCls || ns.b()}__item`)
return {
classes,

View File

@ -1,5 +1,6 @@
import { ref, computed, watchEffect } from 'vue'
import { isNumber } from '@element-plus/utils/util'
import { useNamespace } from '@element-plus/hooks'
import type { SpaceProps } from './space'
import type { CSSProperties, StyleValue } from 'vue'
@ -12,11 +13,9 @@ const SIZE_MAP: Record<ComponentSize, number> = {
}
export function useSpace(props: SpaceProps) {
const classes = computed(() => [
'el-space',
`el-space--${props.direction}`,
props.class,
])
const ns = useNamespace('space')
const classes = computed(() => [ns.b(), ns.m(props.direction), props.class])
const horizontalSize = ref(0)
const verticalSize = ref(0)