feat(backend,frontend): search everywhere in buttons, links and message data, a jump from search or an alert lights up the found words and buttons
This commit is contained in:
1 parent
acfa726e61
commit
d660079c02
21 files changed
+840
-76
No files matched your search
@@ -1,13 +1,15 @@
|
||||
<script lang="ts">
|
||||
import type { InlineButton } from "#lib/api/types.js";
|
||||
import { buttonHasMark } from "#lib/format/search.js";
|
||||
import { safeHref } from "#lib/format/url.js";
|
||||
import { t } from "#lib/i18n/locale.svelte.js";
|
||||
|
||||
interface Props {
|
||||
marks?: string[];
|
||||
rows: InlineButton[][];
|
||||
}
|
||||
|
||||
let { rows }: Props = $props();
|
||||
let { marks = [], rows }: Props = $props();
|
||||
|
||||
let copied = $state<string | null>(null);
|
||||
let resetTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
@@ -27,12 +29,14 @@
|
||||
<div class="row">
|
||||
{#each row as button, colIndex (colIndex)}
|
||||
{@const key = `${rowIndex}:${colIndex}`}
|
||||
{@const lit = marks.length > 0 && buttonHasMark(button, marks)}
|
||||
{#if button.kind === "url" && button.url}
|
||||
<a
|
||||
class="button"
|
||||
href={safeHref(button.url)}
|
||||
rel="noopener"
|
||||
target="_blank"
|
||||
class:found={lit}
|
||||
>
|
||||
<span class="label">{button.text}</span>
|
||||
<span class="corner">↗</span>
|
||||
@@ -42,13 +46,14 @@
|
||||
class="button"
|
||||
onclick={() => copy(key, button.data ?? "")}
|
||||
type="button"
|
||||
class:found={lit}
|
||||
>
|
||||
<span class="label"
|
||||
>{copied === key ? t("inline.copied") : button.text}</span
|
||||
>
|
||||
</button>
|
||||
{:else}
|
||||
<span class="button static">
|
||||
<span class="button static" class:found={lit}>
|
||||
<span class="label">{button.text}</span>
|
||||
</span>
|
||||
{/if}
|
||||
@@ -104,6 +109,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
.found {
|
||||
animation: found-flash 3s ease;
|
||||
}
|
||||
|
||||
@keyframes found-flash {
|
||||
0%,
|
||||
70% {
|
||||
background-color: color-mix(
|
||||
in srgb,
|
||||
var(--color-primary) 30%,
|
||||
var(--color-message-reaction)
|
||||
);
|
||||
box-shadow: inset 0 0 0 1px var(--color-primary);
|
||||
}
|
||||
|
||||
100% {
|
||||
background-color: var(--color-message-reaction);
|
||||
box-shadow: inset 0 0 0 1px transparent;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
Reference in new issue
Block a user