Skip to content

Commit

Permalink
Hide Id copyable tooltip when hovering the tooltip itself
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolfs committed Jun 24, 2024
1 parent 473f893 commit 78dbf91
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 43 deletions.
4 changes: 2 additions & 2 deletions public/elevations.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:root {
--elevation-low: 0 0 64px 0 #00000099;
--elevation-low: 0 0 48px 0 #000000ee;
}

[data-theme="light"] {
--elevation-low: 0 0 64px 0 #0000001a;
--elevation-low: 0 0 16px 0 #00000022;
}
64 changes: 30 additions & 34 deletions src/components/Id.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
export let clipboard: string = id;
export let shorten: boolean = true;
export let style: "oid" | "commit" | "none" = "oid";
export let subject: string | undefined = undefined;
export let ariaLabel: string | undefined = undefined;
export let styleLeft: string = "0";
let icon: ComponentProps<IconSmall>["name"] = "clipboard";
const text = subject ? `Click to copy ${subject}` : "Click to copy";
const text = "Click to copy";
let tooltip = text;
const restoreIcon = debounce(() => {
Expand Down Expand Up @@ -47,16 +47,16 @@
}
.popover {
position: absolute;
bottom: 1.5rem;
left: 0;
display: flex;
align-items: center;
flex-direction: row;
gap: 0.5rem;
justify-content: center;
z-index: 20;
bottom: 1.5rem;
background: var(--color-background-float);
color: var(--color-foreground-default);
color: var(--color-fill-gray);
border: 1px solid var(--color-border-hint);
border-radius: var(--border-radius-small);
box-shadow: var(--elevation-low);
Expand All @@ -75,42 +75,38 @@
</style>

<div class="container">
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
role="button"
tabindex="0"
on:mouseenter={() => {
setVisible(true);
}}
on:mouseleave={() => {
setVisible(false);
}}>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="target-{style} global-{style}"
style:cursor="pointer"
aria-label={ariaLabel}
on:click={async () => {
await copy();
setVisible(true);
}}
role="button"
tabindex="0">
<slot>
{#if shorten}
{formatObjectId(id)}
{:else}
{id}
{/if}
</slot>
</div>
}}
class="target-{style} global-{style}"
style:cursor="pointer"
aria-label={ariaLabel}
on:click={async () => {
await copy();
setVisible(true);
}}
role="button"
tabindex="0">
<slot>
{#if shorten}
{formatObjectId(id)}
{:else}
{id}
{/if}
</slot>
</div>

{#if visible}
<div style:position="absolute">
<div class="popover">
<IconSmall name={icon} />
{tooltip}
</div>
{#if visible}
<div style:position="absolute">
<div class="popover" style:left={styleLeft}>
<IconSmall name={icon} />
{tooltip}
</div>
{/if}
</div>
</div>
{/if}
</div>
3 changes: 1 addition & 2 deletions src/components/NodeId.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
export let nodeId: string;
export let alias: string | undefined = undefined;
export let subject: string = formatNodeId(nodeId);
</script>

<style>
Expand All @@ -25,7 +24,7 @@
}
</style>

<Id id={nodeId} {subject} style="none">
<Id id={nodeId} style="none" styleLeft="1rem">
<div class="avatar-alias">
<Avatar {nodeId} />
{#if alias}
Expand Down
2 changes: 1 addition & 1 deletion src/views/projects/Issue/IssueTeaser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<div
style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;">
<NodeId nodeId={issue.author.id} alias={issue.author.alias} />
opened
opened a
<Id id={issue.id} />
<span title={absoluteTimestamp(issue.discussion[0].timestamp)}>
{formatTimestamp(issue.discussion[0].timestamp)}
Expand Down
5 changes: 1 addition & 4 deletions src/views/projects/Source/PeerBranchSelector/Peer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@
<IconButton title="Expand peer" on:click={() => (expanded = !expanded)}>
<IconSmall name={expanded ? "chevron-down" : "chevron-right"} />
</IconButton>
<NodeId
subject="Node Id"
nodeId={peer.remote.id}
alias={peer.remote.alias} />
<NodeId nodeId={peer.remote.id} alias={peer.remote.alias} />
{#if peer.remote.delegate}
<Badge size="tiny" variant="delegate">
<IconSmall name="badge" />
Expand Down

0 comments on commit 78dbf91

Please sign in to comment.