mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
Fixes https://github.com/chatwoot/chatwoot/issues/8436 Fixes https://github.com/chatwoot/chatwoot/issues/9767 Fixes https://github.com/chatwoot/chatwoot/issues/10156 Fixes https://github.com/chatwoot/chatwoot/issues/6031 Fixes https://github.com/chatwoot/chatwoot/issues/5696 Fixes https://github.com/chatwoot/chatwoot/issues/9250 Fixes https://github.com/chatwoot/chatwoot/issues/9762 --------- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
47 lines
945 B
Vue
47 lines
945 B
Vue
<script setup>
|
|
import { computed, ref } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
const props = defineProps({
|
|
text: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
limit: {
|
|
type: Number,
|
|
default: 120,
|
|
},
|
|
});
|
|
const { t } = useI18n();
|
|
const showMore = ref(false);
|
|
|
|
const textToBeDisplayed = computed(() => {
|
|
if (showMore.value || props.text.length <= props.limit) {
|
|
return props.text;
|
|
}
|
|
|
|
return props.text.slice(0, props.limit) + '...';
|
|
});
|
|
const buttonLabel = computed(() => {
|
|
const i18nKey = !showMore.value ? 'SHOW_MORE' : 'SHOW_LESS';
|
|
return t(`COMPONENTS.SHOW_MORE_BLOCK.${i18nKey}`);
|
|
});
|
|
|
|
const toggleShowMore = () => {
|
|
showMore.value = !showMore.value;
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<span>
|
|
{{ textToBeDisplayed }}
|
|
<button
|
|
v-if="text.length > limit"
|
|
class="text-woot-500 !p-0 !border-0 align-top"
|
|
@click="toggleShowMore"
|
|
>
|
|
{{ buttonLabel }}
|
|
</button>
|
|
</span>
|
|
</template>
|