Skip to content

Commit 1c2d806

Browse files
committed
chore: 🤖 replace CopyButton usage with Hds::CopyButton
1 parent f9a9f67 commit 1c2d806

File tree

3 files changed

+5
-39
lines changed

3 files changed

+5
-39
lines changed

‎addons/rose/addon/components/rose/code-editor/toolbar/index.hbs‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@
2121
data-test-code-editor-toolbar-menu-divider
2222
></div>
2323
{{/if}}
24-
<CopyButton
25-
@text={{@copyText}}
24+
<Hds::Copy::Button
25+
@text='Copy code'
26+
@textToCopy={{@copyText}}
2627
@onSuccess={{this.copied}}
27-
class='rose-code-editor-toolbar__copy-button'
2828
data-test-code-editor-toolbar-copy-button
29-
>
30-
<Hds::Icon @name={{this.copyIconType}} @isInline={{true}} />
31-
Copy code
32-
</CopyButton>
29+
/>
3330
</div>
3431
</div>

‎addons/rose/addon/components/rose/code-editor/toolbar/index.js‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,11 @@
44
*/
55

66
import Component from '@glimmer/component';
7-
import { tracked } from '@glimmer/tracking';
87
import { action } from '@ember/object';
9-
import { later } from '@ember/runloop';
10-
11-
export const COPY_ICON_TYPE = 'clipboard-copy';
12-
export const COPIED_ICON_TYPE = 'clipboard-checked';
138

149
export default class RoseCodeEditorToolbarComponent extends Component {
15-
@tracked copyIconType = COPY_ICON_TYPE;
16-
1710
@action
1811
copied() {
19-
let { onCopy } = this.args;
20-
let originalIconType = this.copyIconType;
21-
22-
this.copyIconType = COPIED_ICON_TYPE;
23-
24-
if (onCopy) {
25-
onCopy();
26-
}
27-
// eslint-disable-next-line ember/no-runloop
28-
later(() => (this.copyIconType = originalIconType), 1000);
12+
this.args.onCopy?.();
2913
}
3014
}

‎addons/rose/app/styles/rose/components/code-editor/_index.scss‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,4 @@
6767
height: sizing.rems(xl);
6868
}
6969
}
70-
71-
&__copy-button {
72-
border: none;
73-
background-color: inherit;
74-
cursor: pointer;
75-
color: var(--ui-gray-starker-2);
76-
margin-right: sizing.rems(xs);
77-
margin-left: sizing.rems(s);
78-
height: sizing.rems(xl);
79-
white-space: nowrap;
80-
81-
.hds-icon {
82-
vertical-align: top;
83-
}
84-
}
8570
}

0 commit comments

Comments
 (0)