All files / src/components TableSkeleton.vue

100% Statements 4/4
100% Branches 0/0
100% Functions 1/1
100% Lines 4/4

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                                                      9x 9x                         10x 10x                                                                            
<template>
  <div class="table-skeleton">
    <div class="table-skeleton__header">
      <span
        v-for="col in columns"
        :key="col.field"
        class="table-skeleton__header-cell"
      >
        {{ col.header }}
      </span>
    </div>
    <div
      v-for="row in rows"
      :key="row"
      class="table-skeleton__row"
    >
      <Skeleton
        v-for="col in columns"
        :key="col.field"
        height="16px"
        :width="columnWidth"
      />
    </div>
  </div>
</template>
 
<script setup>
import Skeleton from '@atomic-ui/skeleton';
import { computed } from 'vue';
 
const props = defineProps({
  rows: {
    type: Number,
    default: 5,
  },
  columns: {
    type: Array,
    required: true,
  },
});
 
const columnWidth = computed(
  () => `${Math.floor(100 / props.columns.length) - 2}%`,
);
</script>
 
<style lang="scss" scoped>
.table-skeleton {
  width: 100%;
  border-bottom: $gray-3-border;
  overflow: hidden;
 
  &__header {
    display: flex;
    gap: 16px;
    padding: 16px 8px;
    background-color: $white;
    border-bottom: $gray-3-border;
  }
 
  &__header-cell {
    flex: 1;
    font-weight: $font-weight-lg;
    font-size: $font-size-lg;
    line-height: $line-height-lg;
    color: $black;
  }
 
  &__row {
    display: flex;
    gap: 16px;
    padding: 16px 8px;
    border-bottom: $gray-3-border;
 
    &:last-child {
      border-bottom: none;
    }
  }
}
</style>