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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(components): [container] #10469

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions packages/components/container/src/container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { computed, useSlots } from 'vue'
import { useNamespace } from '@element-plus/hooks'

import type { Component, VNode } from 'vue'
import type { Component } from 'vue'

defineOptions({
name: 'ElContainer',
Expand All @@ -22,19 +22,11 @@ const slots = useSlots()
const ns = useNamespace('container')

const isVertical = computed(() => {
if (props.direction === 'vertical') {
return true
} else if (props.direction === 'horizontal') {
return false
}
if (slots && slots.default) {
const vNodes: VNode[] = slots.default()
return vNodes.some((vNode) => {
const tag = (vNode.type as Component).name
return tag === 'ElHeader' || tag === 'ElFooter'
})
} else {
return false
}
if (props.direction === 'vertical') return true
if (props.direction === 'horizontal' || !slots || !slots.default) return false
return slots.default().some((vNode) => {
const tag = (vNode.type as Component).name
return tag === 'ElHeader' || tag === 'ElFooter'
})
})
</script>
6 changes: 3 additions & 3 deletions packages/components/container/src/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ const props = defineProps({
})

const ns = useNamespace('header')
const style = computed(() => {
return props.height
const style = computed(() =>
props.height
? (ns.cssVarBlock({
height: props.height,
}) as CSSProperties)
: {}
})
)
</script>