vant/src/composables/use-placeholder.tsx
neverland 0b68d3a141
types: improve ref typing (#8124)
* types: improve ref typing

* types: message
2021-02-10 20:57:24 +08:00

17 lines
457 B
TypeScript

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