0
0
Fork 0
salix-front-mindshore-fork2/src/components/ui/CardList2.vue

121 lines
2.8 KiB
Vue

<script setup>
import { ref, watch } from 'vue';
const $props = defineProps({
addElement: { type: Function, required: true },
element: { type: Object, default: null },
id: { type: Number, default: null },
isSelected: { type: Boolean, default: false },
title: { type: String, default: null },
});
const checkSelect = ref(false);
watch(
() => $props.isSelected,
(value, prevValue) => {
checkSelect.value = value;
}
);
const selectedItem = (item) => {
$props.addElement(item);
};
</script>
<template>
<QCard class="card q-mb-md cursor-pointer q-hoverable bg-white-7 q-pa-lg">
<div>
<slot name="title">
<div class="flex justify-between">
<div class="flex">
<div class="title text-primary text-weight-bold text-h5">
{{ $props.title }}
</div>
<QChip outline color="grey" size="sm">
ID: {{ $props.id }}
</QChip>
</div>
<QCheckbox
v-model="checkSelect"
@click="selectedItem($props.element)"
/>
</div>
</slot>
<div class="card-list-body">
<div class="list-items row flex-wrap-wrap">
<slot name="list-items" />
</div>
<div class="actions">
<slot name="actions" />
</div>
</div>
</div>
</QCard>
</template>
<style lang="scss">
.title {
margin-right: 25px;
}
.card-list-body {
display: flex;
justify-content: space-between;
margin-top: 10px;
.vn-label-value {
display: flex;
justify-content: flex-start;
gap: 2%;
width: 50%;
.label {
width: 35%;
color: var(--vn-label);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.value {
width: 65%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.actions {
display: flex;
flex-direction: column;
justify-content: center;
width: 25%;
}
}
@media (max-width: $breakpoint-xs) {
.card-list-body {
flex-wrap: wrap;
justify-content: center;
.vn-label-value {
width: 100%;
}
.actions {
width: 100%;
margin-top: 15px;
padding: 0 15%;
justify-content: center;
}
}
}
</style>
<style lang="scss" scoped>
.card {
transition: background-color 0.2s;
}
.card:hover {
background-color: var(--vn-gray);
}
.list-items {
width: 75%;
}
</style>