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

40.62% Statements 13/32
33.33% Branches 2/6
11.11% Functions 1/9
41.93% Lines 13/31

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 97 98 99 100 101 102 103 104 105      7x     7x             7x                                                                                         7x 7x                       7x 7x 7x 7x 7x 7x 7x           7x                                          
<template>
<div :class="$style.root" :layout="layout">
    <slot></slot>
</div>
</template>
 
<script>
export default {
    name: 'u-desc-list',
    groupName: 'u-desc-list-group',
    childName: 'u-desc-list-item',
    props: {
        layout: { type: String, default: 'block' },
        labelSize: { type: String, default: 'normal' },
    },
    data() {
        return { groupVMs: [], itemVMs: [] };
    },
    created() {
        this.$on('add-group-vm', (groupVM) => {
            groupVM.parentVM = this;
            this.groupVMs.push(groupVM);
        });
        this.$on('remove-group-vm', (groupVM) => {
            groupVM.parentVM = undefined;
            this.groupVMs.splice(this.groupVMs.indexOf(groupVM), 1);
        });
        this.$on('add-item-vm', (itemVM) => {
            itemVM.parentVM = this;
            this.itemVMs.push(itemVM);
        });
        this.$on('remove-item-vm', (itemVM) => {
            itemVM.parentVM = undefined;
            this.itemVMs.splice(this.itemVMs.indexOf(itemVM), 1);
        });
    },
};
</script>

<style module>
.root {}

.root[layout="inline"] .item {
    display: inline-block;
}

.root[layout="inline"] .item:not(:last-child) {
    margin-right: var(--space-large);
}

.root[layout="block"] .item:not(:last-child) {
    margin-bottom: var(--space-large);
}
 
.root[layout="inline"] .item::before, .root[layout="inline"] .item::after {
    display: block;
}
 
.root[layout="inline"]::after {
    display: block;
    content: '\002e';
    clear: both;
    height: 0;
    visibility: hidden;
}
 
.root[layout="inline"] .item_value {
    max-width: none;
}
 
.root[gap="none"][layout="block"] .item, .root[gap="none"][layout="inline"] .item  {
    margin-bottom: 0;
}
 
.root[gap="none"][layout="block"] .item_label, .root[gap="none"][layout="inline"] .item_label {
    padding-right: 0;
}

.root[gap="none"] .group {
    margin-top: 0;
}
 
.root[gap="none"] .group_title {
    margin-bottom: 0;
}
 
.root[gap="small"][layout="block"] .item:not(:last-child) {
    margin-bottom: var(--space-base);
}
 
.root[gap="small"][layout="inline"] .item:not(:last-child) {
    margin-right: var(--space-base);
}
 
.root[gap="small"][layout="inline"] .item > .item_label { padding-right: 10px; }
 
.root[gap="large"][layout="block"] .item:not(:last-child) {
    margin-bottom: var(--space-huge);
}
 
.root[gap="large"][layout="inline"] .item:not(:last-child) {
    margin-right: var(--space-huge);
}
</style>