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

Commit

Permalink
feat(#3206): toggle description into UiCard
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Aragón <[email protected]>
  • Loading branch information
paaragon committed Aug 7, 2023
1 parent 2adfb18 commit 35f70ae
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 67 deletions.
28 changes: 12 additions & 16 deletions components/Ecosystem/EcosystemCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
}"
:to="member.url"
:secondary-cta="websiteCta"
:description="member.description"
>
<div class="ecosystem-card__details">
<span class="ecosystem-card__licence">
{{ member.licence }}
</span>
<span class="ecosystem-card__stars">
<StarFilled16 />
<span v-if="member.stars > 0">{{ member.stars }}</span>
</span>
</div>
<p class="ecosystem-card__description">
{{ member.description }}
</p>
<template #eyebrow>
<div class="ecosystem-card__details">
<span class="ecosystem-card__licence">
{{ member.licence }}
</span>
<span class="ecosystem-card__stars">
<StarFilled16 />
<span v-if="member.stars > 0">{{ member.stars }}</span>
</span>
</div>
</template>
</UiCard>
<bx-accordion v-if="hasTestsResults">
<bx-accordion-item
Expand Down Expand Up @@ -121,10 +121,6 @@ function formatTimestamp(timestamp: number): string {
}
}
&__description {
margin-top: carbon.$spacing-05;
}
&__details {
display: flex;
align-items: center;
Expand Down
44 changes: 2 additions & 42 deletions components/Events/EventsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,8 @@
:segment="segment"
:vertical-layout="verticalLayout"
:alt-text="altText"
:description="description"
>
<div v-if="description" class="events-card__description">
<p v-if="!tooLongDescription">
{{ description }}
</p>
<p v-if="tooLongDescription && !showMore">
{{ description.substring(0, MAX_DESCRIPTION_LENGTH_CH).trim() }}...
<span
class="events-card__description__toggle"
@click="toggleDescriptionLength"
>show more</span
>
</p>
<p v-if="showMore">
{{ description }}
<span
class="events-card__description__toggle"
@click="toggleDescriptionLength"
>show less</span
>
</p>
</div>
<div>
<div v-if="location" class="events-card__detail">
<Map20 class="events-card__icon" />
Expand Down Expand Up @@ -77,7 +57,7 @@ interface Props {
regions?: string[];
}
const props = withDefaults(defineProps<Props>(), {
withDefaults(defineProps<Props>(), {
types: () => [],
altText: "Event image",
institution: "",
Expand All @@ -91,33 +71,13 @@ const props = withDefaults(defineProps<Props>(), {
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;
}
</script>

<style lang="scss" scoped>
@use "~/assets/scss/carbon.scss";
@use "~/assets/scss/helpers/index.scss" as qiskit;
.events-card {
&__description {
margin-bottom: carbon.$spacing-06;
max-height: 240ch;
height: 100%;
&__toggle {
cursor: pointer;
color: qiskit.$link-color-tertiary;
}
}
&__detail {
display: flex;
align-items: center;
Expand Down
85 changes: 76 additions & 9 deletions components/Ui/UiCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,51 @@
</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 v-if="!tooLongDescription">
{{ description }}
</p>
<p v-if="tooLongDescription && !showMore">
{{
description.substring(0, MAX_DESCRIPTION_LENGTH_CH).trim()
}}...
<UiLinkText
:link="{
url: '',
segment: segment
? {
cta: 'show-more',
location: segment?.location,
}
: undefined,
}"
class="card__description__toggle"
@click="toggleDescriptionLength"
>show more</UiLinkText
>
</p>
<p v-if="showMore">
{{ description }}
<UiLinkText
:link="{
url: '',
}"
class="card__description__toggle"
@click="toggleDescriptionLength"
>show less</UiLinkText
>
</p>
</div>
</div>
<div class="card__ctas">
<div class="card__body__bottom">
<div class="card__slot">
<slot></slot>
</div>
<div class="card__ctas"></div>
<UiCta
v-if="to"
is-wider
Expand Down Expand Up @@ -87,6 +128,7 @@ interface Props {
image?: string;
imageContain?: boolean;
altText?: string;
description?: string;
segment?: CtaClickedEventProp | undefined;
subtitle?: string;
secondaryTags?: string[];
Expand All @@ -103,6 +145,7 @@ const props = withDefaults(defineProps<Props>(), {
image: "",
imageContain: false,
altText: "No description available",
description: undefined,
segment: undefined,
subtitle: "",
secondaryTags: () => [],
Expand All @@ -122,6 +165,15 @@ const ctaLink = computed(() => ({
function hasTags(tags: string[]) {
return Array.isArray(tags) && tags.length > 0;
}
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;
}
</script>

<style lang="scss" scoped>
Expand Down Expand Up @@ -168,10 +220,18 @@ function hasTags(tags: string[]) {
&__body {
overflow-wrap: break-word;
height: 100%;
display: flex;
justify-content: flex-end;
flex-direction: column;
justify-content: flex-end;
height: 100%;
&__top {
height: 100%;
}
}
&__eyebrow {
margin-bottom: carbon.$spacing-05;
}
&__content {
Expand All @@ -183,10 +243,17 @@ function hasTags(tags: string[]) {
}
&__description {
height: 100%;
display: flex;
flex-direction: column;
justify-content: flex-end;
margin-bottom: carbon.$spacing-06;
max-height: 240ch;
&__toggle {
cursor: pointer;
color: qiskit.$link-color-tertiary;
&:hover {
color: qiskit.$link-color-tertiary;
}
}
}
&__ctas {
Expand Down
4 changes: 4 additions & 0 deletions pages/events/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
:to="eventItem.to"
:regions="eventItem.regions"
:description="eventItem.abstract || ''"
:segment="{
cta: '',
location: 'event-pages-index',
}"
/>
</div>
</div>
Expand Down

0 comments on commit 35f70ae

Please sign in to comment.