Replace fixed text length with css line-clamp (#96)

This commit is contained in:
mchev
2024-06-05 14:36:32 +02:00
committed by GitHub
parent bf5a8cdb28
commit 592a537379
15 changed files with 18 additions and 27 deletions

View File

@@ -26,7 +26,6 @@
<div class="flex relative justify-between mb-2">
<BaseText
:text="selectedCustomer.name"
:length="30"
class="flex-1 text-base font-medium text-left text-gray-900"
/>
<div class="flex">
@@ -308,7 +307,6 @@
<BaseText
v-if="customer.name"
:text="customer.name"
:length="30"
class="
m-0
text-base
@@ -320,7 +318,6 @@
<BaseText
v-if="customer.contact_name"
:text="customer.contact_name"
:length="30"
class="
m-0
text-sm

View File

@@ -1,9 +1,10 @@
<template>
<BaseCustomTag :tag="tag" :title="text">
{{ displayText }}
</BaseCustomTag>
<div class="whitespace-normal">
<BaseCustomTag :tag="tag" :title="text" class="line-clamp-1">
{{ displayText }}
</BaseCustomTag>
</div>
</template>
<script setup>
import { computed } from "vue"
@@ -20,12 +21,17 @@ const props = defineProps({
length: {
type: Number,
default: 0,
default: null,
}
})
const displayText = computed(() => {
const { text, length } = props;
const displayText = computed(() => {
if (length) {
return text.length <= length ? text : `${text.substring(0, length)}...`;
}
return text;
});
return props.text.length < props.length ? props.text : `${props.text.substring(0 , props.length)}...`
})
</script>