Skip to content

Commit cdc9828

Browse files
author
shleewhite
committed
add copy button styles
1 parent 6c6dd12 commit cdc9828

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

website/app/components/doc/code-group/index.gts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ export default class DocCodeGroup extends Component<DocCodeGroupSignature> {
9494
return label;
9595
}
9696

97+
get copyButtonClassNames() {
98+
const classNames = ['doc-code-group__copy-button'];
99+
if (this.copyStatus === 'success') {
100+
classNames.push('doc-code-group__copy-button--status-success');
101+
} else if (this.copyStatus === 'error') {
102+
classNames.push('doc-code-group__copy-button--status-error');
103+
}
104+
return classNames.join(' ');
105+
}
106+
97107
handleGtsExpandClick = () => {
98108
this.isExpanded = !this.isExpanded;
99109
this.expandIconName = this.isExpanded ? 'unfold-close' : 'unfold-open';
@@ -162,7 +172,7 @@ export default class DocCodeGroup extends Component<DocCodeGroupSignature> {
162172
<button
163173
type="button"
164174
aria-label={{this.copyButtonLabel}}
165-
class="doc-code-group__copy-button"
175+
class={{this.copyButtonClassNames}}
166176
{{docClipboard
167177
text=this.currentViewSnippet
168178
onSuccess=this.onSuccess

website/app/styles/doc-components/code-group.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,19 @@
6767
border-radius: 4px;
6868
cursor: pointer;
6969

70-
71-
&:hover {
70+
&:hover {
7271
background-color: var(--doc-color-gray-600);
7372
}
73+
74+
&.doc-code-group__copy-button--status-success {
75+
color: var(--doc-color-feedback-success-100);
76+
background-color: var(--doc-color-feedback-success-300);
77+
}
78+
79+
&.doc-code-group__copy-button--status-error {
80+
color: var(--doc-color-feedback-critical-100);
81+
background-color: var(--doc-color-feedback-critical-300);
82+
}
7483
}
7584
}
7685
}

0 commit comments

Comments
 (0)