diff --git a/apps/showcase/components/layout/AppDesigner.vue b/apps/showcase/components/layout/AppDesigner.vue index 931600def..27cc4ae1e 100644 --- a/apps/showcase/components/layout/AppDesigner.vue +++ b/apps/showcase/components/layout/AppDesigner.vue @@ -54,8 +54,8 @@ @@ -85,6 +85,38 @@ export default { methods: { apply() { updatePreset(this.preset); + }, + download() { + const theme = JSON.stringify(this.preset, null, 4).replace(/"([^"]+)":/g, '$1:'); + const textContent = `import { createApp } from "vue"; +import PrimeVue from "primevue/config"; +import Aura from "@primevue/themes/aura"; +import { definePreset } from "@primevue/themes"; + +const app = createApp(App); + +const MyPreset = definePreset(Aura, ${theme}); + +app.use(PrimeVue, { + theme: { + preset: MyPreset + }, +}); +app.mount("#app"); +`; + const blob = new Blob([textContent], { type: 'text/plain' }); + + const url = URL.createObjectURL(blob); + + const a = document.createElement('a'); + + a.href = url; + a.download = 'mytheme.js'; + document.body.appendChild(a); + a.click(); + + document.body.removeChild(a); + URL.revokeObjectURL(url); } } };