diff --git a/packages/card/index.js b/packages/card/index.tsx similarity index 76% rename from packages/card/index.js rename to packages/card/index.tsx index 0ed7ad44f..5f631c6e1 100644 --- a/packages/card/index.js +++ b/packages/card/index.tsx @@ -2,9 +2,44 @@ import { use, isDef } from '../utils'; import { inherit } from '../utils/functional'; import Tag from '../tag'; +// Types +import { CreateElement, RenderContext } from 'vue/types'; +import { DefaultSlots, ScopedSlot } from '../utils/use/sfc'; + +export type CardProps = { + tag?: string; + num?: number | string; + desc?: string; + thumb?: string; + title?: string; + price?: number | string; + currency?: string; + centered?: boolean; + lazyLoad?: boolean; + thumbLink?: string; + originPrice?: number | string; +}; + +export type CardSlots = DefaultSlots & { + num?: ScopedSlot; + tag?: ScopedSlot; + tags?: ScopedSlot; + desc?: ScopedSlot; + title?: ScopedSlot; + thumb?: ScopedSlot; + price?: ScopedSlot; + footer?: ScopedSlot; + 'origin-price'?: ScopedSlot; +}; + const [sfc, bem] = use('card'); -function Card(h, props, slots, ctx) { +function Card( + h: CreateElement, + props: CardProps, + slots: CardSlots, + ctx: RenderContext +) { const { thumb } = props; const showThumb = slots.thumb || thumb; @@ -105,4 +140,4 @@ Card.props = { } }; -export default sfc(Card); +export default sfc(Card);