From 63e1a5e899cd6681ce819c53669a76b7987fb7a2 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Tue, 4 Feb 2020 11:35:09 +0100 Subject: [PATCH] :zap: component to copy text to clipboard --- src/app/ui/copy-text/copy-text.component.html | 9 +++++++ src/app/ui/copy-text/copy-text.component.scss | 0 .../ui/copy-text/copy-text.component.spec.ts | 25 ++++++++++++++++++ src/app/ui/copy-text/copy-text.component.ts | 26 +++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 src/app/ui/copy-text/copy-text.component.html create mode 100644 src/app/ui/copy-text/copy-text.component.scss create mode 100644 src/app/ui/copy-text/copy-text.component.spec.ts create mode 100644 src/app/ui/copy-text/copy-text.component.ts diff --git a/src/app/ui/copy-text/copy-text.component.html b/src/app/ui/copy-text/copy-text.component.html new file mode 100644 index 00000000..73c0c417 --- /dev/null +++ b/src/app/ui/copy-text/copy-text.component.html @@ -0,0 +1,9 @@ + diff --git a/src/app/ui/copy-text/copy-text.component.scss b/src/app/ui/copy-text/copy-text.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/app/ui/copy-text/copy-text.component.spec.ts b/src/app/ui/copy-text/copy-text.component.spec.ts new file mode 100644 index 00000000..18a6c096 --- /dev/null +++ b/src/app/ui/copy-text/copy-text.component.spec.ts @@ -0,0 +1,25 @@ +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; + +import {CopyTextComponent} from './copy-text.component'; + +describe('CopyTextComponent', () => { + let component: CopyTextComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [CopyTextComponent] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CopyTextComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/ui/copy-text/copy-text.component.ts b/src/app/ui/copy-text/copy-text.component.ts new file mode 100644 index 00000000..27457fc5 --- /dev/null +++ b/src/app/ui/copy-text/copy-text.component.ts @@ -0,0 +1,26 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {MessageService} from "primeng/api"; + +@Component({ + selector: 'framadate-copy-text', + templateUrl: './copy-text.component.html', + styleUrls: ['./copy-text.component.scss'] +}) +export class CopyTextComponent implements OnInit { + @Input() public textToCopy: any; + + constructor(private messageService: MessageService,) { + } + + ngOnInit() { + } + + handleClick() { + this.messageService.add({ + severity: 'success', + summary: 'Texte copiƩ', + detail: this.textToCopy + }) + } + +}