UNPKG

@sumdoo/sumdoo-ui

Version:

轻量级的移动端 Vue3 组件库 (支持小程序开发)

54 lines (53 loc) 1.72 kB
/*! * @sumdoo/sumdoo-ui v1.0.0 Wed Feb 09 2022 13:07:24 GMT+0800 (中国标准时间) * (c) 2022 @sumdoo * Released under the MIT License. */ import { defineComponent, inject, computed, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot } from "vue"; import { a as addUnit } from "./helper.js"; import { _ as _export_sfc } from "./plugin-vue_export-helper.js"; const _sfc_main = defineComponent({ name: "SdCol", props: { span: { type: Number, default: 24 }, offset: { type: Number, default: 0 } }, setup(props) { const parentInject = inject("parent"); const class$ = computed(() => { return { [`sd-col-${props.span}`]: true, [`sd-col-offset-${props.offset}`]: true, "sd-col-gutter": !!(parentInject == null ? void 0 : parentInject.gutter.value) }; }); const style$ = computed(() => { const gutter = (parentInject == null ? void 0 : parentInject.gutter.value) || 0; const style = { paddingLeft: addUnit(gutter / 2), paddingRight: addUnit(gutter / 2) }; if (props.span) { style.width = 100 / 24 * props.span + "%"; } if (props.offset) { style["margin-left"] = 100 / 24 * props.offset + "%"; } return style; }); return { class$, style$ }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", { class: normalizeClass(["sd-col", _ctx.class$]), style: normalizeStyle(_ctx.style$) }, [ renderSlot(_ctx.$slots, "default") ], 6); } var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { index as default };