fix: created ListRowItem component to render different type of row item using single component

This commit is contained in:
Shariq Ansari 2023-08-03 21:41:53 +05:30
parent a399cf87c6
commit aadcec3897
2 changed files with 42 additions and 25 deletions

View File

@ -0,0 +1,15 @@
<template>
<slot name="prefix"></slot>
<slot v-if="$slots.default" />
<div v-else class="text-base text-gray-900 truncate">
{{ value }}
</div>
</template>
<script setup>
const props = defineProps({
value: {
type: String,
default: null,
},
})
</script>

View File

@ -77,7 +77,12 @@
class="flex items-center space-x-2.5" class="flex items-center space-x-2.5"
:class="[column.size, column.align]" :class="[column.size, column.align]"
> >
<div v-if="column.type === 'avatar'"> <ListRowItem :value="getValue(row[column.key]).label">
<template #prefix>
<div v-if="column.type === 'indicator'">
<IndicatorIcon :class="getValue(row[column.key]).color" />
</div>
<div v-else-if="column.type === 'avatar'">
<Avatar <Avatar
v-if="getValue(row[column.key]).label" v-if="getValue(row[column.key]).label"
class="flex items-center" class="flex items-center"
@ -96,12 +101,8 @@
shape="square" shape="square"
/> />
</div> </div>
<div v-else-if="column.type === 'indicator'"> </template>
<IndicatorIcon :class="getValue(row[column.key]).color" /> </ListRowItem>
</div>
<div class="text-base text-gray-900 truncate">
{{ getValue(row[column.key]).label }}
</div>
</div> </div>
</router-link> </router-link>
</div> </div>
@ -156,6 +157,7 @@ import IndicatorIcon from './Icons/IndicatorIcon.vue'
import { reactive, ref, computed } from 'vue' import { reactive, ref, computed } from 'vue'
import LayoutHeader from './LayoutHeader.vue' import LayoutHeader from './LayoutHeader.vue'
import Breadcrumbs from './Breadcrumbs.vue' import Breadcrumbs from './Breadcrumbs.vue'
import ListRowItem from './ListRowItem.vue'
const props = defineProps({ const props = defineProps({
list: { list: {