Stackblitz updates
parent
aa76d94a7e
commit
9ebcae9c55
|
@ -85,7 +85,7 @@ export default {
|
||||||
},
|
},
|
||||||
hideStackBlitz: {
|
hideStackBlitz: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: false
|
||||||
},
|
},
|
||||||
dependencies: {
|
dependencies: {
|
||||||
type: null,
|
type: null,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import pkg from '../../../package.json';
|
||||||
import { services } from './services';
|
import { services } from './services';
|
||||||
|
|
||||||
const PrimeVue = {
|
const PrimeVue = {
|
||||||
version: '^3.50.0',
|
version: '^4.0.0-beta.1',
|
||||||
description:
|
description:
|
||||||
'PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBlock, which has 400+ ready to use UI blocks to build spectacular applications in no time.'
|
'PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBlock, which has 400+ ready to use UI blocks to build spectacular applications in no time.'
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@ const core_dependencies = {
|
||||||
// create-vue -> https://github.com/vuejs/create-vue
|
// create-vue -> https://github.com/vuejs/create-vue
|
||||||
const getVueApp = (props = {}, sourceType) => {
|
const getVueApp = (props = {}, sourceType) => {
|
||||||
const path = 'src/';
|
const path = 'src/';
|
||||||
const { code: sources, title = 'primevue_demo', description = '', service, extPages, dependencies: deps, component, extFiles, embedded } = props;
|
const { code: sources, title = 'primevue_demo', description = '', service, extPages, dependencies: deps, component, extFiles } = props;
|
||||||
const dependencies = { ...core_dependencies, ...deps };
|
const dependencies = { ...core_dependencies, ...deps };
|
||||||
|
|
||||||
const fileExtension = '.vue';
|
const fileExtension = '.vue';
|
||||||
|
@ -29,9 +29,6 @@ const getVueApp = (props = {}, sourceType) => {
|
||||||
const sourceFileName = `${path}${mainFileName}${fileExtension}`;
|
const sourceFileName = `${path}${mainFileName}${fileExtension}`;
|
||||||
let element = '',
|
let element = '',
|
||||||
imports = '',
|
imports = '',
|
||||||
unstyled = '',
|
|
||||||
pvTheme = '',
|
|
||||||
themeSwitchCode = '',
|
|
||||||
routeFiles = {};
|
routeFiles = {};
|
||||||
|
|
||||||
sources.routeFiles &&
|
sources.routeFiles &&
|
||||||
|
@ -41,16 +38,6 @@ const getVueApp = (props = {}, sourceType) => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
let extFilesSource = extFiles
|
|
||||||
? embedded
|
|
||||||
? extFiles['composition']
|
|
||||||
: extFiles[sourceType.language]
|
|
||||||
? { ...extFiles[sourceType.language] }
|
|
||||||
: Object.keys(extFiles)
|
|
||||||
.filter((k) => !sourceTypes.includes(k))
|
|
||||||
.reduce((result, current) => (result[current] = extFiles[current]) && result, {})
|
|
||||||
: {};
|
|
||||||
|
|
||||||
if (deps !== null && component !== null) {
|
if (deps !== null && component !== null) {
|
||||||
imports += `import ${component} from 'primevue/${component.toLowerCase()}';
|
imports += `import ${component} from 'primevue/${component.toLowerCase()}';
|
||||||
`;
|
`;
|
||||||
|
@ -58,33 +45,6 @@ const getVueApp = (props = {}, sourceType) => {
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (embedded) {
|
|
||||||
// main.js
|
|
||||||
unstyled += `, unstyled: true, pt: Tailwind`;
|
|
||||||
imports += `import Tailwind from 'primevue/passthrough/tailwind';
|
|
||||||
import ThemeSwitcher from './components/ThemeSwitcher.vue';`;
|
|
||||||
element += `app.component('ThemeSwitcher', ThemeSwitcher);`;
|
|
||||||
|
|
||||||
// package.json
|
|
||||||
dependencies['tailwindcss'] = '^3.3.2';
|
|
||||||
dependencies['postcss'] = '^8.4.27';
|
|
||||||
dependencies['autoprefixer'] = '^10.4.14';
|
|
||||||
|
|
||||||
// App.vue
|
|
||||||
themeSwitchCode = ''.concat(
|
|
||||||
`<template>
|
|
||||||
<ThemeSwitcher />`,
|
|
||||||
sources.split('<template>')[1]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// main.js
|
|
||||||
pvTheme += `import "primeflex/primeflex.css";
|
|
||||||
import "primevue/resources/themes/aura-light-green/theme.css";`;
|
|
||||||
|
|
||||||
// package.json
|
|
||||||
dependencies['primeflex'] = app_dependencies['primeflex'] || 'latest';
|
|
||||||
}
|
|
||||||
|
|
||||||
const files = {
|
const files = {
|
||||||
'package.json': {
|
'package.json': {
|
||||||
content: {
|
content: {
|
||||||
|
@ -135,16 +95,14 @@ export default defineConfig({
|
||||||
</html>`
|
</html>`
|
||||||
},
|
},
|
||||||
[`${path}main.js`]: {
|
[`${path}main.js`]: {
|
||||||
content: `${pvTheme}
|
content: `import "primeicons/primeicons.css";
|
||||||
import "primevue/resources/primevue.min.css"; /* Deprecated */
|
|
||||||
import "primeicons/primeicons.css";
|
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
import "./flags.css";
|
import "./flags.css";
|
||||||
|
|
||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import { router } from "./router";
|
import { router } from "./router";
|
||||||
import PrimeVue from "primevue/config";
|
import PrimeVueStyled from "primevue/styled";
|
||||||
import AutoComplete from 'primevue/autocomplete';
|
import AutoComplete from 'primevue/autocomplete';
|
||||||
import Accordion from 'primevue/accordion';
|
import Accordion from 'primevue/accordion';
|
||||||
import AccordionTab from 'primevue/accordiontab';
|
import AccordionTab from 'primevue/accordiontab';
|
||||||
|
@ -254,7 +212,7 @@ ${imports}
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
app.use(PrimeVue, { ripple: true ${unstyled} });
|
app.use(PrimeVueStyled);
|
||||||
app.use(ConfirmationService);
|
app.use(ConfirmationService);
|
||||||
app.use(ToastService);
|
app.use(ToastService);
|
||||||
app.use(DialogService);
|
app.use(DialogService);
|
||||||
|
@ -369,7 +327,7 @@ app.mount("#app");
|
||||||
`
|
`
|
||||||
},
|
},
|
||||||
[`${path}style.css`]: {
|
[`${path}style.css`]: {
|
||||||
content: embedded ? tailwindConfig : staticStyles.global
|
content: staticStyles.global
|
||||||
},
|
},
|
||||||
[`${path}flags.css`]: {
|
[`${path}flags.css`]: {
|
||||||
content: staticStyles.flags
|
content: staticStyles.flags
|
||||||
|
@ -384,7 +342,7 @@ export const router = createRouter({
|
||||||
});`
|
});`
|
||||||
},
|
},
|
||||||
[`${sourceFileName}`]: {
|
[`${sourceFileName}`]: {
|
||||||
content: embedded ? themeSwitchCode : sources
|
content: sources
|
||||||
},
|
},
|
||||||
'public/logo.svg': {
|
'public/logo.svg': {
|
||||||
content: `
|
content: `
|
||||||
|
@ -415,7 +373,7 @@ export const router = createRouter({
|
||||||
</svg>`
|
</svg>`
|
||||||
},
|
},
|
||||||
...routeFiles,
|
...routeFiles,
|
||||||
...extFilesSource
|
...extFiles
|
||||||
};
|
};
|
||||||
|
|
||||||
if (extPages && extPages.length >= 1) {
|
if (extPages && extPages.length >= 1) {
|
||||||
|
@ -450,67 +408,40 @@ export const router = createRouter({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (embedded) {
|
|
||||||
files['tailwind.config.js'] = {
|
|
||||||
content: `/** @type {import('tailwindcss').Config} */
|
|
||||||
export default {
|
|
||||||
darkMode: 'class',
|
|
||||||
content: [
|
|
||||||
"./index.html",
|
|
||||||
"./src/**/*.{vue,js,ts,jsx,tsx}",
|
|
||||||
"./node_modules/primevue/**/*.{vue,js,ts,jsx,tsx}"
|
|
||||||
],
|
|
||||||
theme: {
|
|
||||||
extend: {}
|
|
||||||
},
|
|
||||||
plugins: []
|
|
||||||
}`
|
|
||||||
};
|
|
||||||
|
|
||||||
files['postcss.config.js'] = {
|
|
||||||
content: `module.exports = {
|
|
||||||
plugins: {
|
|
||||||
tailwindcss: {},
|
|
||||||
autoprefixer: {}
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
};
|
|
||||||
|
|
||||||
files[`${path}components/ThemeSwitcher.vue`] = {
|
|
||||||
content: `<template>
|
|
||||||
<div class="card flex justify-end p-2 mb-4">
|
|
||||||
<button type="button" class="flex border-1 w-2rem h-2rem p-0 align-center justify-center" @click="onThemeToggler">
|
|
||||||
<i :class="\`dark:text-white pi \${iconClass}\`" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {ref} from 'vue';
|
|
||||||
const iconClass = ref('pi-moon');
|
|
||||||
|
|
||||||
const onThemeToggler = () => {
|
|
||||||
const root = document.getElementsByTagName('html')[0];
|
|
||||||
|
|
||||||
root.classList.toggle('dark');
|
|
||||||
iconClass.value = iconClass.value === 'pi-moon' ? 'pi-sun': 'pi-moon';
|
|
||||||
};
|
|
||||||
</script>`
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return { files, dependencies, sourceFileName };
|
return { files, dependencies, sourceFileName };
|
||||||
};
|
};
|
||||||
|
|
||||||
const staticStyles = {
|
const staticStyles = {
|
||||||
global: `html {
|
global: `:root {
|
||||||
|
--primary-text-color: var(--p-primary-600);
|
||||||
|
--primary-color: var(--p-primary-color);
|
||||||
|
--primary-inverse-color: var(--p-primary-inverse-color);
|
||||||
|
--primary-hover-color: var(--p-primary-hover-color);
|
||||||
|
--text-color: var(--p-surface-700);
|
||||||
|
--text-secondary-color: var(--p-surface-500);
|
||||||
|
--ground-background: var(--p-surface-50);
|
||||||
|
--card-background: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[class='p-dark'] {
|
||||||
|
--primary-text-color: var(--p-primary-400);
|
||||||
|
--primary-color: var(--p-primary-color);
|
||||||
|
--primary-inverse-color: var(--p-primary-inverse-color);
|
||||||
|
--primary-hover-color: var(--p-primary-hover-color);
|
||||||
|
--text-color: var(--p-surface-0);
|
||||||
|
--text-secondary-color: var(--p-surface-400);
|
||||||
|
--ground-background: var(--p-surface-950);
|
||||||
|
--card-background: var(--p-surface-900);
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
font-family: "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: var(--font-family);
|
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
background: var(--surface-ground);
|
background: var(--ground-background);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
|
@ -518,7 +449,7 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
background: var(--surface-card);
|
background: var(---card-background);
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
|
|
Loading…
Reference in New Issue