types: use-placeholder

This commit is contained in:
chenjiahan 2020-09-21 18:48:11 +08:00
parent 4c468ffd74
commit 63f15094f3
2 changed files with 16 additions and 14 deletions

View File

@ -1,14 +0,0 @@
import { useHeight } from './use-rect';
export function usePlaceholder(contentRef, bem) {
const height = useHeight(contentRef);
return (renderContent) => (
<div
class={bem('placeholder')}
style={{ height: height.value ? `${height.value}px` : null }}
>
{renderContent()}
</div>
);
}

View File

@ -0,0 +1,16 @@
import { useHeight } from './use-rect';
import type { Ref, VNode } from 'vue';
import type { BEM } from '../utils/create/bem';
export function usePlaceholder(contentRef: Ref<Element>, bem: BEM) {
const height = useHeight(contentRef);
return (renderContent: () => VNode) => (
<div
class={bem('placeholder')}
style={{ height: height.value ? `${height.value}px` : undefined }}
>
{renderContent()}
</div>
);
}