Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Copyable UI #1656

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/lib/components/event/event-details-row.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
copyIconTitle={translate('copy-icon-title')}
copySuccessIconTitle={translate('copy-success-icon-title')}
content={value}
container-class="xl:flex-row h-12 pr-1"
container-class="xl:flex-row"
>
<Link
class="truncate"
Expand All @@ -76,7 +76,7 @@
copyIconTitle={translate('copy-icon-title')}
copySuccessIconTitle={translate('copy-success-icon-title')}
content={value}
container-class="xl:flex-row h-12 pr-1"
container-class="xl:flex-row"
>
<Link
class="truncate"
Expand All @@ -100,7 +100,6 @@
copyIconTitle={translate('copy-icon-title')}
copySuccessIconTitle={translate('copy-success-icon-title')}
content={value}
container-class="h-12 pr-1"
>
<Link
class="truncate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`Table_body_cell$ > History Size renders 1`] = `"<td class=\\"workflows-

exports[`Table_body_cell$ > Parent Namespace renders 1`] = `"<td class=\\"workflows-summary-table-body-cell svelte-qupenl\\" data-testid=\\"workflows-summary-table-body-cell\\">parent-namespace-id</td>"`;

exports[`Table_body_cell$ > Run ID renders 1`] = `"<td class=\\"workflows-summary-table-body-cell filterable svelte-qupenl\\" data-testid=\\"workflows-summary-table-body-cell\\"><a href=\\"/namespaces/default/workflows/abc-123/def-456/history\\" class=\\"link svelte-1v8baj6\\"> def-456</a> </td>"`;
exports[`Table_body_cell$ > Run ID renders 1`] = `"<td class=\\"workflows-summary-table-body-cell filterable svelte-qupenl\\" data-testid=\\"workflows-summary-table-body-cell\\"><a href=\\"/namespaces/default/workflows/abc-123/def-456/history\\" class=\\"link inline svelte-1f9ld6i\\"> def-456</a> </td>"`;

exports[`Table_body_cell$ > Start renders 1`] = `"<td class=\\"workflows-summary-table-body-cell svelte-qupenl\\" data-testid=\\"workflows-summary-table-body-cell\\">2023-04-27 UTC 00:00:00.00</td>"`;

Expand All @@ -22,6 +22,6 @@ exports[`Table_body_cell$ > Status renders 1`] = `"<td class=\\"workflows-summar

exports[`Table_body_cell$ > Task Queue renders 1`] = `"<td class=\\"workflows-summary-table-body-cell svelte-qupenl\\" data-testid=\\"workflows-summary-table-body-cell\\">task-queue</td>"`;

exports[`Table_body_cell$ > Type renders 1`] = `"<td class=\\"workflows-summary-table-body-cell filterable svelte-qupenl\\" data-testid=\\"workflows-summary-table-body-cell\\"><a href=\\"/namespaces/default/workflows/abc-123/def-456/history\\" class=\\"link svelte-1v8baj6\\"> mock-workflow</a> </td>"`;
exports[`Table_body_cell$ > Type renders 1`] = `"<td class=\\"workflows-summary-table-body-cell filterable svelte-qupenl\\" data-testid=\\"workflows-summary-table-body-cell\\"><a href=\\"/namespaces/default/workflows/abc-123/def-456/history\\" class=\\"link inline svelte-1f9ld6i\\"> mock-workflow</a> </td>"`;

exports[`Table_body_cell$ > Workflow ID renders 1`] = `"<td class=\\"workflows-summary-table-body-cell filterable svelte-qupenl\\" data-testid=\\"workflows-summary-table-body-cell\\"><a href=\\"/namespaces/default/workflows/abc-123/def-456/history\\" class=\\"link svelte-1v8baj6\\"> abc-123</a> </td>"`;
exports[`Table_body_cell$ > Workflow ID renders 1`] = `"<td class=\\"workflows-summary-table-body-cell filterable svelte-qupenl\\" data-testid=\\"workflows-summary-table-body-cell\\"><a href=\\"/namespaces/default/workflows/abc-123/def-456/history\\" class=\\"link inline svelte-1f9ld6i\\"> abc-123</a> </td>"`;
45 changes: 31 additions & 14 deletions src/lib/holocene/copyable.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import IconButton from '$lib/holocene/icon-button.svelte';
import Icon from '$lib/holocene/icon/icon.svelte';
import { copyToClipboard } from '$lib/utilities/copy-to-clipboard';

export let content: string;
Expand All @@ -13,34 +13,51 @@

{#if clickAllToCopy}
<button
class="group flex items-center gap-2 {$$props['container-class']}"
class="group flex items-center gap-1 {$$props['container-class']}"
on:click={(e) => copy(e, content)}
>
<slot>
<span class={$$props.class} class:select-all={!$$slots.default}
>{content}</span
>
</slot>
<IconButton
<button
on:click={(e) => copy(e, content)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just have a CopyButton component?

Copy link
Contributor Author

@laurakwhit laurakwhit Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, was just talking with @tigernaut about this. I think probably? Added ✅ But we likely need to have a bigger discussion of if we want this and IconButton to be variants of the Button component.

class={`${visible ? 'visible' : 'invisible group-hover:visible'}`}
icon={$copied ? 'checkmark' : 'copy'}
label={$copied ? copySuccessIconTitle : copyIconTitle}
/>
aria-label={$copied ? copySuccessIconTitle : copyIconTitle}
class={`${
visible ? 'visible' : 'invisible group-hover:visible'
} copy-button`}
>
<Icon
title={$copied ? copySuccessIconTitle : copyIconTitle}
name={$copied ? 'checkmark' : 'copy'}
/>
</button>
</button>
{:else}
<div class="group flex items-center gap-2 {$$props['container-class']}">
<div class="group flex items-center gap-1 {$$props['container-class']}">
<slot>
<span class={$$props.class} class:select-all={!$$slots.default}
>{content}</span
>
</slot>

<IconButton
<button
on:click={(e) => copy(e, content)}
class={`${visible ? 'visible' : 'invisible group-hover:visible'}`}
icon={$copied ? 'checkmark' : 'copy'}
label={$copied ? copySuccessIconTitle : copyIconTitle}
/>
aria-label={$copied ? copySuccessIconTitle : copyIconTitle}
class={`${
visible ? 'visible' : 'invisible group-hover:visible'
} copy-button`}
>
<Icon
title={$copied ? copySuccessIconTitle : copyIconTitle}
name={$copied ? 'checkmark' : 'copy'}
/>
</button>
</div>
{/if}

<style lang="postcss">
.copy-button {
@apply m-1 rounded-md border-2 border-[transparent] hover:border-indigo-600 hover:bg-gradient-to-br hover:from-blue-100 hover:to-purple-100 hover:shadow-focus hover:shadow-blue-600/50 focus-visible:border-indigo-600 focus-visible:bg-gradient-to-br focus-visible:from-blue-100 focus-visible:to-purple-100 focus-visible:shadow-focus focus-visible:shadow-blue-600/50 focus-visible:outline-none;
}
</style>
4 changes: 2 additions & 2 deletions src/lib/holocene/link.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{href}
target={newTab ? '_blank' : null}
rel={newTab ? 'noreferrer' : null}
class="link {className}"
class="link {icon ? 'inline-flex' : 'inline'} {className}"
class:active
on:click
{...$$restProps}
Expand All @@ -39,7 +39,7 @@

<style lang="postcss">
.link {
@apply inline-flex max-w-fit cursor-pointer items-center gap-2 rounded underline underline-offset-2 hover:text-indigo-600 focus-visible:bg-blue-100 focus-visible:shadow-focus focus-visible:shadow-blue-600/50 focus-visible:outline-none;
@apply max-w-fit cursor-pointer items-center gap-2 rounded underline underline-offset-2 hover:text-indigo-600 focus-visible:bg-blue-100 focus-visible:shadow-focus focus-visible:shadow-blue-600/50 focus-visible:outline-none;

&.active {
@apply text-blue-900;
Expand Down