From edd51b7e172e041cba02255ab0dff99ccd42b73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Arag=C3=B3n?= Date: Thu, 3 Aug 2023 15:54:07 +0200 Subject: [PATCH] feat(#3206): truncate EventsCard description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pablo Aragón --- components/Events/EventsCard.vue | 42 +++++++++++++++++-- components/Ui/DataTable/UiDataTable.vue | 4 +- .../events/upcoming-community-events.json | 2 +- pages/events/fall-fest.vue | 5 +-- pages/events/index.vue | 5 +-- pages/events/seminar-series.vue | 20 ++++----- pages/events/summer-school-2022.vue | 5 +-- pages/events/summer-school-2023.vue | 5 +-- utils/event-schema-org.ts | 2 +- 9 files changed, 60 insertions(+), 30 deletions(-) diff --git a/components/Events/EventsCard.vue b/components/Events/EventsCard.vue index d82e8c15a1..32ee250487 100644 --- a/components/Events/EventsCard.vue +++ b/components/Events/EventsCard.vue @@ -11,8 +11,23 @@ :vertical-layout="verticalLayout" :alt-text="altText" > -
- +
+

+ {{ description.substring(0, MAX_DESCRIPTION_LENGTH_CH).trim() }}... + show more +

+

+ {{ description }} + show less +

@@ -46,19 +61,20 @@ interface Props { types?: string[]; title: string; image: string; + description?: string; altText?: string; institution?: string; location?: string; date?: string; time?: string | null; - to: string; + to?: string; ctaLabel?: string; segment?: CtaClickedEventProp | undefined; verticalLayout?: boolean; regions?: string[]; } -withDefaults(defineProps(), { +const props = withDefaults(defineProps(), { types: () => [], altText: "Event image", institution: "", @@ -68,8 +84,19 @@ withDefaults(defineProps(), { segment: undefined, time: undefined, verticalLayout: false, + description: undefined, + to: "", regions: () => [], }); + +const MAX_DESCRIPTION_LENGTH_CH = 240; +const tooLongDescription = + props.description && props.description.length > MAX_DESCRIPTION_LENGTH_CH; + +const showMore = ref(false); +function toggleDescriptionLength() { + showMore.value = !showMore.value; +}