Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
feat(copy-to-clipboard): Added variant input to control embedded
Browse files Browse the repository at this point in the history
button variant.

We have added an input to the copy-to-clipboard component that is passed
through to the button, which is being used in the copy to clipboard
template. The newly created input controls the variant of the embedded
button.

Fixes #76
  • Loading branch information
tomheller authored and ffriedl89 committed Jan 31, 2020
1 parent 36e6067 commit bbad528
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/copy-to-clipboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ a label ready to be copied to the clipboard.
Using `<dt-copy-to-clipboard-label>` defines the button content (e.g. text like
"click here to copy").

## Inputs

| Name | Type | Default | Description |
| --------- | ------------------------- | --------- | ------------------------------------------------------------- |
| `variant` | `'primary' | 'secondary'` | `primary` | Defines the variant of the embedded copy-to-clipboard button. |

## Outputs

| Name | Type | Description |
Expand Down
1 change: 1 addition & 0 deletions components/copy-to-clipboard/src/copy-to-clipboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<button
dt-button
class="dt-copy-to-clipboard-btn-button"
[variant]="variant"
#copyButton
(click)="copyToClipboard()"
>
Expand Down
5 changes: 5 additions & 0 deletions components/copy-to-clipboard/src/copy-to-clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
Output,
ViewChild,
ViewEncapsulation,
Input,
} from '@angular/core';
import { Subscription, timer } from 'rxjs';

Expand All @@ -34,6 +35,7 @@ import {
removeCssClass,
} from '@dynatrace/barista-components/core';
import { DtInput } from '@dynatrace/barista-components/input';
import { ButtonVariant } from '@dynatrace/barista-components/button';

const DT_COPY_CLIPBOARD_TIMER = 800;
const DT_COPY_TO_CLIPBOARD_SUCCESSFUL = 'dt-copy-to-clipboard-successful';
Expand All @@ -53,6 +55,9 @@ const DT_COPY_TO_CLIPBOARD_SUCCESSFUL = 'dt-copy-to-clipboard-successful';
export class DtCopyToClipboard implements AfterContentInit, OnDestroy {
constructor(private _cd: ChangeDetectorRef) {}

/** Defines the button variant of the copy button. */
@Input() variant: ButtonVariant = 'primary';

/** Emits a stream when the content has been copied. */
@Output() readonly copied: EventEmitter<void> = new EventEmitter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ import { DtExampleCopyToClipboardDark } from './copy-to-clipboard-dark-example/c
import { DtExampleCopyToClipboardDefault } from './copy-to-clipboard-default-example/copy-to-clipboard-default-example';
import { DtExampleCopyToClipboardError } from './copy-to-clipboard-error-example/copy-to-clipboard-error-example';
import { DtExampleCopyToClipboardTextarea } from './copy-to-clipboard-textarea-example/copy-to-clipboard-textarea-example';
import { DtExampleCopyToClipboardSecondaryButton } from './copy-to-clipboard-secondary-button-example/copy-to-clipboard-secondary-button-example';

export const DT_COPY_TO_CLIPBOARD_EXAMPLES = [
DtExampleCopyToClipboardCallback,
DtExampleCopyToClipboardContext,
DtExampleCopyToClipboardDark,
DtExampleCopyToClipboardDefault,
DtExampleCopyToClipboardError,
DtExampleCopyToClipboardSecondaryButton,
DtExampleCopyToClipboardTextarea,
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<dt-copy-to-clipboard variant="secondary">
<input
dtInput
value="https://barista.dynatrace.com/"
aria-label="The value of this input field will be copied to clipboard."
/>
<dt-copy-to-clipboard-label>Copy</dt-copy-to-clipboard-label>
</dt-copy-to-clipboard>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2020 Dynatrace LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Component } from '@angular/core';

@Component({
selector: 'dt-example-copy-to-clipboard-secondary-button',
templateUrl: 'copy-to-clipboard-secondary-button-example.html',
})
export class DtExampleCopyToClipboardSecondaryButton {}

0 comments on commit bbad528

Please sign in to comment.