-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add More Artworks By Artist to resource detail panel
This commit adds artworks related to the same artist to given artwork detail panels. It populates these related galleries using a mix of prefetched and on-demand data from the arches API.
- Loading branch information
1 parent
3986f8d
commit 82d5f41
Showing
11 changed files
with
255 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,8 @@ | |
.v-leave-to { | ||
opacity: 0; | ||
} | ||
|
||
.resource-link { | ||
text-decoration: underline; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<template> | ||
<div v-if="artist" class="more-artworks-by-artist-title"> | ||
More artwork by | ||
<span class="resource-link" @click="setActiveResource(artist.resourceinstanceid)">{{ | ||
artist.displayname | ||
}}</span> | ||
</div> | ||
<div v-if="relatedArtworks" class="more-artworks-by-artist-gallery"> | ||
<MoreArtworksByArtistItem | ||
v-for="artwork in relatedArtworks" | ||
:key="artwork.resourceinstanceid" | ||
:artwork="artwork" | ||
:image-tile-data=" | ||
getImageTileDataForResource( | ||
artwork, | ||
props.imagesPrefetch, | ||
props.resourceRelationsPrefetch, | ||
props.idReferences | ||
) | ||
" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { | ||
ApiResource, | ||
ApiResourceRelation, | ||
Resource, | ||
Prefetch, | ||
ResourceXResource, | ||
Tile, | ||
ImageTileData | ||
} from '@/types'; | ||
import { useResourceStore } from '@/stores/resourceStore'; | ||
import MoreArtworksByArtistItem from './MoreArtworksByArtistItem.vue'; | ||
import { getImageTileDataForResource, getMoreArtworksByArtist } from '@/utils'; | ||
const props = defineProps<{ | ||
resource: ApiResource; | ||
resourcesPrefetch: Array<Resource>; | ||
resourceRelations: Array<ApiResourceRelation>; | ||
idReferences: Prefetch['idReferences']; | ||
resourceRelationsPrefetch: Array<ResourceXResource>; | ||
imagesPrefetch: Array<Tile<ImageTileData[]>>; | ||
}>(); | ||
const resourceStore = useResourceStore(); | ||
const artist = props.resourceRelations.find( | ||
(resource) => props.idReferences.graphIdToNameTable[resource.graph_id] === 'Artist' | ||
); | ||
const relatedArtworks = artist | ||
? getMoreArtworksByArtist( | ||
artist, | ||
props.resourcesPrefetch, | ||
props.resourceRelationsPrefetch, | ||
props.idReferences | ||
) | ||
: undefined; | ||
const setActiveResource = (newResourceId: string) => { | ||
resourceStore.$patch({ | ||
resourceId: newResourceId | ||
}); | ||
}; | ||
</script> | ||
<style scoped> | ||
.more-artworks-by-artist-title { | ||
font-family: 'Inter'; | ||
font-style: normal; | ||
font-weight: 700; | ||
font-size: 16px; | ||
line-height: 100%; | ||
color: #000000; | ||
} | ||
.more-artworks-by-artist-gallery { | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
align-items: flex-start; | ||
align-content: flex-start; | ||
padding: 0px; | ||
gap: 16px; | ||
isolation: isolate; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<template> | ||
<div @click="setActiveResource(props.artwork.resourceinstanceid)"> | ||
<img | ||
v-if="imageUrl" | ||
:class="`more-artwork-image ${resourceStore.resourceId === props.artwork.resourceinstanceid ? 'blocked' : ''}`" | ||
loading="lazy" | ||
:src="imageUrl" | ||
alt="thumbnail image" | ||
/> | ||
<img | ||
v-else | ||
:class="`more-artwork-image ${resourceStore.resourceId === props.artwork.resourceinstanceid ? 'blocked' : ''}`" | ||
:src="isProd ? '/archesdataviewer/noimage.png' : '/noimage.png'" | ||
alt="no image available" | ||
loading="lazy" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useResourceStore } from '@/stores/resourceStore'; | ||
import type { ImageTileData, Resource } from '@/types'; | ||
const resourceStore = useResourceStore(); | ||
const props = defineProps<{ | ||
artwork: Resource; | ||
imageTileData: ImageTileData[] | undefined; | ||
}>(); | ||
console.log(props.artwork); | ||
const isProd = import.meta.env.PROD; | ||
const imageUrl = props.imageTileData | ||
? import.meta.env.VITE_ARCHES_API_URL + props.imageTileData[0].url | ||
: undefined; | ||
const setActiveResource = (newResourceId: string) => { | ||
resourceStore.$patch({ | ||
resourceId: newResourceId | ||
}); | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.more-artwork-image { | ||
width: 150px; | ||
height: 150px; | ||
object-fit: cover; | ||
flex-shrink: 0; | ||
cursor: pointer; | ||
} | ||
.more-artwork-image:hover { | ||
opacity: 0.5; | ||
} | ||
.blocked { | ||
filter: brightness(50%); | ||
pointer-events: none; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.