mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-18 10:59:10 +08:00
refactor(components): [space] use useNamespace (#5749)
This commit is contained in:
parent
8f91f98796
commit
99d3f0902b
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user