Skip to content

Commit

Permalink
feat: APPS-2917 FTVA series date variation (#602)
Browse files Browse the repository at this point in the history
* feat: start stories for cardmeta

* fix: run linter

* chore: add story, setup

* chore: lint

* feat: short date ranges on ftvaEventSeries

* chore: update story for sectionwrapper

* fix: dont show date range if ftvaEvent

* chore: lint

* fix: apply blue background to element w border radius

* chore: remove console log lint

---------

Co-authored-by: Jess Divers <[email protected]>
  • Loading branch information
farosFreed and Jess Divers authored Sep 10, 2024
1 parent bef7e2a commit ecbf3ed
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 14 deletions.
22 changes: 14 additions & 8 deletions src/lib-components/CardMeta.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const props = defineProps({
type: String,
default: '',
},
// long = 'Febuary 1, 2022', short = 'Feb 1, 2022
// long single date = 'Febuary 1, 2022', short = 'Feb 1, 2022
// long date range = 'Febuary 1, 2022 - Febuary 2, 2022', short = 'Feb 1 - Feb 2'
dateFormat: {
type: String,
default: 'long',
Expand Down Expand Up @@ -107,8 +108,13 @@ const parsedTarget = computed(() => {
})
const parsedDate = computed(() => {
if (props.startDate)
return props.endDate ? formatDates(props.startDate, props.endDate, props.dateFormat) : formatDates(props.startDate, props.startDate, props.dateFormat)
if (props.startDate) {
if (props.sectionHandle === 'ftvaEvent')
return formatDates(props.startDate, props.startDate, props.dateFormat)
else
return props.endDate ? formatDates(props.startDate, props.endDate, props.dateFormat) : formatDates(props.startDate, props.startDate, props.dateFormat)
}
return ''
})
Expand All @@ -117,10 +123,10 @@ const parsedTime = computed(() => {
if (props.startDate && props.sectionHandle === 'event')
return formatTimes(props.startDate, props.endDate)
// legacy behavior returns nothing when sectionHandle is not 'event',
// so check theme is set to avoid returning nothing
else if (props.startDate && theme?.value !== undefined)
// so check theme is set AND we are not showing ftvaEventSeries data to avoid returning nothing
else if (props.startDate && (props.sectionHandle !== 'ftvaEventSeries' && theme?.value !== undefined))
return props.endDate ? formatTimes(props.startDate, props.endDate) : formatTimes(props.startDate, props.startDate)
// in all other cases incl. if it is ftvaEventSeries, return nothing
return ''
})
Expand Down Expand Up @@ -196,7 +202,7 @@ const classes = computed(() => {
v-if="startDate || ongoing"
class="date-time"
>
<div v-if="ongoing">
<div v-if="ongoing" class="ongoing-item">
Ongoing
</div>
<time
Expand All @@ -205,7 +211,7 @@ const classes = computed(() => {
v-html="parsedDate"
/>
<time
v-if="startDate"
v-if="startDate && sectionHandle !== 'ftvaEventSeries'"
class="schedule-item"
v-html="parsedTime"
/>
Expand Down
20 changes: 20 additions & 0 deletions src/stories/CardMeta.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,23 @@ export function FtvaOnlyCategoryAndTitle() {
`,
}
}
// used on FTVA Event Series Page
export function FTVAOngoing() {
return {
data() {
return { ...mockDefault }
},
components: { CardMeta },
template: `
<card-meta
:to="to"
:category="category"
:title="title"
:ongoing=true
:text="text"
:locations="locations"
:language="language"
/>
`,
}
}
95 changes: 94 additions & 1 deletion src/stories/SectionTeaserCard.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const mockFtva = [
title: 'TEST - La Région Centrale Screening',
startDate: '2027-03-31T07:00:00+00:00',
endDate: null,
sectionHandle: 'ftvaEvent',
image: {
id: '3131261',
src: 'https://static.library.ucla.edu/craftassetstest/FTVA/_fullscreen/pinkcloud-crop.png',
Expand All @@ -114,13 +115,15 @@ const mockFtva = [
to: 'events/step-up-3-07-19-25',
title: 'TEST - Step Up 3D (2010) Sequel to 2008\'s Step Up 2: The Streets and the third installment in the Step Up film series',
startDate: '2028-03-31T07:00:00+00:00',
sectionHandle: 'ftvaEvent',
image: null
},
{
id: '3145784',
to: 'events/step-up-2-07-07-25',
title: 'TEST - Step Up 2: The Streets (2008)',
startDate: '2026-03-31T07:00:00+00:00',
sectionHandle: 'ftvaEvent',
image: {
id: '3157357',
src: 'https://static.library.ucla.edu/craftassetstest/FTVA/_fullscreen/step2.jpg',
Expand All @@ -135,6 +138,77 @@ const mockFtva = [
}
},
]

const mockFtvaSeries = [
{
uri: 'series/todd-solondz-series',
title: 'TEST - Todd Solondz Series',
startDate: '2025-11-06T08:00:00+00:00',
endDate: '2025-12-13T08:00:00+00:00',
ongoing: true,
sectionHandle: 'ftvaEventSeries',
ftvaImage: [
{
id: '3157237',
src: 'https://static.library.ucla.edu/craftassetstest/FTVA/_fullscreen/Todd-Solondz_2024-07-04-073854_jbqd.jpg',
height: 1734,
width: 2560,
srcset: 'https://static.library.ucla.edu/craftassetstest/FTVA/_375xAUTO_crop_center-center_none/Todd-Solondz_2024-07-04-073854_jbqd.jpg 375w, https://static.library.ucla.edu/craftassetstest/FTVA/_960xAUTO_crop_center-center_none/Todd-Solondz_2024-07-04-073854_jbqd.jpg 960w, https://static.library.ucla.edu/craftassetstest/FTVA/_1280xAUTO_crop_center-center_none/Todd-Solondz_2024-07-04-073854_jbqd.jpg 1280w, https://static.library.ucla.edu/craftassetstest/FTVA/_1920xAUTO_crop_center-center_none/Todd-Solondz_2024-07-04-073854_jbqd.jpg 1920w, https://static.library.ucla.edu/craftassetstest/FTVA/_2560xAUTO_crop_center-center_none/Todd-Solondz_2024-07-04-073854_jbqd.jpg 2560w',
alt: null,
focalPoint: [
0.5,
0.5
]
}
]
},
{
uri: 'series/step-up-series',
title: 'TEST Series: The Step Up Movie Series',
startDate: '2025-11-07T08:00:00+00:00',
endDate: '2025-12-20T08:00:00+00:00',
ongoing: false,
sectionHandle: 'ftvaEventSeries',
ftvaImage: [
{
id: '3203293',
src: 'https://static.library.ucla.edu/craftassetstest/FTVA/_fullscreen/step-up-7_2024-08-29-024747_kgpd.jpg',
height: 1438,
width: 2560,
srcset: 'https://static.library.ucla.edu/craftassetstest/FTVA/_375xAUTO_crop_center-center_none/step-up-7_2024-08-29-024747_kgpd.jpg 375w, https://static.library.ucla.edu/craftassetstest/FTVA/_960xAUTO_crop_center-center_none/step-up-7_2024-08-29-024747_kgpd.jpg 960w, https://static.library.ucla.edu/craftassetstest/FTVA/_1280xAUTO_crop_center-center_none/step-up-7_2024-08-29-024747_kgpd.jpg 1280w, https://static.library.ucla.edu/craftassetstest/FTVA/_1920xAUTO_crop_center-center_none/step-up-7_2024-08-29-024747_kgpd.jpg 1920w, https://static.library.ucla.edu/craftassetstest/FTVA/_2560xAUTO_crop_center-center_none/step-up-7_2024-08-29-024747_kgpd.jpg 2560w',
alt: null,
focalPoint: [
0.5,
0.5
]
}
]
},
{
uri: 'series/series-with-3-upcoming-events',
title: 'Series with 3 upcoming events',
startDate: '2025-11-07T08:00:00+00:00',
endDate: '2025-12-20T08:00:00+00:00',
sectionHandle: 'ftvaEventSeries',
ongoing: false,
ftvaImage: []
}
]
// Sample data from Craft CMS for FTVA Event Series uses:
// 'uri' instead of 'to',
// 'ftvaImage' ARRAY instead of 'image' OBJECT,
// these fields will need to be parsed to match the component props if final data is structured this way
const parsedFTVAEventSeries = mockFtvaSeries.map((item) => {
return {
to: item.uri,
title: item.title,
startDate: item.startDate ? item.startDate : null,
endDate: item.endDate ? item.endDate : null,
ongoing: item.ongoing,
sectionHandle: item.sectionHandle,
image: item.ftvaImage[0],
}
})
// Variations of stories below
export function Default() {
return {
Expand All @@ -150,7 +224,7 @@ export function Default() {
}
}

export function FTVAWithSectionTitle() {
export function FTVAEventDetail() {
return {
data() {
return { items: mockFtva }
Expand All @@ -169,3 +243,22 @@ export function FTVAWithSectionTitle() {
`,
}
}

export function ftvaEventSeries() {
return {
data() {
return { items: parsedFTVAEventSeries }
},
provide() {
return {
theme: computed(() => 'ftva'),
}
},
components: { SectionTeaserCard },
template: `
<section-teaser-card
:items="items"
/>
`,
}
}
5 changes: 4 additions & 1 deletion src/stories/SectionWrapper.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ const mockFtvaSeries = [
title: 'TEST - Todd Solondz Series',
startDate: '2025-11-06T08:00:00+00:00',
endDate: '2025-12-13T08:00:00+00:00',
ongoing: false,
ongoing: true,
sectionHandle: 'ftvaEventSeries',
image:
{
id: '3157237',
Expand All @@ -225,6 +226,7 @@ const mockFtvaSeries = [
startDate: '2025-11-07T08:00:00+00:00',
endDate: '2025-12-20T08:00:00+00:00',
ongoing: false,
sectionHandle: 'ftvaEventSeries',
image:
{
id: '3203293',
Expand All @@ -246,6 +248,7 @@ const mockFtvaSeries = [
endDate: '2026-03-31T07:00:00+00:00',
ongoing: false,
image: null,
sectionHandle: 'ftvaEventSeries'
},
]

Expand Down
9 changes: 7 additions & 2 deletions src/styles/ftva/_block-card-with-image.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@
height: 34px;
overflow: hidden;

.ongoing-item + .schedule-item {
// hide the date range if the ongoing label is display
display: none;
}

.schedule-item:nth-of-type(1) {
position: relative;
margin-right: 28px;

&::after {
// show the diamond icon after, but only if it's not the last child
&:not(:last-child)::after {
content: url('ucla-library-design-tokens/assets/svgs/icon-ftva-diamond.svg');
position: absolute;
right: -30px;
Expand Down
4 changes: 2 additions & 2 deletions src/styles/ftva/_section-wrapper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
:deep(.section-teaser-card) {
--color-children-theme: #{$page-blue};

.card-meta {
.block-highlight.card {
background-color: var(--color-children-theme);
}
}
Expand All @@ -47,7 +47,7 @@


:deep(*) {
.card-meta {
.block-highlight.card {
background-color: var(--color-children-theme);
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/utils/formatEventDates.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ function formatDates(startDate = '', endDate = '', dateFormat = 'long') {
// "Feb 11 2020"
const day = output.slice(0, 3)
const dateYear = output.split(' ').slice(1).join(' ')
if (endDate && endDate !== startDate) {
// Feb 11 – May 31
const shortFormatEndDate = format(new Date(endDate), 'MMM d')
const shortFormatStartDate = format(new Date(startDate), 'MMM d')
return `${shortFormatStartDate} - ${shortFormatEndDate}`
}
return `${day} ${dateYear}`
}

Expand Down

1 comment on commit ecbf3ed

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.