Skip to content

Commit

Permalink
Add source links to creator pages
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Bulat <[email protected]>
  • Loading branch information
obulat committed Mar 11, 2024
1 parent eae8c19 commit 73ee921
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 22 deletions.
78 changes: 56 additions & 22 deletions frontend/src/components/VCollectionHeader/VCollectionHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,24 @@
>{{ $t(`collection.link.${collection}`) }}</VButton
>
<p
v-if="collectionParams.collection !== 'creator'"
class="results caption-regular md:label-regular mt-2 text-dark-charcoal-70 md:mt-0"
>
{{ resultsLabel }}
</p>

<p
v-else-if="
collectionParams.collection === 'creator' && resultsLabel.length === 2
"
class="results caption-regular md:label-regular mt-2 text-dark-charcoal-70 md:mt-0"
>
{{ resultsLabel[0]
}}<VLink :href="source.link" class="!gap-x-1" show-external-icon>{{
source.name
}}</VLink
><span v-if="resultsLabel[1]">{{ resultsLabel[1] }}</span>
</p>
</div>
</template>

Expand All @@ -48,6 +62,7 @@ import { useMediaStore } from "~/stores/media"
import VIcon from "~/components/VIcon/VIcon.vue"
import VButton from "~/components/VButton.vue"
import VLink from "~/components/VLink.vue"
const icons = {
tag: "tag",
Expand All @@ -60,7 +75,7 @@ const icons = {
*/
export default defineComponent({
name: "VCollectionHeader",
components: { VIcon, VButton },
components: { VLink, VIcon, VButton },
props: {
collectionParams: {
type: Object as PropType<CollectionParams>,
Expand All @@ -82,14 +97,23 @@ export default defineComponent({
const iconName = computed(() => icons[props.collectionParams.collection])
const collection = computed(() => props.collectionParams.collection)
const sourceName = computed(() => {
const source = computed(() => {
if (props.collectionParams.collection === "tag") {
return ""
return {
name: "",
link: "",
}
}
return {
name: providerStore.getProviderName(
props.collectionParams.source,
props.mediaType
),
link: providerStore.getSourceUrl(
props.collectionParams.source,
props.mediaType
),
}
return providerStore.getProviderName(
props.collectionParams.source,
props.mediaType
)
})
const title = computed(() => {
Expand All @@ -98,7 +122,7 @@ export default defineComponent({
} else if (props.collectionParams.collection === "creator") {
return props.collectionParams.creator
}
return sourceName.value
return source.value.name
})
const url = computed(() => {
Expand All @@ -107,10 +131,7 @@ export default defineComponent({
} else if (props.collectionParams.collection === "creator") {
return props.creatorUrl
}
return providerStore.getSourceUrl(
props.collectionParams.source,
props.mediaType
)
return source.value.link
})
const { getI18nCollectionResultCountLabel } = useI18nResultsCount()
Expand All @@ -119,19 +140,22 @@ export default defineComponent({
return ""
}
const resultsCount = mediaStore.results[props.mediaType].count
if (props.collectionParams.collection === "creator") {
return getI18nCollectionResultCountLabel(
resultsCount,
props.mediaType,
"creator",
{ source: sourceName.value }
)
}
return getI18nCollectionResultCountLabel(
const params =
props.collectionParams.collection === "creator"
? { source: source.value.name }
: undefined
const label = getI18nCollectionResultCountLabel(
resultsCount,
props.mediaType,
props.collectionParams.collection
props.collectionParams.collection,
params
)
if (props.collectionParams.collection === "creator") {
const splitLabel = label.split(source.value.name)
return splitLabel.length === 2 ? splitLabel : ["", ""]
}
return label
})
const isMd = computed(() => uiStore.isBreakpoint("md"))
Expand All @@ -157,6 +181,7 @@ export default defineComponent({
collection,
title,
resultsLabel,
source,
url,
iconName,
isMd,
Expand All @@ -167,6 +192,15 @@ export default defineComponent({
</script>

<style scoped>
@keyframes shimmer {
0% {
background-position: -1000px 0;
}
100% {
background-position: 1000px 0;
}
}
.collection-header {
grid-template-areas: "icon title" "button button" "results results";
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 73ee921

Please sign in to comment.