-
Notifications
You must be signed in to change notification settings - Fork 20
/
KCatalogItem.vue
71 lines (61 loc) 路 1.42 KB
/
KCatalogItem.vue
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
<template>
<KCard
class="k-catalog-item"
:data-testid="item && item.title ? `${item.title.replace(/[^0-9a-z]/gi, '-')}-catalog-item` : 'catalog-item'"
role="button"
tabindex="0"
@click="($event: any) => handleCardClick($event, item)"
>
<template #title>
<slot name="card-title">
{{ item ? item.title : '' }}
</slot>
</template>
<template #actions>
<slot name="card-actions" />
</template>
<div :class="{ 'multi-line-truncate': truncate }">
<slot name="card-body">
{{ item ? item.description : '' }}
</slot>
</div>
<template #footer>
<slot name="card-footer" />
</template>
</KCard>
</template>
<script setup lang="ts">
import type { PropType } from 'vue'
import type { CatalogItem } from '@/types'
import KCard from '@/components/KCard/KCard.vue'
defineProps({
item: {
type: Object as PropType<CatalogItem>,
default: () => ({}),
},
truncate: {
type: Boolean,
default: true,
},
})
const emit = defineEmits(['click'])
const handleCardClick = (evt: Event, item: CatalogItem): void => {
emit('click', {
evt,
item,
})
}
</script>
<style lang="scss" scoped>
.k-catalog-item {
cursor: pointer;
overflow: hidden;
transition: box-shadow $kongponentsTransitionDurTimingFunc;
&:hover {
box-shadow: var(--kui-shadow, $kui-shadow);
}
.multi-line-truncate {
@include truncate(3);
}
}
</style>