-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(material-angular-io): allow module imports to be copied from API…
… tab (#30389) adds icon button next to module import text allowing users to copy it directly fixes #16127
- Loading branch information
Showing
6 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
material.angular.io/src/app/shared/doc-viewer/module-import-copy-button.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {Component, inject} from '@angular/core'; | ||
import {MatIconButton} from '@angular/material/button'; | ||
import {MatIcon} from '@angular/material/icon'; | ||
import {MatSnackBar} from '@angular/material/snack-bar'; | ||
import {MatTooltip} from '@angular/material/tooltip'; | ||
import {Clipboard} from '@angular/cdk/clipboard'; | ||
|
||
/** | ||
* Shows up an icon button which will allow users to copy the module import | ||
*/ | ||
@Component({ | ||
selector: 'module-import-copy-button', | ||
template: `<button | ||
mat-icon-button | ||
matTooltip="Copy import to the clipboard" | ||
(click)="copy()"> | ||
<mat-icon>content_copy</mat-icon> | ||
</button>`, | ||
standalone: true, | ||
imports: [MatIconButton, MatIcon, MatTooltip], | ||
}) | ||
export class ModuleImportCopyButton { | ||
private clipboard = inject(Clipboard); | ||
private snackbar = inject(MatSnackBar); | ||
/** Import path for the module that will be copied */ | ||
import = ''; | ||
|
||
copy(): void { | ||
const message = this.clipboard.copy(this.import) | ||
? 'Copied module import' | ||
: 'Failed to copy module import'; | ||
this.snackbar.open(message, undefined, {duration: 2500}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters