Skip to content

Commit d7b87e5

Browse files
committed
build: add clipboard to dev app
Currently we don't have an easy way of debugging the `cdk/clipboard` module locally. These changes add a page to the dev app.
1 parent 9343d08 commit d7b87e5

File tree

9 files changed

+108
-0
lines changed

9 files changed

+108
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
/src/dev-app/card/** @jelbourn
140140
/src/dev-app/checkbox/** @jelbourn @devversion
141141
/src/dev-app/chips/** @jelbourn
142+
/src/dev-app/clipboard/** @jelbourn @xkxx
142143
/src/dev-app/column-resize/** @kseamon @andrewseguin
143144
/src/dev-app/connected-overlay/** @jelbourn @crisbeto
144145
/src/dev-app/dataset/** @andrewseguin

src/dev-app/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ng_module(
2525
"//src/dev-app/card",
2626
"//src/dev-app/checkbox",
2727
"//src/dev-app/chips",
28+
"//src/dev-app/clipboard",
2829
"//src/dev-app/column-resize",
2930
"//src/dev-app/connected-overlay",
3031
"//src/dev-app/datepicker",

src/dev-app/clipboard/BUILD.bazel

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
load("//tools:defaults.bzl", "ng_module", "sass_binary")
4+
5+
ng_module(
6+
name = "clipboard",
7+
srcs = glob(["**/*.ts"]),
8+
assets = [
9+
":clipboard_demo_scss",
10+
"clipboard-demo.html",
11+
],
12+
deps = [
13+
"//src/cdk/clipboard",
14+
"@npm//@angular/forms",
15+
"@npm//@angular/router",
16+
],
17+
)
18+
19+
sass_binary(
20+
name = "clipboard_demo_scss",
21+
src = "clipboard-demo.scss",
22+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {ClipboardModule} from '@angular/cdk/clipboard';
10+
import {NgModule} from '@angular/core';
11+
import {FormsModule} from '@angular/forms';
12+
import {RouterModule} from '@angular/router';
13+
import {ClipboardDemo} from './clipboard-demo';
14+
15+
@NgModule({
16+
imports: [
17+
ClipboardModule,
18+
FormsModule,
19+
RouterModule.forChild([{path: '', component: ClipboardDemo}]),
20+
],
21+
declarations: [ClipboardDemo],
22+
})
23+
export class ClipboardDemoModule {
24+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<section>
2+
<label for="example-textarea">Text to be copied</label>
3+
<textarea id="example-textarea" cols="30" rows="10" [(ngModel)]="value"></textarea>
4+
</section>
5+
6+
<section>
7+
<label for="example-attempts-input">Copy attempts</label>
8+
<input id="example-attempts-input" type="number" [(ngModel)]="attempts"/>
9+
</section>
10+
11+
<button (click)="copyViaService()">Copy to clipboard via service</button>
12+
<button
13+
[cdkCopyToClipboard]="value"
14+
[cdkCopyToClipboardAttempts]="attempts">Copy to clipboard via directive</button>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
label {
2+
display: block;
3+
}
4+
5+
section {
6+
margin: 8px 0;
7+
}
8+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {Component} from '@angular/core';
10+
import {Clipboard} from '@angular/cdk/clipboard';
11+
12+
13+
@Component({
14+
selector: 'clipboard-demo',
15+
styleUrls: ['clipboard-demo.css'],
16+
templateUrl: 'clipboard-demo.html',
17+
})
18+
export class ClipboardDemo {
19+
attempts = 3;
20+
21+
value = `Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It's not ` +
22+
`a story the Jedi would tell you. It's a Sith legend. Darth Plagueis was a Dark Lord ` +
23+
`of the Sith, so powerful and so wise he could use the Force to influence the ` +
24+
`midichlorians to create life… He had such a knowledge of the dark side that he could ` +
25+
`even keep the ones he cared about from dying. The dark side of the Force is a pathway ` +
26+
`to many abilities some consider to be unnatural. He became so powerful… the only ` +
27+
`thing he was afraid of was losing his power, which eventually, of course, he did. ` +
28+
`Unfortunately, he taught his apprentice everything he knew, then his apprentice ` +
29+
`killed him in his sleep. Ironic. He could save others from death, but not himself.`;
30+
31+
constructor(private _clipboard: Clipboard) {}
32+
33+
copyViaService() {
34+
this._clipboard.copy(this.value);
35+
}
36+
}

src/dev-app/dev-app/dev-app-layout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class DevAppLayout {
3131
{name: 'Card', route: '/card'},
3232
{name: 'Checkbox', route: '/checkbox'},
3333
{name: 'Chips', route: '/chips'},
34+
{name: 'Clipboard', route: '/clipboard'},
3435
{name: 'Column Resize', route: 'column-resize'},
3536
{name: 'Connected Overlay', route: '/connected-overlay'},
3637
{name: 'Datepicker', route: '/datepicker'},

src/dev-app/dev-app/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const DEV_APP_ROUTES: Routes = [
3030
{path: 'card', loadChildren: 'card/card-demo-module#CardDemoModule'},
3131
{path: 'checkbox', loadChildren: 'checkbox/checkbox-demo-module#CheckboxDemoModule'},
3232
{path: 'chips', loadChildren: 'chips/chips-demo-module#ChipsDemoModule'},
33+
{path: 'clipboard', loadChildren: 'clipboard/clipboard-demo-module#ClipboardDemoModule'},
3334
{
3435
path: 'column-resize',
3536
loadChildren: 'column-resize/column-resize-demo-module#ColumnResizeDemoModule'

0 commit comments

Comments
 (0)