Skip to content

Commit d8ac2a5

Browse files
author
Jesse Haigh
committed
theme and CopyState const
1 parent bc1fdc1 commit d8ac2a5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/components/ContentNode/CodeListing.vue

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,19 @@
5757
import { escapeHtml } from 'docc-render/utils/strings';
5858
import Language from 'docc-render/constants/Language';
5959
import CodeBlock from 'docc-render/components/CodeBlock.vue';
60-
import CopyIcon from 'docc-render/components/Icons/CopyIcon.vue';
61-
import CheckmarkIcon from 'docc-render/components/Icons/CheckmarkIcon.vue';
62-
import CrossIcon from 'docc-render/components/Icons/CrossIcon.vue';
60+
import CopyIcon from 'theme/components/Icons/CopyIcon.vue';
61+
import CheckmarkIcon from 'theme/components/Icons/CheckmarkIcon.vue';
62+
import CrossIcon from 'theme/components/Icons/CrossIcon.vue';
6363
import { highlightContent, registerHighlightLanguage } from 'docc-render/utils/syntax-highlight';
6464
6565
import CodeListingFilename from './CodeListingFilename.vue';
6666
67+
const CopyState = {
68+
idle: 'idle',
69+
success: 'success',
70+
failure: 'failure',
71+
};
72+
6773
export default {
6874
name: 'CodeListing',
6975
components: {
@@ -76,7 +82,7 @@ export default {
7682
data() {
7783
return {
7884
syntaxHighlightedLines: [],
79-
copyState: 'idle',
85+
copyState: CopyState.idle,
8086
};
8187
},
8288
props: {
@@ -154,15 +160,15 @@ export default {
154160
copyCodeToClipboard() {
155161
navigator.clipboard.writeText(this.copyableText)
156162
.then(() => {
157-
this.copyState = 'success';
163+
this.copyState = CopyState.success;
158164
})
159165
.catch((err) => {
160166
console.error('Failed to copy text: ', err);
161-
this.copyState = 'failure';
167+
this.copyState = CopyState.failure;
162168
})
163169
.finally(() => {
164170
setTimeout(() => {
165-
this.copyState = 'idle';
171+
this.copyState = CopyState.idle;
166172
}, 1000);
167173
});
168174
},

0 commit comments

Comments
 (0)