From 97f3e3c7479f0d01216c33f64a709f7143456fb9 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 18 Jul 2021 16:54:36 +0100 Subject: [PATCH] :sparkles: Adds export styles functionality --- src/components/Settings/CustomThemeMaker.vue | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/Settings/CustomThemeMaker.vue b/src/components/Settings/CustomThemeMaker.vue index 08fc3a0b..30614d30 100644 --- a/src/components/Settings/CustomThemeMaker.vue +++ b/src/components/Settings/CustomThemeMaker.vue @@ -31,6 +31,9 @@ /> +

+ Export Custom Variables +

Reset Styles for '{{ themeToEdit }}'

@@ -101,6 +104,15 @@ export default { this.customColors = this.makeInitialData(mainCssVars); this.saveChanges(); }, + exportToClipboard() { + const themeName = this.themeToEdit.replace(/^\w/, c => c.toUpperCase()); + let clipboardText = `// Custom Colors for ${themeName}\n`; + Object.keys(this.customColors).forEach((customVar) => { + clipboardText += (`--${customVar}: ${this.customColors[customVar]};\n`); + }); + navigator.clipboard.writeText(clipboardText); + this.$toasted.show(`Theme data for ${themeName} copied to clipboard`); + }, /* Returns a JSON object, with the variable name as key, and color as value */ makeInitialData(variableArray) { const data = {}; @@ -168,6 +180,7 @@ export default {