feat: [3/6]: add basic piefed event UI
This commit is contained in:
5 files changed
+114
-18
No files matched your search
@@ -0,0 +1,91 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { Post, PostEvent } from '$lib/api/types'
|
||||||
|
import { locale, t } from '$lib/app/i18n'
|
||||||
|
import Blobs from '$lib/ui/generic/Blobs.svelte'
|
||||||
|
import { publishedToDate } from '$lib/ui/util/date'
|
||||||
|
import RelativeDate from '$lib/ui/util/RelativeDate.svelte'
|
||||||
|
import { Material } from 'mono-svelte'
|
||||||
|
import {
|
||||||
|
Calendar,
|
||||||
|
Clock,
|
||||||
|
CurrencyDollar,
|
||||||
|
Icon,
|
||||||
|
MapPin,
|
||||||
|
} from 'svelte-hero-icons/dist'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
post: Post & { event: PostEvent }
|
||||||
|
}
|
||||||
|
|
||||||
|
let { post }: Props = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-2 gap-4">
|
||||||
|
<Material
|
||||||
|
rounding="2xl"
|
||||||
|
color="info"
|
||||||
|
class="relative z-0 flex flex-col overflow-hidden col-span-2"
|
||||||
|
>
|
||||||
|
<div class="-m-4 mask-b-from-0 scale-125 -z-10">
|
||||||
|
<Blobs seed={post.name} />
|
||||||
|
</div>
|
||||||
|
<h3 class="font-display text-3xl tracking-tight">
|
||||||
|
{post.name}
|
||||||
|
</h3>
|
||||||
|
</Material>
|
||||||
|
{#if post.event.start}
|
||||||
|
{@const startDate = publishedToDate(post.event.start)}
|
||||||
|
<Material rounding="2xl" color="info" class="space-y-1">
|
||||||
|
<Icon src={Calendar} size="20" mini />
|
||||||
|
<h4 class="capitalize text-xl font-display">
|
||||||
|
<date>
|
||||||
|
{startDate.toLocaleDateString($locale, {
|
||||||
|
dateStyle: 'long',
|
||||||
|
})}
|
||||||
|
</date>
|
||||||
|
</h4>
|
||||||
|
<RelativeDate options={{ style: 'long' }} date={startDate} />
|
||||||
|
</Material>
|
||||||
|
<Material rounding="2xl" color="info" class="space-y-1">
|
||||||
|
<Icon src={Clock} size="20" mini />
|
||||||
|
<h4 class="capitalize text-xl font-display">
|
||||||
|
<time>
|
||||||
|
{startDate.toLocaleTimeString($locale, {
|
||||||
|
timeStyle: 'long',
|
||||||
|
})}
|
||||||
|
</time>
|
||||||
|
</h4>
|
||||||
|
<time>
|
||||||
|
{startDate.toLocaleTimeString($locale, {
|
||||||
|
timeZone: 'GMT',
|
||||||
|
timeStyle: 'long',
|
||||||
|
})}
|
||||||
|
</time>
|
||||||
|
</Material>
|
||||||
|
{/if}
|
||||||
|
{#if post.event.event_fee_amount}
|
||||||
|
<Material rounding="2xl" color="info" class="space-y-1">
|
||||||
|
<Icon src={CurrencyDollar} size="20" mini />
|
||||||
|
<h5 class="capitalize text-lg font-display">
|
||||||
|
{post.event.event_fee_amount}
|
||||||
|
{post.event.event_fee_currency ?? ''}
|
||||||
|
</h5>
|
||||||
|
</Material>
|
||||||
|
{/if}
|
||||||
|
{#if post.event.location && Object.keys(post.event.location).length > 0}
|
||||||
|
<Material rounding="2xl" color="info" class="space-y-1">
|
||||||
|
<Icon src={MapPin} size="20" mini />
|
||||||
|
<h4 class="capitalize text-xl font-display">
|
||||||
|
{$t('filter.location.label')}
|
||||||
|
</h4>
|
||||||
|
<dl class="space-y-2">
|
||||||
|
{#each Object.keys(post.event.location) as key}
|
||||||
|
<div class="flex flex-row justify-between flex-wrap">
|
||||||
|
<dt class="capitalize font-medium">{key}</dt>
|
||||||
|
<dd>{post.event.location[key]}</dd>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</dl>
|
||||||
|
</Material>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
import { settings, type View } from '$lib/app/settings.svelte'
|
import { settings, type View } from '$lib/app/settings.svelte'
|
||||||
import { PostIframe, PostImage, PostLink } from '..'
|
import { PostIframe, PostImage, PostLink } from '..'
|
||||||
import { iframeType, type MediaType } from '../helpers'
|
import { iframeType, type MediaType } from '../helpers'
|
||||||
|
import PostEvent from './PostEvent.svelte'
|
||||||
import PostPoll from './PostPoll.svelte'
|
import PostPoll from './PostPoll.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -41,6 +42,10 @@
|
|||||||
title={post.name}
|
title={post.name}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
|
{:else if type == 'poll' && post.poll && view == 'cozy'}
|
||||||
|
<PostPoll post={{ ...post, poll: post.poll! }} />
|
||||||
|
{:else if type == 'event' && post.event && view == 'cozy'}
|
||||||
|
<PostEvent post={{ ...post, event: post.event! }} />
|
||||||
{:else if type == 'embed' && post.url}
|
{:else if type == 'embed' && post.url}
|
||||||
<PostLink
|
<PostLink
|
||||||
url={post.url}
|
url={post.url}
|
||||||
@@ -50,6 +55,4 @@
|
|||||||
{view}
|
{view}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
{:else if type == 'poll' && post.poll}
|
|
||||||
<PostPoll post={{ ...post, poll: post.poll! }} />
|
|
||||||
{/if}
|
{/if}
|
||||||
@@ -5,11 +5,13 @@
|
|||||||
import { showImage } from '$lib/ui/generic/ExpandableImage.svelte'
|
import { showImage } from '$lib/ui/generic/ExpandableImage.svelte'
|
||||||
import { Button, modal } from 'mono-svelte'
|
import { Button, modal } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
|
Calendar,
|
||||||
DocumentText,
|
DocumentText,
|
||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
Icon,
|
Icon,
|
||||||
Link,
|
Link,
|
||||||
Photo,
|
Photo,
|
||||||
|
PresentationChartBar,
|
||||||
VideoCamera,
|
VideoCamera,
|
||||||
} from 'svelte-hero-icons/dist'
|
} from 'svelte-hero-icons/dist'
|
||||||
import { bestImageURL, postLink, type MediaType } from '../helpers'
|
import { bestImageURL, postLink, type MediaType } from '../helpers'
|
||||||
@@ -109,21 +111,19 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
|
{@const typeIconMap = new Map([
|
||||||
|
['embed', Link],
|
||||||
|
['iframe', VideoCamera],
|
||||||
|
['poll', PresentationChartBar],
|
||||||
|
['event', Calendar],
|
||||||
|
])}
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
'bg-slate-100 dark:bg-zinc-900 w-full h-full rounded-xl grid place-items-center',
|
'bg-slate-100 dark:bg-zinc-900 w-full h-full rounded-xl grid place-items-center',
|
||||||
'text-slate-600 dark:text-zinc-400',
|
'text-slate-600 dark:text-zinc-400',
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon src={typeIconMap.get(type) ?? DocumentText} solid size="32" />
|
||||||
src={type == 'embed'
|
|
||||||
? Link
|
|
||||||
: type == 'iframe'
|
|
||||||
? VideoCamera
|
|
||||||
: DocumentText}
|
|
||||||
solid
|
|
||||||
size="32"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -40,11 +40,10 @@
|
|||||||
distinct: 'material-distinct',
|
distinct: 'material-distinct',
|
||||||
transparent: 'material-transparent',
|
transparent: 'material-transparent',
|
||||||
uniform: 'material-uniform',
|
uniform: 'material-uniform',
|
||||||
none: '',
|
info: 'material-info',
|
||||||
}
|
warning: 'material-warning',
|
||||||
|
success: 'material-success',
|
||||||
const interactiveClass = {
|
error: 'material-error',
|
||||||
interactive: 'material-int',
|
|
||||||
none: '',
|
none: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
options: Intl.RelativeTimeFormatOptions,
|
options: Intl.RelativeTimeFormatOptions,
|
||||||
locale?: string,
|
locale?: string,
|
||||||
relativeTo?: Date,
|
relativeTo?: Date,
|
||||||
|
absolute?: boolean,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const now = relativeTo?.getTime() ?? Date.now()
|
const now = relativeTo?.getTime() ?? Date.now()
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
|
|
||||||
let language = locale ?? 'en'
|
let language = locale ?? 'en'
|
||||||
|
|
||||||
if (settings.absoluteDates) {
|
if (absolute) {
|
||||||
const rtf = new Intl.DateTimeFormat(language, {
|
const rtf = new Intl.DateTimeFormat(language, {
|
||||||
...options,
|
...options,
|
||||||
timeStyle: 'short',
|
timeStyle: 'short',
|
||||||
@@ -62,6 +63,7 @@
|
|||||||
date: Date
|
date: Date
|
||||||
relativeTo?: Date | undefined
|
relativeTo?: Date | undefined
|
||||||
options?: Intl.RelativeTimeFormatOptions
|
options?: Intl.RelativeTimeFormatOptions
|
||||||
|
absolute?: boolean
|
||||||
style?: string
|
style?: string
|
||||||
class?: string
|
class?: string
|
||||||
}
|
}
|
||||||
@@ -73,6 +75,7 @@
|
|||||||
numeric: 'always',
|
numeric: 'always',
|
||||||
style: 'narrow',
|
style: 'narrow',
|
||||||
},
|
},
|
||||||
|
absolute = settings.absoluteDates,
|
||||||
style = '',
|
style = '',
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
@@ -81,5 +84,5 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<time datetime={dateTime} title={dateTime} class={clazz} {style}>
|
<time datetime={dateTime} title={dateTime} class={clazz} {style}>
|
||||||
{formatRelativeDate(date, options, $locale, relativeTo)}
|
{formatRelativeDate(date, options, $locale, relativeTo, absolute)}
|
||||||
</time>
|
</time>
|
||||||
Reference in new issue
Block a user