From dbbe580ef12e247487f59f2bb6e8ca741de1410e Mon Sep 17 00:00:00 2001 From: konnorrogers Date: Tue, 11 Jun 2024 17:08:34 -0400 Subject: [PATCH] prettier --- src/components/copy-button/copy-button.ts | 83 ++++++++++++----------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/src/components/copy-button/copy-button.ts b/src/components/copy-button/copy-button.ts index dd1835c22..8c75e8c06 100644 --- a/src/components/copy-button/copy-button.ts +++ b/src/components/copy-button/copy-button.ts @@ -55,6 +55,18 @@ export default class WaCopyButton extends WebAwesomeElement { @state() isCopying = false; @state() status: 'rest' | 'success' | 'error' = 'rest'; + private get currentLabel() { + if (this.status === 'success') { + return this.successLabel || this.localize.term('copied'); + } + + if (this.status === 'error') { + return this.errorLabel || this.localize.term('error'); + } + + return this.copyLabel || this.localize.term('copy'); + } + /** The text value to copy. */ @property() value = ''; @@ -156,13 +168,8 @@ export default class WaCopyButton extends WebAwesomeElement { } private async showStatus(status: 'success' | 'error') { - const copyLabel = this.copyLabel || this.localize.term('copy'); - const successLabel = this.successLabel || this.localize.term('copied'); - const errorLabel = this.errorLabel || this.localize.term('error'); const iconToShow = status === 'success' ? this.successIcon : this.errorIcon; - this.tooltip.content = status === 'success' ? successLabel : errorLabel; - // Show the feedback icon await animateWithClass(this.copyIcon, 'hide'); this.copyIcon.hidden = true; @@ -178,50 +185,48 @@ export default class WaCopyButton extends WebAwesomeElement { this.copyIcon.hidden = false; await animateWithClass(this.copyIcon, 'show'); - this.tooltip.content = copyLabel; this.isCopying = false; }, this.feedbackDuration); } render() { - const copyLabel = this.copyLabel || this.localize.term('copy'); - return html` - - - + `; } }