Skip to content

Commit e1d2f61

Browse files
authored
refactor: adding changes to copy to clipboard (#925)
1 parent 1437a9e commit e1d2f61

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

projects/assets-library/assets/icons/copy-to-clipboard.svg

Lines changed: 0 additions & 5 deletions
This file was deleted.

projects/assets-library/src/icons/icon-library.module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ const iconsRootPath = 'assets/icons';
3737
{ key: IconType.CollapseAll, url: `${iconsRootPath}/collapse-all.svg` },
3838
{ key: IconType.Collapsed, url: `${iconsRootPath}/plus-square.svg` },
3939
{ key: IconType.Compare, url: `${iconsRootPath}/compare.svg` },
40-
{ key: IconType.CopyToClipboard, url: `${iconsRootPath}/copy-to-clipboard.svg` },
4140
{ key: IconType.Custom, url: `${iconsRootPath}/custom.svg` },
4241
{ key: IconType.Dashboard, url: `${iconsRootPath}/dashboard.svg` },
4342
{ key: IconType.Device, url: `${iconsRootPath}/device.svg` },

projects/assets-library/src/icons/icon-type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const enum IconType {
2929
Collapsed = 'svg:plus-square',
3030
Compare = 'svg:compare',
3131
CompareArrows = 'compare_arrows',
32-
CopyToClipboard = 'svg:copy-to-clipboard',
32+
ContentCopy = 'content_copy',
3333
Code = 'svg:code',
3434
Custom = 'svg:custom',
3535
CustomWebhook = 'svg:custom-webhook',

projects/components/src/copy-to-clipboard/copy-to-clipboard.component.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ describe('Copy to Clipboard component', () => {
3232

3333
test('correctly copies the text to clipboard', fakeAsync(() => {
3434
spectator = createHost(
35-
`<ht-copy-to-clipboard [text]="textToBeCopied" label="Copy to Clipboard"></ht-copy-to-clipboard>`,
35+
`<ht-copy-to-clipboard [tooltipDuration]="tooltipDuration" [text]="textToBeCopied" label="Copy to Clipboard"></ht-copy-to-clipboard>`,
3636
{
3737
hostProps: {
38-
textToBeCopied: 'Text to be copied'
38+
textToBeCopied: 'Text to be copied',
39+
tooltipDuration: 1000
3940
}
4041
}
4142
);
@@ -62,7 +63,7 @@ describe('Copy to Clipboard component', () => {
6263

6364
spectator.tick();
6465
expect(spectator.inject(PopoverService).drawPopover).toHaveBeenCalled();
65-
spectator.tick(4000);
66+
spectator.tick(1001);
6667
expect(mockPopoverRef.close).toHaveBeenCalled();
6768
}));
6869
});

projects/components/src/copy-to-clipboard/copy-to-clipboard.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class CopyToClipboardComponent implements OnInit, OnDestroy {
5252
public size?: ButtonSize = ButtonSize.Small;
5353

5454
@Input()
55-
public icon?: IconType = IconType.CopyToClipboard;
55+
public icon?: IconType = IconType.ContentCopy;
5656

5757
@Input()
5858
public label?: string = 'Copy to Clipboard';
@@ -63,6 +63,9 @@ export class CopyToClipboardComponent implements OnInit, OnDestroy {
6363
@Input()
6464
public text?: string;
6565

66+
@Input()
67+
public tooltipDuration: number = 3000;
68+
6669
@Output()
6770
public readonly copiedChanges: EventEmitter<boolean> = new EventEmitter();
6871

@@ -133,7 +136,7 @@ export class CopyToClipboardComponent implements OnInit, OnDestroy {
133136
});
134137

135138
return of(popoverRef).pipe(
136-
delay(3000),
139+
delay(this.tooltipDuration ?? 0),
137140
finalize(() => popoverRef.close())
138141
);
139142
}

0 commit comments

Comments
 (0)