Make IDs copyable by clicking anywhere in the body

This commit is contained in:
Rūdolfs Ošiņš
2023-11-09 10:55:10 +01:00
parent ca28fc28b2
commit 179f22cf66
8 changed files with 62 additions and 68 deletions
+10 -13
View File
@@ -5,12 +5,12 @@
import { isLocal, truncateId } from "@app/lib/utils";
import { loadProjects } from "@app/views/nodes/router";
import Clipboard from "@app/components/Clipboard.svelte";
import ErrorMessage from "@app/components/ErrorMessage.svelte";
import Link from "@app/components/Link.svelte";
import Loading from "@app/components/Loading.svelte";
import ProjectCard from "@app/components/ProjectCard.svelte";
import Button from "@app/components/Button.svelte";
import CopyableId from "@app/components/CopyableId.svelte";
export let baseUrl: BaseUrl;
export let nid: string;
@@ -74,11 +74,6 @@
font-size: var(--font-size-x-large);
font-weight: var(--font-weight-bold);
}
.address {
color: var(--color-fill-secondary);
font-family: var(--font-family-monospace);
display: flex;
}
.info {
display: flex;
justify-content: space-between;
@@ -86,6 +81,7 @@
.version {
color: var(--color-fill-gray);
font-family: var(--font-family-monospace);
font-size: var(--font-size-small);
}
.projects {
display: flex;
@@ -111,18 +107,19 @@
{#each externalAddresses as address}
<!-- If there are externalAddresses this is probably a remote node -->
<!-- in that case, we show all the defined externalAddresses as a listing -->
<div class="address">
<CopyableId id={`${nid}@${address}`}>
{truncateId(nid)}@{address}
<Clipboard small text={`${nid}@${address}`} />
</div>
</CopyableId>
{:else}
<!-- else this is probably a local node -->
<!-- So we show only the nid -->
<div class="address layout-desktop">
{nid}<Clipboard small text={nid} />
<div class="layout-desktop">
<CopyableId id={nid} />
</div>
<div class="address layout-mobile">
{truncateId(nid)}<Clipboard small text={nid} />
<div class="layout-mobile">
<CopyableId id={nid}>
{truncateId(nid)}
</CopyableId>
</div>
{/each}
</div>
+1 -3
View File
@@ -32,9 +32,7 @@
{#each embeds as embed}
<Badge variant="neutral">
<span class="txt-overflow">{embed.name}</span>
<Clipboard
text={`![${embed.name}](${embed.content.substring(4)})`}
small />
<Clipboard text={`![${embed.name}](${embed.content.substring(4)})`} />
</Badge>
{:else}
<div class="txt-missing">No attachments</div>
+5 -5
View File
@@ -4,10 +4,10 @@
import { formatCommit } from "@app/lib/utils";
import Changeset from "@app/views/projects/Changeset.svelte";
import Clipboard from "@app/components/Clipboard.svelte";
import CommitAuthorship from "@app/views/projects/Commit/CommitAuthorship.svelte";
import InlineMarkdown from "@app/components/InlineMarkdown.svelte";
import Layout from "./Layout.svelte";
import CopyableId from "@app/components/CopyableId.svelte";
export let baseUrl: BaseUrl;
export let commit: Commit;
@@ -49,12 +49,12 @@
<InlineMarkdown fontSize="medium" content={header.summary} />
</div>
<div class="layout-desktop-flex txt-monospace sha1">
<span>{header.id}</span>
<Clipboard small text={header.id} />
<CopyableId id={header.id} />
</div>
<div class="layout-mobile-flex txt-monospace sha1 txt-small">
{formatCommit(header.id)}
<Clipboard small text={header.id} />
<CopyableId id={header.id}>
{formatCommit(header.id)}
</CopyableId>
</div>
</div>
<pre class="description txt-small">{header.description}</pre>
+4 -19
View File
@@ -8,12 +8,12 @@
import { twemoji, isLocal } from "@app/lib/utils";
import Button from "@app/components/Button.svelte";
import Clipboard from "@app/components/Clipboard.svelte";
import CloneButton from "@app/views/projects/Header/CloneButton.svelte";
import Link from "@app/components/Link.svelte";
import Header from "./Header.svelte";
import TrackButton from "./Header/TrackButton.svelte";
import CopyableId from "@app/components/CopyableId.svelte";
export let activeTab: ActiveTab = undefined;
export let baseUrl: BaseUrl;
@@ -45,23 +45,9 @@
.project-name:hover {
color: inherit;
}
.id {
color: var(--color-fill-secondary);
overflow-wrap: anywhere;
display: flex;
justify-content: left;
align-items: center;
gap: 0.125rem;
margin: 1rem 0 3rem 0;
}
.description :global(a) {
border-bottom: 1px solid var(--color-foreground-contrast);
}
.truncate {
white-space: nowrap;
text-overflow: ellipsis;
overflow-x: hidden;
}
.content {
width: 100%;
max-width: var(--content-max-width);
@@ -91,7 +77,7 @@
<div class="header">
<div class="title">
<span class="truncate">
<span class="txt-overflow">
<Link
route={{
resource: "project.source",
@@ -131,9 +117,8 @@
{@html render(project.description)}
</div>
<div class="id">
<span class="truncate global-hash">{project.id}</span>
<Clipboard small text={project.id} />
<div style:margin-bottom="3rem">
<CopyableId id={project.id} />
</div>
<Header {project} {activeTab} {baseUrl} />