All files / src/components/u-desc-list.vue item.vue

68.42% Statements 13/19
33.33% Branches 2/6
33.33% Functions 1/3
72.22% Lines 13/18

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 93 94 95 96      7x   7x     7x                                                                                                                       7x 7x                                                 7x 7x
<template>
<div :class="$style.root" :label-size="currentLabelSize">
    <label :class="$style.label">
        <slot name="label">{{ label }}</slot>
    </label>
    <div :class="$style.value" vusion-slot-name="default">
        <slot></slot>
    </div>
</div>
</template>
 
<script>
import MEmitter from '../m-emitter.vue';
 
export default {
    name: 'u-desc-list-item',
    parentName: 'u-desc-list',
    groupName: 'u-desc-list-group',
    mixins: [MEmitter],
    props: { label: String, labelSize: String },
    data() {
        return { groupVM: undefined, parentVM: undefined };
    },
    computed: {
        currentLabelSize() {
            return (
                this.labelSize
                || (this.groupVM && this.groupVM.labelSize)
                || (this.parentVM && this.parentVM.labelSize)
                || 'auto'
            );
        },
    },
    created() {
        this.$dispatch(this.$options.groupName, 'add-item-vm', this);
        this.$dispatch(this.$options.parentName, 'add-item-vm', this);
    },
    destroyed() {
        this.$dispatch(this.$options.groupName, 'remove-item-vm', this);
        this.$dispatch(this.$options.parentName, 'remove-item-vm', this);
    },
};
</script>
 
<style module>
.root {
    position: relative;
}
 
.root::before, .root::after {
    display: table;
    content: '';
    line-height: 0;
}
 
.root::after {
    clear: both;
}
 
.label {
    display: block;
    float: left;
    padding-right: var(--desc-list-item-label-padding-right);
    text-align: right;
    color: var(--color-light);
}
 
.root[label-size$="auto"] .label { width: auto; padding-right: 1em; }
.root[label-size$="mini"] .label { width: var(--desc-list-item-label-width-mini); }
.root[label-size$="small"] .label { width: var(--desc-list-item-label-width-small); }
.root[label-size$="normal"] .label { width: var(--desc-list-item-label-width); }
.root[label-size$="large"] .label { width: var(--desc-list-item-label-width-large); }
 
.value {
    float: left;
    max-width: calc(100% - var(--desc-list-item-label-width) - 30px);
    color: var(--color-base);
}
 
.root[label-size$="mini"] .value {
    max-width: calc(100% - var(--desc-list-item-label-width-mini) - 30px);
}
 
.root[label-size$="small"] .value {
    max-width: calc(100% - var(--desc-list-item-label-width-small) - 30px);
}
 
.root[label-size$="large"] .value {
    max-width: calc(100% - var(--desc-list-item-label-width-large) - 30px);
}
 
.root[label-size$="huge"] .value {
    max-width: calc(100% - 120px - 30px);
}
</style>