Skip to content

Commit

Permalink
fix: APPS-2972 Reformat dates to exclude the leading zero on single d…
Browse files Browse the repository at this point in the history
…igit dates (#638)

* update the format to have no leading zero on single digit days and update the story to contain one

* update block-clipped-date stories to test for single digit format effect

* update block-clipped-date stories to test for single digit format effect

* update only block-three-column

* linting
  • Loading branch information
jendiamond authored Oct 22, 2024
1 parent 12bc41e commit 76b7155
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/lib-components/BlockCardThreeColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { computed } from 'vue'
import type { PropType } from 'vue'
import MoleculePlaceholder from 'ucla-library-design-tokens/assets/svgs/molecule-placeholder.svg'
import format from 'date-fns/format'
import { useTheme } from '@/composables/useTheme'

// COMPONENTS
Expand All @@ -15,7 +16,6 @@ import CardMeta from '@/lib-components/CardMeta.vue'

// UTILITY FUNCTIONS
import formatFullDay from '@/utils/formatFullDay'
import formatDay from '@/utils/formatEventDay'
import formatMonth from '@/utils/formatEventMonth'

// TYPESCRIPT
Expand Down Expand Up @@ -75,8 +75,7 @@ const parsedDateMonth = computed(() => {

const parsedDateDay = computed(() => {
if (props.startDate)
return formatDay(props.startDate)

return format(new Date(props.startDate), 'd')
return ''
})

Expand Down
40 changes: 40 additions & 0 deletions src/stories/BlockCardThreeColumn.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ const mockDefault = {
],
}

const mockSingleDigitDate = {
to: 'series/todd-solondz-series',
startDate: '2026-02-03T06:30:00+00:00',
image: API.image,
title: 'TEST - Todd Solondz Series',
endDate: '2026-04-08T05:45:00+00:00',
tagLabels: [
{
title: 'Guest speaker'
},
{
title: '35mm'
}
],
}

// Variations of stories below
export function Default(args) {
return {
Expand All @@ -53,6 +69,30 @@ export function Default(args) {
}
}

export function SingleDigitDate(args) {
return {
data() {
return { ...mockSingleDigitDate }
},
provide() {
return {
theme: computed(() => 'ftva'),
}
},
components: { BlockCardThreeColumn },
template: `
<block-card-three-column
:to="to"
:start-date="startDate"
:image="image"
:image-aspect-ratio="100"
:title="title"
:tagLabels="tagLabels"
:startTime="parsedTime"
/>`,
}
}

export function LongTitle(args) {
return {
data() {
Expand Down
47 changes: 45 additions & 2 deletions src/stories/BlockClippedDate.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,26 @@ const mock = {
title: 'Seven seas of the ancient world',
alternativeFullName: '陳餘敏卿纪念基金',
language: 'zh',
startDate: '2022-03-31T07:00:00+00:00',
endDate: '2021-11-26T11:00:00-08:00',
startDate: '2026-12-17T07:00:00+00:00',
endDate: '2027-12-26T11:00:00-08:00',
text: '<p>In Greek literature (which is where the phrase entered Western literature), the Seven Seas were the Aegean, Adriatic, Mediterranean, Black, Red, and Caspian seas, with the Persian Gulf</p>',
imageAspectRatio: 60,
locations: [
{ title: 'Powellarium', to: '/location/bar' },
{ title: 'Research Library (Charles E. Young)', to: '/location/baz' },
],
sectionHandle: 'event',
}

const mockSingleDigitDate = {
image: API.image,
to: '/visit/foo/bar/',
category: 'Ullamco',
title: 'Seven seas of the ancient world',
alternativeFullName: '陳餘敏卿纪念基金',
language: 'zh',
startDate: '2026-02-05T07:00:00+00:00',
endDate: '2027-02-07T11:00:00-08:00',
text: '<p>In Greek literature (which is where the phrase entered Western literature), the Seven Seas were the Aegean, Adriatic, Mediterranean, Black, Red, and Caspian seas, with the Persian Gulf</p>',
imageAspectRatio: 60,
locations: [
Expand Down Expand Up @@ -68,6 +86,31 @@ export function Default() {
}
}

export function SingleDigitDate() {
return {
data() {
return { ...mockSingleDigitDate }
},
components: { BlockClippedDate },
template: `
<block-clipped-date
:image="image"
:to="to"
:category="category"
:title="title"
:start-date="startDate"
:end-date="endDate"
:text="text"
:image-aspect-ratio="60"
:locations="locations"
:alternativeFullName="alternativeFullName"
:language="language"
:section-handle="sectionHandle"
/>
`,
}
}

export function OngoingEvent() {
return {
data() {
Expand Down
16 changes: 8 additions & 8 deletions src/stories/SectionTeaserList.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const mockDefault = [
category: 'Ullamco',
title: 'Fames ac turpis egestas sed tempus lorem ipsum',
startDate: '2021-09-03T08:00:00+00:00',
endDate: '2021-10-08T07:10:00+00:00',
endDate: '2021-10-28T07:10:00+00:00',
text: 'Ultricies leo integer malesuada nunc vel risus commodo viverra.',
sectionHandle: 'event',
},
Expand All @@ -26,8 +26,8 @@ const mockDefault = [
to: '/visit/foo/baz/',
category: 'Sagittis',
title: 'Amet nisl suscipit adipiscing bibendum lectus sed',
startDate: '2021-09-03T08:00:00+00:00',
endDate: '2021-10-08T07:10:00+00:00',
startDate: '2021-09-09T08:00:00+00:00',
endDate: '2021-10-18T07:10:00+00:00',
sectionHandle: 'event',
text: 'A diam maecenas sed enim. Tristique senectus et netus et malesuada fames. Nibh nisl condimentum id venenatis. Mi bibendum neque egestas congue. Placerat duis ultricies lacus sed turpis. Massa enim nec dui nunc mattis. Dolor morbi non arcu risus quis varius vestibulum sed.',
},
Expand All @@ -37,7 +37,7 @@ const mockDefault = [
category: 'Tincidunt',
title: 'Scelerisque varius morbi enim nunc ornare quam',
startDate: '2021-09-03T08:00:00+00:00',
endDate: '2021-10-08T07:10:00+00:00',
endDate: '2021-10-23T07:10:00+00:00',
sectionHandle: 'event',
text: 'Eu ultrices vitae auctor eu augue. Dolor morbi non arcu risus quis varius quam. Augue lacus viverra vitae congue eu consequat.',
},
Expand All @@ -46,8 +46,8 @@ const mockDefault = [
to: '/visit/foo/ban/',
category: 'Gravida',
title: 'At varius vel pharetra vel turpis. Quam vulputate dignissim suspendisse in est ante in. Sed cras ornare arcu. Non diam phasellus vestibulum.',
startDate: '2021-09-03T08:00:00+00:00',
endDate: '2021-10-08T07:10:00+00:00',
startDate: '2021-09-08T08:00:00+00:00',
endDate: '2021-10-18T07:10:00+00:00',
sectionHandle: 'event',
text: 'Accumsan tortor posuere ac ut consequat semper viverra libero.',
},
Expand All @@ -70,7 +70,7 @@ const mockMixedOngoingEvents = [
category: 'Ullamco',
title: 'Fames ac turpis egestas sed tempus lorem ipsum',
startDate: '2021-09-03T08:00:00+00:00',
endDate: '2021-10-08T07:10:00+00:00',
endDate: '2021-10-13T07:10:00+00:00',
text: 'Ultricies leo integer malesuada nunc vel risus commodo viverra.',
sectionHandle: 'event',
},
Expand Down Expand Up @@ -133,7 +133,7 @@ const mockDynamicComponent = [
id: '2847944',
to: 'events/la-région-centrale-03-08-24',
title: 'TEST - La Région Centrale Screening',
startDate: '2027-03-31T07:00:00+00:00',
startDate: '2027-03-05T07:00:00+00:00',
image: API.image,
tagLabels: [
{ title: 'Guest speaker' },
Expand Down

1 comment on commit 76b7155

@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.