Skip to content

Commit

Permalink
feat: APPS-2920 theme to toggle 'multiple locations' (#601)
Browse files Browse the repository at this point in the history
* feat: prop to toggle 'multiple locations'

* feat: change to themesettings, fix story

---------

Co-authored-by: Jess Divers <[email protected]>
  • Loading branch information
farosFreed and Jess Divers authored Sep 4, 2024
1 parent cdced68 commit b998ab6
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 18 deletions.
51 changes: 34 additions & 17 deletions src/lib-components/BlockEventDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,26 @@ const { startDate, time, locations } = defineProps({
locations: {
type: Array<BlockEventDetailLocation>,
default: () => [],
},
}
})
const theme = useTheme()
const classes = computed(() => {
return ['block-event-detail', theme?.value || '']
})
const themeSettings = computed(() => {
switch (theme?.value) {
case 'ftva':
return {
multiLocationMsgDisplay: true,
}
default:
return {
multiLocationMsgDisplay: false,
}
}
})
</script>
<template>
Expand All @@ -63,23 +75,28 @@ const classes = computed(() => {
>
<span>
<SvgIconLocation class="row-icon" />
<span
v-for="(location, index) in locations"
:key="location.title"
class="location-link"
>
<SmartLink
:to="location.title"
:link-target="location.uri ? location.uri : ''"
<span v-if="themeSettings?.multiLocationMsgDisplay && locations.length > 1">
Multiple Locations
</span>
<span v-else class="locations-wrapper">
<span
v-for="(location, index) in locations"
:key="location.title"
class="location-link"
>
{{ location.title }}
</SmartLink>
{{ index
< locations.length
- 1
? ', '
: ''
}}
<SmartLink
:to="location.title"
:link-target="location.uri ? location.uri : ''"
>
{{ location.title }}
</SmartLink>
{{ index
< locations.length
- 1
? ', '
: ''
}}
</span>
</span>
</span>
</div>
Expand Down
31 changes: 30 additions & 1 deletion src/stories/BlockEventDetail.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const mockEventDetailData = {
title: 'Billy Wilder Theater',
url: 'https://test-craft.library.ucla.edu/locations/billy-wilder-theater',
uri: 'locations/billy-wilder-theater'
},
{
id: '195746',
title: 'Other Location',
url: 'https://test-craft.library.ucla.edu/locations/other-locations',
uri: 'locations/somelocation'
}
]
}
Expand All @@ -42,7 +48,7 @@ export function Default() {
}
}

export function FTVA() {
export function FTVAMultipleLocations() {
return {
data() {
return {
Expand All @@ -65,6 +71,29 @@ export function FTVA() {
}
}

export function FTVAOneLocation() {
return {
data() {
return {
data: mockEventDetailData,
}
},
provide() {
return {
theme: computed(() => 'ftva'),
}
},
components: { BlockEventDetail },
template: `
<block-event-detail
:startDate="data.startDateWithTime"
:time="data.startDateWithTime"
:locations="[data.location[0]]"
/>
`,
}
}

export function FtvaNoLocation() {
return {
data() {
Expand Down

1 comment on commit b998ab6

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