2022-07-12 08:55:28 +00:00
|
|
|
<template>
|
|
|
|
<div class="container mx-auto py-4 md:py-12 px-2 md:px-60">
|
|
|
|
<main>
|
2022-10-11 15:48:37 +00:00
|
|
|
<h1>{{ t("Category list") }}</h1>
|
|
|
|
<div
|
|
|
|
class="flex flex-wrap items-center justify-center gap-3 md:gap-4"
|
|
|
|
v-if="promotedCategories.length > 0"
|
|
|
|
>
|
2022-07-12 08:55:28 +00:00
|
|
|
<CategoryCard
|
|
|
|
v-for="category in promotedCategories"
|
|
|
|
:key="category.key"
|
|
|
|
:category="category"
|
|
|
|
:with-details="true"
|
|
|
|
/>
|
|
|
|
</div>
|
2022-10-11 12:59:13 +00:00
|
|
|
<div v-else>
|
|
|
|
<EmptyContent icon="image" :inline="true">
|
2022-10-11 15:48:37 +00:00
|
|
|
{{
|
|
|
|
t(
|
|
|
|
"No categories with public upcoming events on this instance were found."
|
|
|
|
)
|
|
|
|
}}
|
2022-10-11 12:59:13 +00:00
|
|
|
</EmptyContent>
|
|
|
|
</div>
|
2022-07-12 08:55:28 +00:00
|
|
|
|
|
|
|
<div
|
|
|
|
class="mx-auto w-full max-w-lg rounded-2xl dark:bg-gray-800 p-2 mt-10"
|
|
|
|
>
|
2022-10-11 15:48:37 +00:00
|
|
|
<o-collapse
|
|
|
|
v-model:open="isLicencePanelOpen"
|
|
|
|
:aria-id="'contentIdForA11y5'"
|
|
|
|
>
|
|
|
|
<template #trigger>
|
|
|
|
<o-button
|
|
|
|
aria-controls="contentIdForA11y1"
|
|
|
|
:icon-right="isLicencePanelOpen ? 'chevron-up' : 'chevron-down'"
|
|
|
|
>
|
|
|
|
{{ t("Category illustrations credits") }}
|
|
|
|
</o-button>
|
|
|
|
</template>
|
|
|
|
<div class="flex flex-col dark:text-zinc-300 gap-2 py-4 px-1">
|
2022-07-12 08:55:28 +00:00
|
|
|
<p
|
|
|
|
v-for="(categoryLicence, key) in categoriesPicturesLicences"
|
|
|
|
:key="key"
|
|
|
|
class="flex flex-row gap-1 items-center"
|
|
|
|
>
|
|
|
|
<a
|
|
|
|
:href="categoryLicence.source.url"
|
|
|
|
target="_blank"
|
|
|
|
class="shrink-0"
|
|
|
|
>
|
|
|
|
<picture class="brightness-50">
|
|
|
|
<source
|
2022-08-12 14:40:04 +00:00
|
|
|
:srcset="`/img/categories/${key.toLowerCase()}.webp 2x, /img/categories/${key.toLowerCase()}.webp`"
|
2022-07-12 08:55:28 +00:00
|
|
|
media="(min-width: 1000px)"
|
|
|
|
/>
|
|
|
|
<source
|
2022-08-12 14:40:04 +00:00
|
|
|
:srcset="`/img/categories/${key.toLowerCase()}.webp 2x, /img/categories/${key.toLowerCase()}-small.webp`"
|
2022-07-12 08:55:28 +00:00
|
|
|
media="(min-width: 300px)"
|
|
|
|
/>
|
|
|
|
<img
|
2022-10-05 10:13:19 +00:00
|
|
|
loading="lazy"
|
2022-07-12 08:55:28 +00:00
|
|
|
class="w-full h-12 w-12 object-cover"
|
2022-08-12 14:40:04 +00:00
|
|
|
:src="`/img/categories/${key.toLowerCase()}.webp`"
|
|
|
|
:srcset="`/img/categories/${key.toLowerCase()}-small.webp `"
|
2022-07-12 08:55:28 +00:00
|
|
|
alt=""
|
|
|
|
/>
|
|
|
|
</picture>
|
|
|
|
</a>
|
|
|
|
<span
|
|
|
|
class="flex-0"
|
|
|
|
v-html="
|
|
|
|
t(
|
|
|
|
'Illustration picture for “{category}” by {author} on {source} ({license})',
|
|
|
|
{
|
|
|
|
category: eventCategoryLabel(key),
|
|
|
|
author: imageAuthor(categoryLicence.author),
|
|
|
|
source: imageSource(categoryLicence.source),
|
|
|
|
license: imageLicense(categoryLicence),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
"
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
</div>
|
2022-10-11 15:48:37 +00:00
|
|
|
</o-collapse>
|
2022-07-12 08:55:28 +00:00
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import CategoryCard from "@/components/Categories/CategoryCard.vue";
|
|
|
|
|
|
|
|
import { computed, ref } from "vue";
|
|
|
|
import { CATEGORY_STATISTICS } from "@/graphql/statistics";
|
|
|
|
import { useQuery } from "@vue/apollo-composable";
|
|
|
|
import { CategoryStatsModel } from "@/types/stats.model";
|
|
|
|
import {
|
|
|
|
categoriesPicturesLicences,
|
|
|
|
CategoryPictureLicencing,
|
|
|
|
CategoryPictureLicencingElement,
|
|
|
|
} from "@/components/Categories/constants";
|
|
|
|
import { useI18n } from "vue-i18n";
|
2022-08-26 14:08:58 +00:00
|
|
|
import { useEventCategories } from "@/composition/apollo/config";
|
2022-10-11 12:59:13 +00:00
|
|
|
import EmptyContent from "@/components/Utils/EmptyContent.vue";
|
2023-01-27 14:48:48 +00:00
|
|
|
import { useHead } from "@vueuse/head";
|
2022-07-12 08:55:28 +00:00
|
|
|
|
|
|
|
const { t } = useI18n({ useScope: "global" });
|
|
|
|
|
2022-08-26 14:08:58 +00:00
|
|
|
const { eventCategories } = useEventCategories();
|
2022-07-12 08:55:28 +00:00
|
|
|
|
|
|
|
const eventCategoryLabel = (categoryId: string): string | undefined => {
|
2022-08-26 14:08:58 +00:00
|
|
|
return eventCategories.value?.find(({ id }) => categoryId == id)?.label;
|
2022-07-12 08:55:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const { result: categoryStatsResult } = useQuery<{
|
|
|
|
categoryStatistics: CategoryStatsModel[];
|
|
|
|
}>(CATEGORY_STATISTICS);
|
|
|
|
const categoryStats = computed(
|
|
|
|
() => categoryStatsResult.value?.categoryStatistics ?? []
|
|
|
|
);
|
|
|
|
|
|
|
|
const promotedCategories = computed((): CategoryStatsModel[] => {
|
|
|
|
return categoryStats.value
|
|
|
|
.map(({ key, number }) => ({
|
|
|
|
key,
|
|
|
|
number,
|
2022-08-26 14:08:58 +00:00
|
|
|
label: eventCategoryLabel(key) as string,
|
2022-07-12 08:55:28 +00:00
|
|
|
}))
|
|
|
|
.filter(
|
|
|
|
({ key, number, label }) =>
|
|
|
|
key !== "MEETING" && number >= 1 && label !== undefined
|
|
|
|
)
|
|
|
|
.sort((a, b) => a.label.localeCompare(b.label));
|
|
|
|
});
|
|
|
|
|
|
|
|
const imageAuthor = (author: CategoryPictureLicencingElement) =>
|
|
|
|
`<a target="_blank" class="underline font-medium" href="${author?.url}">${author?.name}</a>`;
|
|
|
|
const imageSource = (source: CategoryPictureLicencingElement) =>
|
|
|
|
`<a target="_blank" class="underline font-medium" href="${source?.url}">${source?.name}</a>`;
|
|
|
|
|
|
|
|
const imageLicense = (categoryLicence: CategoryPictureLicencing): string => {
|
|
|
|
let license = categoryLicence?.license;
|
|
|
|
if (categoryLicence?.source?.name === "Unsplash") {
|
|
|
|
license = {
|
|
|
|
name: "Unsplash License",
|
|
|
|
url: "https://unsplash.com/license",
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return `<a target="_blank" class="underline font-medium" href="${license?.url}">${license?.name}</a>`;
|
|
|
|
};
|
|
|
|
|
|
|
|
const isLicencePanelOpen = ref(false);
|
2023-01-27 14:48:48 +00:00
|
|
|
|
|
|
|
useHead({
|
|
|
|
title: computed(() => t("Category list")),
|
|
|
|
});
|
2022-07-12 08:55:28 +00:00
|
|
|
</script>
|