mizzkey/packages/frontend/src/pages/announcements.vue

93 lines
2.1 KiB
Vue
Raw Normal View History

<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
2023-05-19 09:20:53 +02:00
<MkSpacer :contentMax="800">
<MkPagination v-slot="{items, reload}" :pagination="pagination" class="ruryvtyk _gaps_m">
<section v-for="(announcement, i) in items" :key="announcement.id" :class="{ announcement: true, _panel: true, private: announcement.isPrivate }">
<div class="header"><span v-if="$i && !announcement.isRead"><span class="ti ti-speakerphone"></span></span><Mfm :text="announcement.title"/></div>
2023-01-06 01:41:14 +01:00
<div class="content">
<Mfm :text="announcement.text"/>
<img v-if="announcement.imageUrl" :src="announcement.imageUrl"/>
</div>
2023-01-06 01:41:14 +01:00
<div v-if="$i && !announcement.isRead" class="footer">
<MkButton primary @click="read(items, reload, announcement, i)"><i class="ti ti-check"></i> {{ i18n.ts.gotIt }}</MkButton>
</div>
</section>
</MkPagination>
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import MkPagination from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue';
2021-11-11 18:02:25 +01:00
import * as os from '@/os';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
2023-04-01 06:52:07 +02:00
import { $i } from '@/account';
const pagination = {
endpoint: 'announcements' as const,
offsetMode: true,
limit: 10,
};
function read(items, reload, announcement, i) {
items[i].isRead = true;
os.api('i/read-announcement', {
announcementId: announcement.id,
}).then(reload);
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.announcements,
icon: 'ti ti-speakerphone',
});
</script>
<style lang="scss" scoped>
.ruryvtyk {
> .private {
border-left: 4px solid olivedrab;
}
> .announcement {
2023-01-07 11:57:48 +01:00
padding: 16px;
2023-01-06 01:41:14 +01:00
> .header {
2023-01-07 11:57:48 +01:00
margin-bottom: 16px;
2023-01-06 01:41:14 +01:00
font-weight: bold;
2021-10-24 17:13:54 +02:00
}
2023-01-06 01:41:14 +01:00
> .content {
> img {
display: block;
max-height: 300px;
max-width: 100%;
}
}
2023-01-06 01:41:14 +01:00
> .footer {
2023-01-07 11:57:48 +01:00
margin-top: 16px;
2023-01-06 01:41:14 +01:00
}
}
}
@keyframes fade {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
</style>