impr: use label based opening for disclosures
This commit is contained in:
12 files changed
+81
-42
No files matched your search
@@ -40,15 +40,19 @@
|
|||||||
<svelte:element
|
<svelte:element
|
||||||
this={htmlElement}
|
this={htmlElement}
|
||||||
{style}
|
{style}
|
||||||
class="{!expanded
|
class={[
|
||||||
? `overflow-hidden
|
expanded
|
||||||
bg-linear-to-b text-transparent from-slate-600 via-slate-600
|
? 'text-slate-600 dark:text-zinc-400 max-h-full'
|
||||||
dark:from-zinc-400 dark:via-zinc-400 bg-clip-text z-0 max-h-36`
|
: [
|
||||||
: 'text-slate-600 dark:text-zinc-400 max-h-full'} text-base {clazz}"
|
'overflow-hidden bg-linear-to-b text-transparent from-slate-600 via-slate-600',
|
||||||
|
'dark:from-zinc-400 dark:via-zinc-400 bg-clip-text z-0 max-h-36',
|
||||||
|
],
|
||||||
|
clazz,
|
||||||
|
]}
|
||||||
class:pointer-events-none={!clickThrough}
|
class:pointer-events-none={!clickThrough}
|
||||||
bind:this={element}
|
bind:this={element}
|
||||||
>
|
>
|
||||||
<Markdown inline source={expanded ? body : body.slice(0, 1000)} />
|
<Markdown source={expanded ? body : body.slice(0, 1000)} />
|
||||||
{#if overflows}
|
{#if overflows}
|
||||||
<Button
|
<Button
|
||||||
onclick={() => (expanded = !expanded)}
|
onclick={() => (expanded = !expanded)}
|
||||||
|
|||||||
@@ -138,15 +138,16 @@
|
|||||||
},
|
},
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
setContext('options', rendererOptions)
|
setContext('options', { ...rendererOptions, inline: inline })
|
||||||
|
|
||||||
let tokens = $derived(marked.lexer(source))
|
let tokens = $derived(marked.lexer(source))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<article
|
<svelte:element
|
||||||
|
this={inline ? 'div' : 'article'}
|
||||||
dir="auto"
|
dir="auto"
|
||||||
class={[!noStyle && 'break-words space-y-4 leading-normal', clazz]}
|
class={[!noStyle && 'break-words space-y-4 leading-normal', clazz]}
|
||||||
{style}
|
{style}
|
||||||
>
|
>
|
||||||
<MdTree {tokens} renderers={inline ? inlineRenderers : renderers} />
|
<MdTree {tokens} renderers={inline ? inlineRenderers : renderers} />
|
||||||
</article>
|
</svelte:element>
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
<Material
|
<Material
|
||||||
padding="none"
|
padding="none"
|
||||||
|
rounding="2xl"
|
||||||
class="flex flex-col rounded-xl
|
class="flex flex-col rounded-xl
|
||||||
divide-y divide-slate-200 dark:divide-zinc-800 overflow-hidden"
|
divide-y divide-slate-200 dark:divide-zinc-800 overflow-hidden"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import { getContext } from 'svelte'
|
||||||
|
|
||||||
let { children } = $props()
|
let { children } = $props()
|
||||||
|
|
||||||
|
const options = getContext('options')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<p class="leading-[1.7] break-words max-w">
|
<p class={[!options.inline && 'leading-[1.7] break-words max-w']}>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ export const spoilerPlugin = {
|
|||||||
name: 'spoiler',
|
name: 'spoiler',
|
||||||
level: 'block',
|
level: 'block',
|
||||||
start(src) {
|
start(src) {
|
||||||
return src.match(/^:::/)?.index
|
return src.match(/:::/)?.index
|
||||||
},
|
},
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const rule = /^::: spoiler (.+)\n([\s\S]*?)\n:::/
|
const rule = /::: ?spoiler(?: ?(.*))\n([\s\S]*?)\n:::/
|
||||||
const match = rule.exec(src)
|
const match = rule.exec(src)
|
||||||
if (match) {
|
if (match) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ export default function (tokensExtractor) {
|
|||||||
name: 'container',
|
name: 'container',
|
||||||
level: 'block',
|
level: 'block',
|
||||||
start(src) {
|
start(src) {
|
||||||
return src.match(/^:::[^:\n]/)?.index
|
return src.match(/:::[^:\n]/)?.index
|
||||||
},
|
},
|
||||||
tokenizer(src) {
|
tokenizer(src) {
|
||||||
const rule =
|
const rule =
|
||||||
/^:::[\s]?(?<type>[a-z0-9-]+)(?<options>.*)?\n(?<content>(?:.|\n)*)\n:::(?:\n|$)/i
|
/:::[\s]?(?<type>[a-z0-9-]+)(?<options>.*)?\n(?<content>(?:.|\n)*)\n:::(?:\n)*/i
|
||||||
|
|
||||||
const match = rule.exec(findRawContainer(src))
|
const match = rule.exec(findRawContainer(src))
|
||||||
if (!match || !match.groups) return null
|
if (!match || !match.groups) return null
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
{#if icon}
|
{#if icon}
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
'ml-auto ',
|
'ml-auto',
|
||||||
!open && 'rotate-90',
|
!open && 'rotate-90',
|
||||||
'transition-transform duration-300 ease-out',
|
'transition-transform duration-300 ease-out',
|
||||||
]}
|
]}
|
||||||
@@ -51,8 +51,10 @@
|
|||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#if content}{@render content()}{:else}
|
{#if content}
|
||||||
<div class="pt-2 text-slate-900 dark:text-zinc-100">
|
{@render content()}
|
||||||
|
{:else}
|
||||||
|
<div class="text-slate-900 dark:text-zinc-100 *:mt-2">
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -316,7 +316,7 @@
|
|||||||
|
|
||||||
.btn-disabled {
|
.btn-disabled {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
filter: brightness(70%);
|
filter: brightness(90%);
|
||||||
cursor: normal;
|
cursor: normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Snippet } from 'svelte'
|
import type { Snippet } from 'svelte'
|
||||||
import { expoOut } from 'svelte/easing'
|
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
import { slide } from 'svelte/transition'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open?: boolean
|
open?: boolean
|
||||||
@@ -20,16 +18,35 @@
|
|||||||
children,
|
children,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
|
const id = $props.id()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div {...rest} class={['w-full', clazz]}>
|
<div {...rest} class={['w-full', clazz]}>
|
||||||
<button onclick={() => (open = !open)} class="w-full">
|
<label for={id} class="w-full">
|
||||||
{@render summary?.({ open })}
|
{@render summary?.({ open })}
|
||||||
</button>
|
</label>
|
||||||
{@render extended?.()}
|
{@render extended?.()}
|
||||||
{#if open}
|
<input {id} class="hidden input" type="checkbox" bind:checked={open} />
|
||||||
<div transition:slide={{ axis: 'y', easing: expoOut, duration: 300 }}>
|
<div class="expand">
|
||||||
{@render children?.({ open })}
|
{@render children?.({ open })}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.expand {
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: 0fr;
|
||||||
|
grid-template-columns: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: grid-template-rows 0.5s cubic-bezier(0.19, 1, 0.22, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input:checked + .expand {
|
||||||
|
grid-template-rows: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expand > :global(*) {
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const roundedClass = {
|
const roundedClass = {
|
||||||
none: 'rounded-none',
|
none: '',
|
||||||
sm: 'rounded-xs',
|
sm: 'rounded-xs',
|
||||||
md: 'rounded-md',
|
md: 'rounded-md',
|
||||||
lg: 'rounded-lg',
|
lg: 'rounded-lg',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import CommentItem from '$comp/lemmy/comment/CommentItem.svelte'
|
import CommentItem from '$comp/lemmy/comment/CommentItem.svelte'
|
||||||
import PrivateMessage from '$comp/lemmy/inbox/PrivateMessage.svelte'
|
import PrivateMessage from '$comp/lemmy/inbox/PrivateMessage.svelte'
|
||||||
|
import Markdown from '$comp/markdown/Markdown.svelte'
|
||||||
import Avatar from '$comp/ui/Avatar.svelte'
|
import Avatar from '$comp/ui/Avatar.svelte'
|
||||||
import Expandable from '$comp/ui/Expandable.svelte'
|
import Expandable from '$comp/ui/Expandable.svelte'
|
||||||
import RelativeDate from '$comp/util/RelativeDate.svelte'
|
import RelativeDate from '$comp/util/RelativeDate.svelte'
|
||||||
@@ -63,23 +64,32 @@
|
|||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<div class="text-sm font-normal text-slate-600 dark:text-zinc-400">
|
<div class="text-sm font-normal text-slate-600 dark:text-zinc-400">
|
||||||
{#if item.type == 'comment_reply'}
|
{#if item.type == 'comment_reply'}
|
||||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
<Markdown
|
||||||
{@html $t('routes.inbox.item.reply', {
|
inline
|
||||||
user: `<strong>${item.creator.name}</strong>`,
|
source={$t('routes.inbox.item.reply', {
|
||||||
post: `<strong>${escapeHtml(item.item.post.name)}</strong>`,
|
user: `**${item.creator.name}**`,
|
||||||
|
post: `**${escapeHtml(item.item.post.name)}**`,
|
||||||
})}
|
})}
|
||||||
|
noStyle
|
||||||
|
/>
|
||||||
{:else if item.type == 'person_mention'}
|
{:else if item.type == 'person_mention'}
|
||||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
<Markdown
|
||||||
{@html $t('routes.inbox.item.mention', {
|
inline
|
||||||
user: `<strong>${item.creator.name}</strong>`,
|
source={$t('routes.inbox.item.mention', {
|
||||||
post: `<strong>${escapeHtml(item.item.post.name)}</strong>`,
|
user: `**${item.creator.name}**`,
|
||||||
|
post: `**${escapeHtml(item.item.post.name)}**`,
|
||||||
})}
|
})}
|
||||||
|
noStyle
|
||||||
|
/>
|
||||||
{:else if item.type == 'private_message'}
|
{:else if item.type == 'private_message'}
|
||||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
<Markdown
|
||||||
{@html $t('routes.inbox.item.message', {
|
inline
|
||||||
user: `<strong>${item.item.creator.name}</strong>`,
|
source={$t('routes.inbox.item.message', {
|
||||||
recipient: `<strong>${item.item.recipient.name}</strong>`,
|
user: `**${item.creator.name}**`,
|
||||||
|
recipient: `**${escapeHtml(item.item.recipient.name)}**`,
|
||||||
})}
|
})}
|
||||||
|
noStyle
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="text-xs text-slate-600 dark:text-zinc-400">
|
<div class="text-xs text-slate-600 dark:text-zinc-400">
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
<button class="h-full" onclick={() => (themeData.data.currentTheme = theme.id)}>
|
<button class="h-full" onclick={() => (themeData.data.currentTheme = theme.id)}>
|
||||||
<Material
|
<Material
|
||||||
padding="none"
|
padding="none"
|
||||||
|
rounding="none"
|
||||||
class="{theme.id == themeData.data.currentTheme
|
class="{theme.id == themeData.data.currentTheme
|
||||||
? 'ring-2 ring-inset ring-primary-900 dark:ring-primary-100'
|
? 'ring-2 ring-primary-900 dark:ring-primary-100'
|
||||||
: ''} flex relative cursor-pointer h-full flex-col text-left p-0.5"
|
: ''} rounded-2xl flex relative cursor-pointer h-full flex-col text-left p-0.5"
|
||||||
rounding="2xl"
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
src={CheckCircle}
|
src={CheckCircle}
|
||||||
size="20"
|
size="20"
|
||||||
solid
|
solid
|
||||||
class="absolute top-0 right-0 m-2 text-primary-900 dark:text-primary-100"
|
class="absolute top-0 right-0 m-2 text-primary-100"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="px-4 py-2 flex items-center gap-1 justify-between">
|
<div class="px-4 py-2 flex items-center gap-1 justify-between">
|
||||||
|
|||||||
Reference in new issue
Block a user