diff --git a/src/lib/feature/post/media/PostEvent.svelte b/src/lib/feature/post/media/PostEvent.svelte new file mode 100644 index 00000000..2a280746 --- /dev/null +++ b/src/lib/feature/post/media/PostEvent.svelte @@ -0,0 +1,91 @@ + + +
+ +
+ +
+

+ {post.name} +

+
+ {#if post.event.start} + {@const startDate = publishedToDate(post.event.start)} + + +

+ + {startDate.toLocaleDateString($locale, { + dateStyle: 'long', + })} + +

+ +
+ + +

+ +

+ +
+ {/if} + {#if post.event.event_fee_amount} + + +
+ {post.event.event_fee_amount} + {post.event.event_fee_currency ?? ''} +
+
+ {/if} + {#if post.event.location && Object.keys(post.event.location).length > 0} + + +

+ {$t('filter.location.label')} +

+
+ {#each Object.keys(post.event.location) as key} +
+
{key}
+
{post.event.location[key]}
+
+ {/each} +
+
+ {/if} +
diff --git a/src/lib/feature/post/media/PostMedia.svelte b/src/lib/feature/post/media/PostMedia.svelte index 01461aa3..3cc9f84d 100644 --- a/src/lib/feature/post/media/PostMedia.svelte +++ b/src/lib/feature/post/media/PostMedia.svelte @@ -3,6 +3,7 @@ import { settings, type View } from '$lib/app/settings.svelte' import { PostIframe, PostImage, PostLink } from '..' import { iframeType, type MediaType } from '../helpers' + import PostEvent from './PostEvent.svelte' import PostPoll from './PostPoll.svelte' interface Props { @@ -41,6 +42,10 @@ title={post.name} {...rest} /> +{:else if type == 'poll' && post.poll && view == 'cozy'} + +{:else if type == 'event' && post.event && view == 'cozy'} + {:else if type == 'embed' && post.url} -{:else if type == 'poll' && post.poll} - {/if} diff --git a/src/lib/feature/post/media/PostMediaCompact.svelte b/src/lib/feature/post/media/PostMediaCompact.svelte index 9c155b5e..7fa2dea5 100644 --- a/src/lib/feature/post/media/PostMediaCompact.svelte +++ b/src/lib/feature/post/media/PostMediaCompact.svelte @@ -5,11 +5,13 @@ import { showImage } from '$lib/ui/generic/ExpandableImage.svelte' import { Button, modal } from 'mono-svelte' import { + Calendar, DocumentText, ExclamationTriangle, Icon, Link, Photo, + PresentationChartBar, VideoCamera, } from 'svelte-hero-icons/dist' import { bestImageURL, postLink, type MediaType } from '../helpers' @@ -109,21 +111,19 @@ {/if} {:else} + {@const typeIconMap = new Map([ + ['embed', Link], + ['iframe', VideoCamera], + ['poll', PresentationChartBar], + ['event', Calendar], + ])}
- +
{/if} diff --git a/src/lib/ui/shared/materials/Material.svelte b/src/lib/ui/shared/materials/Material.svelte index cfe2d642..911e39e4 100644 --- a/src/lib/ui/shared/materials/Material.svelte +++ b/src/lib/ui/shared/materials/Material.svelte @@ -40,11 +40,10 @@ distinct: 'material-distinct', transparent: 'material-transparent', uniform: 'material-uniform', - none: '', - } - - const interactiveClass = { - interactive: 'material-int', + info: 'material-info', + warning: 'material-warning', + success: 'material-success', + error: 'material-error', none: '', } diff --git a/src/lib/ui/util/RelativeDate.svelte b/src/lib/ui/util/RelativeDate.svelte index 4776cbd1..45ecfa5c 100644 --- a/src/lib/ui/util/RelativeDate.svelte +++ b/src/lib/ui/util/RelativeDate.svelte @@ -7,6 +7,7 @@ options: Intl.RelativeTimeFormatOptions, locale?: string, relativeTo?: Date, + absolute?: boolean, ) { try { const now = relativeTo?.getTime() ?? Date.now() @@ -29,7 +30,7 @@ let language = locale ?? 'en' - if (settings.absoluteDates) { + if (absolute) { const rtf = new Intl.DateTimeFormat(language, { ...options, timeStyle: 'short', @@ -62,6 +63,7 @@ date: Date relativeTo?: Date | undefined options?: Intl.RelativeTimeFormatOptions + absolute?: boolean style?: string class?: string } @@ -73,6 +75,7 @@ numeric: 'always', style: 'narrow', }, + absolute = settings.absoluteDates, style = '', class: clazz = '', }: Props = $props() @@ -81,5 +84,5 @@