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')
|
||||
</script>
|
||||
|
||||
<Menu rtl={false} preventDefault>
|
||||
<Menu rtl={false} let:toggleOpen>
|
||||
<button
|
||||
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
|
||||
dark:bg-zinc-800 dark:border-zinc-700"
|
||||
slot="button"
|
||||
type="button"
|
||||
on:click|preventDefault
|
||||
on:click|preventDefault={toggleOpen}
|
||||
>
|
||||
{optionNames.get(selected) || selected}
|
||||
</button>
|
||||
|
||||
@@ -22,35 +22,13 @@
|
||||
import { page } from '$app/stores'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import PostActions from '$lib/components/lemmy/PostActions.svelte'
|
||||
|
||||
let postRes: PostView
|
||||
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>
|
||||
|
||||
<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">
|
||||
<Avatar
|
||||
url={postRes.community.icon}
|
||||
@@ -120,38 +98,5 @@
|
||||
{postRes.post.body}
|
||||
</p>
|
||||
{/if}
|
||||
<div class="flex flex-row gap-2 items-center pt-2">
|
||||
<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>
|
||||
<PostActions post={postRes} />
|
||||
</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;
|
||||
}
|
||||
|
||||
.markdown :global(il) {
|
||||
@apply my-1;
|
||||
}
|
||||
|
||||
.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>
|
||||
@@ -28,10 +28,10 @@
|
||||
|
||||
<nav
|
||||
class="sticky bg-slate-50/70 dark:bg-zinc-950/70 backdrop-blur-3xl top-0
|
||||
z-50 mt-2"
|
||||
z-50"
|
||||
>
|
||||
<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">
|
||||
<a href="/" class="flex flex-row items-center gap-2">
|
||||
@@ -56,8 +56,13 @@
|
||||
<Icon src={GlobeAlt} width={16} />
|
||||
<span class="hidden sm:inline ml-1">Communities</span>
|
||||
</Link>
|
||||
<Menu>
|
||||
<Button color={Color.accent} slot="button" label="Create">
|
||||
<Menu let:toggleOpen>
|
||||
<Button
|
||||
color={Color.accent}
|
||||
slot="button"
|
||||
label="Create"
|
||||
on:click={toggleOpen}
|
||||
>
|
||||
<Icon src={Plus} width={16} />
|
||||
<span class="hidden sm:inline">Create</span>
|
||||
</Button>
|
||||
@@ -68,12 +73,13 @@
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
</div>
|
||||
<Menu>
|
||||
<Menu let:toggleOpen>
|
||||
<button
|
||||
class="w-8 h-8 rounded-full ring-1 ring-slate-300 bg-slate-100
|
||||
dark:bg-zinc-800 relative"
|
||||
aria-label="Profile"
|
||||
slot="button"
|
||||
on:click={toggleOpen}
|
||||
>
|
||||
{#if $user}
|
||||
<img
|
||||
|
||||
@@ -15,32 +15,25 @@
|
||||
|
||||
let element: any
|
||||
|
||||
export let preventDefault = false
|
||||
export const toggleOpen = () => (open = !open)
|
||||
</script>
|
||||
|
||||
<svelte:body
|
||||
on:click={(event) => {
|
||||
if (open) {
|
||||
let path = event.composedPath()
|
||||
|
||||
if (!path.includes(element)) {
|
||||
open = false
|
||||
}
|
||||
on:click={(e) => {
|
||||
if (!element.contains(e.target)) {
|
||||
open = false
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="overflow-visible z-30 {absolute
|
||||
? 'absolute'
|
||||
: 'relative'} cursor-auto {clazz}"
|
||||
on:click={(e) => {
|
||||
if (preventDefault) e.preventDefault()
|
||||
|
||||
open = !open
|
||||
}}
|
||||
bind:this={element}
|
||||
>
|
||||
<slot name="button" />
|
||||
<slot name="button" {toggleOpen} />
|
||||
{#if open}
|
||||
<div
|
||||
transition:scale|local={{
|
||||
@@ -48,7 +41,7 @@
|
||||
start: 0.95,
|
||||
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-left left-0'}
|
||||
{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'}"
|
||||
>
|
||||
{#if open}
|
||||
<slot />
|
||||
<slot {toggleOpen} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
@@ -9,19 +9,21 @@
|
||||
const click = createEventDispatcher()
|
||||
</script>
|
||||
|
||||
{#if link}
|
||||
<a
|
||||
{href}
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||
>
|
||||
<slot />
|
||||
</a>
|
||||
{:else}
|
||||
<button
|
||||
on:click={(e) => click('click', e)}
|
||||
type="button"
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||
>
|
||||
<slot />
|
||||
</button>
|
||||
{/if}
|
||||
<li>
|
||||
{#if link}
|
||||
<a
|
||||
{href}
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||
>
|
||||
<slot />
|
||||
</a>
|
||||
{:else}
|
||||
<button
|
||||
on:click={(e) => click('click', e)}
|
||||
type="button"
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||
>
|
||||
<slot />
|
||||
</button>
|
||||
{/if}
|
||||
</li>
|
||||
Reference in new issue
Block a user