All files index.ts

97.36% Statements 37/38
83.33% Branches 25/30
100% Functions 3/3
100% Lines 33/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92  1x 7x 7x 7x 7x   1x 1x 1x 1x                             8x 8x 8x 8x     8x             8x 8x 8x 1x   8x 1x   8x 2x   8x 1x   8x     1x           1x           1x           1x           1x           1x           1x
import { defineComponentHOC, Doraemon, Component, Prop } from '@doraemon-ui/miniprogram.core-js'
const { classNames, styleToCssString } = Doraemon.util

@ComIponent({
  props: {E
    prefixCls: {
      type: String,
      default: 'dora-demo-block',
    },
  },
})
class DemoBlock extends Doraemon {
  /**
   * 自定义类名前缀
   *
   * @type {string}
   * @memberof DemoBlock
   */
  prefixCls!: string
 
  @Prop({
    type: String,
    default: '',
  })
  title: string
 
  @Prop({
    type: Boolean,
    default: false,
  })
  bordered: boolean
 
  @Prop({
    type: String,
    default: '',
  })
  padding: string
 
  @Prop({
    type: String,
    default: '',
  })
  background: string
 
  @Prop({
    type: String,
    default: '',
  })
  direction: string
 
  @Prop({
    type: String,
    default: '',
  })
  align: string
 
  get classes () {
    const { prefixCls, bordered } = this
    const wrap = prefixCls
    const hd = `${prefixCls}__hd`
    const bd = classNames(`${prefixCls}__bd`, {
      [`${prefixCls}__bd--bordered`]: bordered,
    })
 
    return {
      wrap,
      hd,
      bd,
    }
  }
 
  get bodyStyle () {
    const { padding, background, direction, align } = this
    const bodyStyle: { [key: string]: string } = {}
    if (padding) {
      bodyStyle.padding = padding
    }
    if (background) {
      bodyStyle.background = background
    }
    if (direction) {
      bodyStyle.flexDirection = direction
    }
    if (align) {
      bodyStyle.alignItems = align
    }
    return styleToCssString(bodyStyle)
  }
}
 
export default defineComponentHOC()(DemoBlock)