aboutsummaryrefslogtreecommitdiff
path: root/src/components/list/list.vue
blob: f17766b47b8dac8a9b0776bca84adc8f434dc292 (plain)
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
<template>
  <div class="list">
    <div
      v-for="item in items"
      :key="getKey(item)"
      class="list-item"
    >
      <slot
        name="item"
        :item="item"
      />
    </div>
    <div
      v-if="items.length === 0 && !!$slots.empty"
      class="list-empty-content faint"
    >
      <slot name="empty" />
    </div>
  </div>
</template>

<script>
export default {
  props: {
    items: {
      type: Array,
      default: () => []
    },
    getKey: {
      type: Function,
      default: item => item.id
    }
  }
}
</script>

<style lang="scss">
@import "../../variables";

.list {
  &-item:not(:last-child) {
    border-bottom: 1px solid;
    border-bottom-color: $fallback--border;
    border-bottom-color: var(--border, $fallback--border);
  }

  &-empty-content {
    text-align: center;
    padding: 10px;
  }
}
</style>