Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

3206 eventcard limit description lengths #3484

Merged
merged 8 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions components/Events/EventsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
:segment="segment"
:vertical-layout="verticalLayout"
:alt-text="altText"
:description="description"
>
<div class="events-card__description">
<slot v-if="$slots.default" />
</div>
<div>
<div v-if="location" class="events-card__detail">
<Map20 class="events-card__icon" />
Expand Down Expand Up @@ -46,12 +44,13 @@ 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;
Expand All @@ -68,6 +67,8 @@ withDefaults(defineProps<Props>(), {
segment: undefined,
time: undefined,
verticalLayout: false,
description: undefined,
to: "",
regions: () => [],
});
</script>
Expand All @@ -76,10 +77,6 @@ withDefaults(defineProps<Props>(), {
@use "~/assets/scss/carbon.scss";

.events-card {
&__description {
margin-bottom: carbon.$spacing-06;
}

&__detail {
display: flex;
align-items: center;
Expand Down
4 changes: 2 additions & 2 deletions components/Ui/DataTable/UiDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
</template>

<script setup lang="ts">
import { TextLink } from "~/types/links";
import { Link } from "~/types/links";

export interface TableRowElement {
addTooltip?: boolean;
component?: string;
packageName?: string;
styles?: string;
data: string | TextLink;
data: string | Link;
}

interface Props {
Expand Down
114 changes: 94 additions & 20 deletions components/Ui/UiCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,55 @@
</div>
</header>
<div class="card__body">
<div class="card__description">
<slot />
<div class="card__body__top">
<div class="card__eyebrow">
<slot name="eyebrow"></slot>
</div>
<div v-if="description" class="card__description">
<p :id="`ui-card-desc-${$.uid}`">
{{ showMaxDescription(description) }}
<UiLinkText
v-if="descriptionTooLong"
:link="{
url: '',
segment:
segment && descriptionTooLong && !showMore
? {
cta: 'show-more',
location: segment?.location,
}
: undefined,
}"
class="card__description__toggle"
@click="toggleDescriptionLength"
>
{{ !showMore ? "Show more" : "Show less" }}
</UiLinkText>
</p>
</div>
</div>
<div class="card__ctas">
<UiCta
v-if="to"
is-wider
kind="ghost"
:label="ctaLink.label"
:segment="ctaLink.segment"
:url="ctaLink.url"
/>
<UiCta
v-if="secondaryCta"
is-wider
kind="ghost"
:label="secondaryCta.label"
:segment="secondaryCta.segment"
:url="secondaryCta.url"
/>
<div class="card__body__bottom">
<div class="card__slot">
<slot></slot>
</div>
<div class="card__ctas">
<UiCta
v-if="to"
is-wider
kind="ghost"
:label="ctaLink.label"
:segment="ctaLink.segment"
:url="ctaLink.url"
/>
<UiCta
v-if="secondaryCta"
is-wider
kind="ghost"
:label="secondaryCta.label"
:segment="secondaryCta.segment"
:url="secondaryCta.url"
/>
</div>
</div>
</div>
</div>
Expand All @@ -87,6 +116,8 @@ interface Props {
image?: string;
imageContain?: boolean;
altText?: string;
description?: string;
maxDescriptionLength?: number;
segment?: CtaClickedEventProp | undefined;
subtitle?: string;
secondaryTags?: string[];
Expand All @@ -103,6 +134,8 @@ const props = withDefaults(defineProps<Props>(), {
image: "",
imageContain: false,
altText: "No description available",
description: undefined,
maxDescriptionLength: 240,
segment: undefined,
subtitle: "",
secondaryTags: () => [],
Expand All @@ -122,6 +155,22 @@ const ctaLink = computed(() => ({
function hasTags(tags: string[]) {
return Array.isArray(tags) && tags.length > 0;
}

const descriptionTooLong =
props.description && props.description.length > props.maxDescriptionLength;

const showMore = ref(false);
function toggleDescriptionLength() {
showMore.value = !showMore.value;
}

function showMaxDescription(description: string) {
if (descriptionTooLong && !showMore.value) {
return description.substring(0, props.maxDescriptionLength).trim() + "...";
}

return description;
}
</script>

<style lang="scss" scoped>
Expand Down Expand Up @@ -168,6 +217,18 @@ function hasTags(tags: string[]) {

&__body {
overflow-wrap: break-word;
display: flex;
flex-direction: column;
justify-content: flex-end;
height: 100%;

&__top {
height: 100%;
}
}

&__eyebrow {
margin-bottom: carbon.$spacing-05;
}

&__content {
Expand All @@ -178,6 +239,20 @@ function hasTags(tags: string[]) {
justify-content: space-between;
}

&__description {
margin-bottom: carbon.$spacing-06;
max-height: 240ch;

&__toggle {
cursor: pointer;
color: qiskit.$link-color-tertiary;

&:hover {
color: qiskit.$link-color-tertiary;
}
}
}

&__ctas {
display: flex;
justify-content: flex-start;
Expand All @@ -188,7 +263,6 @@ function hasTags(tags: string[]) {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: carbon.$spacing-07;

@include carbon.breakpoint-down(lg) {
flex-direction: column;
Expand Down
2 changes: 1 addition & 1 deletion hooks/mock/content/events/upcoming-community-events.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"startDateAndTime": null,
"endDate": "",
"to": "https://imperturbable-hyphenation.info/",
"abstract": "Accusamus eos amet animi saepe quidem fugit veritatis ex eveniet. Consectetur saepe assumenda. Esse id unde quibusdam consequuntur minima aperiam dicta amet rem."
"abstract": "Accusamus eos amet animi saepe quidem fugit veritatis ex eveniet. Consectetur saepe assumenda. Esse id unde quibusdam consequuntur minima aperiam dicta amet rem. Accusamus eos amet animi saepe quidem fugit veritatis ex eveniet. Consectetur saepe assumenda. Esse id unde quibusdam consequuntur minima aperiam dicta amet rem. Accusamus eos amet animi saepe quidem fugit veritatis ex eveniet. Consectetur saepe assumenda. Esse id unde quibusdam consequuntur minima aperiam dicta amet rem. Accusamus eos amet animi saepe quidem fugit veritatis ex eveniet. Consectetur saepe assumenda. Esse id unde quibusdam consequuntur"
},
{
"types": ["Open Source"],
Expand Down
5 changes: 2 additions & 3 deletions pages/events/fall-fest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
:alt-text="headerData.card.altText"
:title="headerData.card.title"
:to="headerData.card.to"
:description="headerData.card.description"
vertical-layout
>
{{ headerData.card.description }}
</EventsCard>
/>
</template>
</LayoutLeadSpaceWithCard>

Expand Down
9 changes: 6 additions & 3 deletions pages/events/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@
:time="eventItem.startDateAndTime"
:to="eventItem.to"
:regions="eventItem.regions"
>
{{ eventItem.abstract }}
</EventsCard>
:description="eventItem.abstract || ''"
:segment="{
cta: '',
location: 'event-pages-index',
}"
/>
</div>
</div>
</template>
Expand Down
20 changes: 10 additions & 10 deletions pages/events/seminar-series.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
:institution="cardContent.institution"
:location="cardContent.location"
:title="cardContent.title"
:to="cardContent.to"
vertical-layout
/>
</template>
Expand Down Expand Up @@ -311,14 +310,16 @@ function dataPerRow(
{
component: "AppCta",
styles: "min-width: 5rem;",
data: {
url: event.to,
label: "Join event",
segment: {
cta: "talk-on-youtube",
location: eventsSection,
},
},
data: event.to
? {
url: event.to,
label: "Join event",
segment: {
cta: "talk-on-youtube",
location: eventsSection,
},
}
: "",
},
]);
}
Expand All @@ -332,7 +333,6 @@ useSchemaOrg([
startDate: new Date(event.startDate),
mode: "Online",
location: event.location,
url: event.to,
name: event.title,
image: event.image,
performer: event.speaker,
Expand Down
5 changes: 2 additions & 3 deletions pages/events/summer-school-2022.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
:title="headerData.card.title"
:to="headerData.card.to"
vertical-layout
>
{{ headerData.card.description }}
</EventsCard>
:description="headerData.card.description"
/>
</template>
</LayoutLeadSpaceWithCard>

Expand Down
5 changes: 2 additions & 3 deletions pages/events/summer-school-2023.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@
:time="headerData.card.time"
:title="headerData.card.title"
:to="headerData.card.to"
:description="headerData.card.description"
vertical-layout
>
{{ headerData.card.description }}
</EventsCard>
/>
</template>
</LayoutLeadSpaceWithCard>

Expand Down
2 changes: 1 addition & 1 deletion utils/event-schema-org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface Event {
startDate: Date;
mode: "Online" | "Offline";
location: string;
url: string;
url?: string;
name: string;
image: string;
performer?: string;
Expand Down
Loading