UNPKG

choo-taro-ui-vue3

Version:

Taro UI Rewritten in Vue 3.0

138 lines (130 loc) 5.71 kB
import { defineComponent, toRefs, createCommentVNode, resolveComponent, createVNode, withCtx, openBlock, createBlock, renderSlot, Fragment, createElementBlock, normalizeClass, normalizeStyle, toDisplayString, createTextVNode, mergeProps } from 'vue'; import { useIconClasses, useIconStyle } from '../composables'; const AtCard = defineComponent({ name: "AtCard", emits: ["click"], props: { isFull: Boolean, note: String, thumb: String, title: String, extra: String, extraStyle: Object, icon: Object }, setup(props, { emit }) { const { iconClasses } = useIconClasses(props.icon); const { iconStyle } = useIconStyle(props.icon); function handleClick(args) { emit("click", args); } return { ...toRefs(props), iconClasses, iconStyle, handleClick }; } }); // Binding optimization for webpack code-split const _createCommentVNode = createCommentVNode, _resolveComponent = resolveComponent, _createVNode = createVNode, _withCtx = withCtx, _openBlock = openBlock, _createBlock = createBlock, _renderSlot = renderSlot, _Fragment = Fragment, _createElementBlock = createElementBlock, _normalizeClass = normalizeClass, _normalizeStyle = normalizeStyle, _toDisplayString = toDisplayString, _createTextVNode = createTextVNode, _mergeProps = mergeProps; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_taro_image = process.env.TARO_ENV === "h5" ? _resolveComponent("taro-image") : "image"; const _component_taro_view = process.env.TARO_ENV === "h5" ? _resolveComponent("taro-view") : "view"; const _component_taro_text = process.env.TARO_ENV === "h5" ? _resolveComponent("taro-text") : "text"; return (_openBlock(), _createBlock(_component_taro_view, _mergeProps(_ctx.$attrs, { class: ['at-card', { 'at-card--full': _ctx.isFull }], onTap: _ctx.handleClick }), { default: _withCtx(() => [ _createCommentVNode(" header "), _createVNode(_component_taro_view, { class: "at-card__header" }, { default: _withCtx(() => [ _createCommentVNode(" thumb image "), (_ctx.thumb) ? (_openBlock(), _createBlock(_component_taro_view, { key: 0, class: "at-card__header-thumb" }, { default: _withCtx(() => [ _createVNode(_component_taro_image, { class: "at-card__header-thumb-info", mode: "scaleToFill", src: _ctx.thumb }, null, 8 /* PROPS */, ["src"]) ]), _: 1 /* STABLE */ })) : (_ctx.$slots.renderIcon) ? (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [ _createCommentVNode(" renderIcon "), _renderSlot(_ctx.$slots, "renderIcon") ], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)) : (_ctx.icon && _ctx.icon.value) ? (_openBlock(), _createElementBlock(_Fragment, { key: 2 }, [ _createCommentVNode(" use icon if not thumb "), _createVNode(_component_taro_text, { class: _normalizeClass(['at-card__header-icon', _ctx.iconClasses ]), style: _normalizeStyle(_ctx.iconStyle) }, null, 8 /* PROPS */, ["class", "style"]) ], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)) : _createCommentVNode("v-if", true), _createCommentVNode(" title "), (_ctx.title) ? (_openBlock(), _createBlock(_component_taro_text, { key: 3, class: "at-card__header-title" }, { default: _withCtx(() => [ _createTextVNode(_toDisplayString(_ctx.title), 1 /* TEXT */) ]), _: 1 /* STABLE */ })) : _createCommentVNode("v-if", true), _createCommentVNode(" extra info "), (_ctx.extra) ? (_openBlock(), _createBlock(_component_taro_text, { key: 4, class: "at-card__header-extra", style: _normalizeStyle({ ...(_ctx.extraStyle || {}) }) }, { default: _withCtx(() => [ _createTextVNode(_toDisplayString(_ctx.extra), 1 /* TEXT */) ]), _: 1 /* STABLE */ }, 8 /* PROPS */, ["style"])) : _createCommentVNode("v-if", true) ]), _: 3 /* FORWARDED */ }), _createCommentVNode(" content "), _createVNode(_component_taro_view, { class: "at-card__content" }, { default: _withCtx(() => [ _createCommentVNode(" main content "), _createVNode(_component_taro_view, { class: "at-card__content-info" }, { default: _withCtx(() => [ _renderSlot(_ctx.$slots, "default") ]), _: 3 /* FORWARDED */ }), _createCommentVNode(" content note "), (_ctx.note) ? (_openBlock(), _createBlock(_component_taro_view, { key: 0, class: "at-card__content-note" }, { default: _withCtx(() => [ _createTextVNode(_toDisplayString(_ctx.note), 1 /* TEXT */) ]), _: 1 /* STABLE */ })) : _createCommentVNode("v-if", true) ]), _: 3 /* FORWARDED */ }) ]), _: 3 /* FORWARDED */ }, 16 /* FULL_PROPS */, ["class", "onTap"])) } AtCard.render = _sfc_render; export default AtCard;