fix: (somehow) make absolute work again
This commit is contained in:
1 parent
d19a90658b
commit
2bc4d19ae0
8 files changed
+148
-106
No files matched your search
@@ -14,14 +14,14 @@
|
|||||||
optionNames.set(null, 'None')
|
optionNames.set(null, 'None')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Menu rtl={false} preventDefault>
|
<Menu rtl={false} let:toggleOpen>
|
||||||
<button
|
<button
|
||||||
class="flex flex-row gap-2 items-center px-3 py-1.5 w-full text-sm
|
class="flex flex-row gap-2 items-center px-3 py-1.5 w-full text-sm
|
||||||
transition-all max-w-64 rounded-md bg-slate-100 border border-slate-200
|
transition-all max-w-64 rounded-md bg-slate-100 border border-slate-200
|
||||||
dark:bg-zinc-800 dark:border-zinc-700"
|
dark:bg-zinc-800 dark:border-zinc-700"
|
||||||
slot="button"
|
slot="button"
|
||||||
type="button"
|
type="button"
|
||||||
on:click|preventDefault
|
on:click|preventDefault={toggleOpen}
|
||||||
>
|
>
|
||||||
{optionNames.get(selected) || selected}
|
{optionNames.get(selected) || selected}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -22,35 +22,13 @@
|
|||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import Link from '$lib/components/input/Link.svelte'
|
import Link from '$lib/components/input/Link.svelte'
|
||||||
|
import PostActions from '$lib/components/lemmy/PostActions.svelte'
|
||||||
|
|
||||||
let postRes: PostView
|
let postRes: PostView
|
||||||
export { postRes as post }
|
export { postRes as post }
|
||||||
|
|
||||||
async function deletePost() {
|
|
||||||
if (!$authData) return
|
|
||||||
|
|
||||||
await getClient().deletePost({
|
|
||||||
auth: $authData.token,
|
|
||||||
deleted: true,
|
|
||||||
post_id: postRes.post.id,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function youtubeToPiped(url: string): string {
|
|
||||||
const youtubeDomainsRegex =
|
|
||||||
/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\//i
|
|
||||||
|
|
||||||
if (youtubeDomainsRegex.test(url)) {
|
|
||||||
return url
|
|
||||||
.replace(youtubeDomainsRegex, '$1$2invidious.io.lol/')
|
|
||||||
.replace('www.', '')
|
|
||||||
}
|
|
||||||
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card class="bg-white flex flex-col overflow-hidden w-full relative p-5 gap-2">
|
<Card class="bg-white flex flex-col w-full p-5 gap-2">
|
||||||
<span class="flex flex-row gap-2 text-xs items-center">
|
<span class="flex flex-row gap-2 text-xs items-center">
|
||||||
<Avatar
|
<Avatar
|
||||||
url={postRes.community.icon}
|
url={postRes.community.icon}
|
||||||
@@ -120,38 +98,5 @@
|
|||||||
{postRes.post.body}
|
{postRes.post.body}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex flex-row gap-2 items-center pt-2">
|
<PostActions post={postRes} />
|
||||||
<PostVote
|
|
||||||
post={postRes.post}
|
|
||||||
vote={postRes.my_vote}
|
|
||||||
score={postRes.counts.score}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Link color={Color.border} href="/post/{getInstance()}/{postRes.post.id}">
|
|
||||||
<Icon slot="icon" src={ChatBubbleOvalLeft} mini width={16} height={16} />
|
|
||||||
<FormattedNumber number={postRes.counts.comments} />
|
|
||||||
</Link>
|
|
||||||
<Menu top absolute class="bottom-0 right-0 m-5 z-10">
|
|
||||||
<Button slot="button" label="Post actions">
|
|
||||||
<Icon src={EllipsisHorizontal} width={16} mini />
|
|
||||||
</Button>
|
|
||||||
<span class="mx-4 text-xs opacity-80 text-left my-2">Post Actions</span>
|
|
||||||
<MenuButton
|
|
||||||
on:click={() => {
|
|
||||||
navigator.clipboard.writeText(
|
|
||||||
`${$page.url.origin}/post/${getInstance()}/${postRes.post.id}`
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon src={Square2Stack} width={16} mini />
|
|
||||||
Copy Link
|
|
||||||
</MenuButton>
|
|
||||||
{#if $user?.person.id == postRes.post.creator_id}
|
|
||||||
<MenuButton on:click={deletePost} color={Color.dangerSecondary}>
|
|
||||||
<Icon src={Trash} width={16} mini />
|
|
||||||
Delete
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
|
||||||
</Menu>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { PostView } from 'lemmy-js-client'
|
||||||
|
import PostVote from './PostVote.svelte'
|
||||||
|
import { getClient, getInstance } from '$lib/lemmy.js'
|
||||||
|
import { Color } from '$lib/ui/colors.js'
|
||||||
|
import Link from '$lib/components/input/Link.svelte'
|
||||||
|
import {
|
||||||
|
ChatBubbleOvalLeft,
|
||||||
|
EllipsisHorizontal,
|
||||||
|
Icon,
|
||||||
|
Newspaper,
|
||||||
|
Square2Stack,
|
||||||
|
Trash,
|
||||||
|
UserCircle,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
|
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||||
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
|
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||||
|
import { page } from '$app/stores'
|
||||||
|
import { user, authData } from '$lib/lemmy.js'
|
||||||
|
|
||||||
|
export let post: PostView
|
||||||
|
|
||||||
|
async function deletePost() {
|
||||||
|
if (!$authData) return
|
||||||
|
|
||||||
|
await getClient().deletePost({
|
||||||
|
auth: $authData.token,
|
||||||
|
deleted: true,
|
||||||
|
post_id: post.post.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function youtubeToPiped(url: string): string {
|
||||||
|
const youtubeDomainsRegex =
|
||||||
|
/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\//i
|
||||||
|
|
||||||
|
if (youtubeDomainsRegex.test(url)) {
|
||||||
|
return url
|
||||||
|
.replace(youtubeDomainsRegex, '$1$2invidious.io.lol/')
|
||||||
|
.replace('www.', '')
|
||||||
|
}
|
||||||
|
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex flex-row gap-2 items-center pt-2 z-50">
|
||||||
|
<PostVote post={post.post} vote={post.my_vote} score={post.counts.score} />
|
||||||
|
|
||||||
|
<Link color={Color.border} href="/post/{getInstance()}/{post.post.id}">
|
||||||
|
<Icon slot="icon" src={ChatBubbleOvalLeft} mini width={16} height={16} />
|
||||||
|
<FormattedNumber number={post.counts.comments} />
|
||||||
|
</Link>
|
||||||
|
<Menu top class="ml-auto overflow-auto" let:toggleOpen>
|
||||||
|
<Button slot="button" label="Post actions" on:click={toggleOpen}>
|
||||||
|
<Icon src={EllipsisHorizontal} width={16} mini />
|
||||||
|
</Button>
|
||||||
|
<span class="mx-4 text-xs opacity-80 text-left my-2">Creator</span>
|
||||||
|
<MenuButton
|
||||||
|
link
|
||||||
|
href="/u/{post.creator.name}@{new URL(post.creator.actor_id).hostname}"
|
||||||
|
>
|
||||||
|
<Icon src={UserCircle} width={16} mini />
|
||||||
|
<span>{post.creator.name}</span>
|
||||||
|
</MenuButton>
|
||||||
|
<MenuButton
|
||||||
|
link
|
||||||
|
href="/c/{post.community.name}@{new URL(post.community.actor_id)
|
||||||
|
.hostname}"
|
||||||
|
>
|
||||||
|
<Icon src={Newspaper} width={16} mini />
|
||||||
|
<span>{post.community.title}</span>
|
||||||
|
</MenuButton>
|
||||||
|
<hr class="w-[90%] mx-auto opacity-10 my-2" />
|
||||||
|
<span class="mx-4 text-xs opacity-80 text-left my-2">Actions</span>
|
||||||
|
<MenuButton
|
||||||
|
on:click={() => {
|
||||||
|
navigator.clipboard.writeText(
|
||||||
|
`${$page.url.origin}/post/${getInstance()}/${post.post.id}`
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon src={Square2Stack} width={16} mini />
|
||||||
|
Copy Link
|
||||||
|
</MenuButton>
|
||||||
|
{#if $user?.person.id == post.post.creator_id}
|
||||||
|
<MenuButton on:click={deletePost} color={Color.dangerSecondary}>
|
||||||
|
<Icon src={Trash} width={16} mini />
|
||||||
|
Delete
|
||||||
|
</MenuButton>
|
||||||
|
{/if}
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
@@ -45,7 +45,11 @@
|
|||||||
line-height: initial;
|
line-height: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.markdown :global(il) {
|
||||||
|
@apply my-1;
|
||||||
|
}
|
||||||
|
|
||||||
.markdown :global(blockquote) {
|
.markdown :global(blockquote) {
|
||||||
@apply border-l-2 border-black/20 dark:border-white/20 pl-2 my-1;
|
@apply border-l-2 border-black/20 dark:border-white/20 pl-2 my-1 h-max;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -28,10 +28,10 @@
|
|||||||
|
|
||||||
<nav
|
<nav
|
||||||
class="sticky bg-slate-50/70 dark:bg-zinc-950/70 backdrop-blur-3xl top-0
|
class="sticky bg-slate-50/70 dark:bg-zinc-950/70 backdrop-blur-3xl top-0
|
||||||
z-50 mt-2"
|
z-50"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="flex z-20 flex-row gap-4 items-center w-full h-16 max-w-5xl mx-auto px-6"
|
class="flex z-20 flex-row gap-4 items-center w-full h-16 max-w-5xl mx-auto px-6 my-1"
|
||||||
>
|
>
|
||||||
<div class="flex flex-row gap-2 items-center mr-auto">
|
<div class="flex flex-row gap-2 items-center mr-auto">
|
||||||
<a href="/" class="flex flex-row items-center gap-2">
|
<a href="/" class="flex flex-row items-center gap-2">
|
||||||
@@ -56,8 +56,13 @@
|
|||||||
<Icon src={GlobeAlt} width={16} />
|
<Icon src={GlobeAlt} width={16} />
|
||||||
<span class="hidden sm:inline ml-1">Communities</span>
|
<span class="hidden sm:inline ml-1">Communities</span>
|
||||||
</Link>
|
</Link>
|
||||||
<Menu>
|
<Menu let:toggleOpen>
|
||||||
<Button color={Color.accent} slot="button" label="Create">
|
<Button
|
||||||
|
color={Color.accent}
|
||||||
|
slot="button"
|
||||||
|
label="Create"
|
||||||
|
on:click={toggleOpen}
|
||||||
|
>
|
||||||
<Icon src={Plus} width={16} />
|
<Icon src={Plus} width={16} />
|
||||||
<span class="hidden sm:inline">Create</span>
|
<span class="hidden sm:inline">Create</span>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -68,12 +73,13 @@
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
<Menu>
|
<Menu let:toggleOpen>
|
||||||
<button
|
<button
|
||||||
class="w-8 h-8 rounded-full ring-1 ring-slate-300 bg-slate-100
|
class="w-8 h-8 rounded-full ring-1 ring-slate-300 bg-slate-100
|
||||||
dark:bg-zinc-800 relative"
|
dark:bg-zinc-800 relative"
|
||||||
aria-label="Profile"
|
aria-label="Profile"
|
||||||
slot="button"
|
slot="button"
|
||||||
|
on:click={toggleOpen}
|
||||||
>
|
>
|
||||||
{#if $user}
|
{#if $user}
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -15,32 +15,25 @@
|
|||||||
|
|
||||||
let element: any
|
let element: any
|
||||||
|
|
||||||
export let preventDefault = false
|
export const toggleOpen = () => (open = !open)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:body
|
<svelte:body
|
||||||
on:click={(event) => {
|
on:click={(e) => {
|
||||||
if (open) {
|
if (!element.contains(e.target)) {
|
||||||
let path = event.composedPath()
|
open = false
|
||||||
|
|
||||||
if (!path.includes(element)) {
|
|
||||||
open = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<button
|
|
||||||
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
|
<div
|
||||||
class="overflow-visible z-30 {absolute
|
class="overflow-visible z-30 {absolute
|
||||||
? 'absolute'
|
? 'absolute'
|
||||||
: 'relative'} cursor-auto {clazz}"
|
: 'relative'} cursor-auto {clazz}"
|
||||||
on:click={(e) => {
|
|
||||||
if (preventDefault) e.preventDefault()
|
|
||||||
|
|
||||||
open = !open
|
|
||||||
}}
|
|
||||||
bind:this={element}
|
bind:this={element}
|
||||||
>
|
>
|
||||||
<slot name="button" />
|
<slot name="button" {toggleOpen} />
|
||||||
{#if open}
|
{#if open}
|
||||||
<div
|
<div
|
||||||
transition:scale|local={{
|
transition:scale|local={{
|
||||||
@@ -48,7 +41,7 @@
|
|||||||
start: 0.95,
|
start: 0.95,
|
||||||
easing: expoOut,
|
easing: expoOut,
|
||||||
}}
|
}}
|
||||||
class="absolute max-h-64 overflow-auto {rtl
|
class="absolute max-h-64 z-30 overflow-auto {rtl
|
||||||
? 'origin-top-right right-0'
|
? 'origin-top-right right-0'
|
||||||
: 'origin-top-left left-0'}
|
: 'origin-top-left left-0'}
|
||||||
{top ? 'bottom-[100%] origin-bottom-left' : 'top-[100%]'}
|
{top ? 'bottom-[100%] origin-bottom-left' : 'top-[100%]'}
|
||||||
@@ -57,8 +50,8 @@
|
|||||||
: 'bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800'}"
|
: 'bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800'}"
|
||||||
>
|
>
|
||||||
{#if open}
|
{#if open}
|
||||||
<slot />
|
<slot {toggleOpen} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</div>
|
||||||
@@ -9,19 +9,21 @@
|
|||||||
const click = createEventDispatcher()
|
const click = createEventDispatcher()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if link}
|
<li>
|
||||||
<a
|
{#if link}
|
||||||
{href}
|
<a
|
||||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
{href}
|
||||||
>
|
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||||
<slot />
|
>
|
||||||
</a>
|
<slot />
|
||||||
{:else}
|
</a>
|
||||||
<button
|
{:else}
|
||||||
on:click={(e) => click('click', e)}
|
<button
|
||||||
type="button"
|
on:click={(e) => click('click', e)}
|
||||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
type="button"
|
||||||
>
|
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||||
<slot />
|
>
|
||||||
</button>
|
<slot />
|
||||||
{/if}
|
</button>
|
||||||
|
{/if}
|
||||||
|
</li>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
import CommunityCard from '$lib/components/community/CommunityCard.svelte'
|
import CommunityCard from '$lib/components/community/CommunityCard.svelte'
|
||||||
import Button from '$lib/components/input/Button.svelte'
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
|
import PostActions from '$lib/components/lemmy/PostActions.svelte'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
|
|
||||||
@@ -107,12 +108,8 @@
|
|||||||
<Markdown source={post.body} />
|
<Markdown source={post.body} />
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="w-max">
|
<div class="w-ful relative">
|
||||||
<PostVote
|
<PostActions post={data.post.post_view} />
|
||||||
post={data.post.post_view.post}
|
|
||||||
score={data.post.post_view.counts.score}
|
|
||||||
vote={data.post.post_view.my_vote}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4 flex flex-col gap-2">
|
<div class="mt-4 flex flex-col gap-2">
|
||||||
|
|||||||
Reference in new issue
Block a user