mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Theming API: update nuxt-primevue module
This commit is contained in:
parent
b5e53e6fa3
commit
a5dff7722e
11 changed files with 46 additions and 50 deletions
|
@ -51,7 +51,12 @@ export default defineNuxtModule({
|
|||
|
||||
const styleContent = () => `
|
||||
${registered.styles.map((style) => `import ${style.as} from '${style.from}';`).join('\n')}
|
||||
${importTheme ? `import ${importTheme.as} from '${importTheme.from}';\n` : ''}
|
||||
${
|
||||
importTheme
|
||||
? `import Theme from 'primevue/themes';
|
||||
import ${importTheme.as} from '${importTheme.from}';\n`
|
||||
: ''
|
||||
}
|
||||
|
||||
const styleProps = {
|
||||
${options?.csp?.nonce ? `nonce: ${options?.csp?.nonce}` : ''}
|
||||
|
@ -61,9 +66,11 @@ const styles = [
|
|||
${registered.styles.map((item) => `${item.as} && ${item.as}.getStyleSheet ? ${item.as}.getStyleSheet(undefined, styleProps) : ''`).join(',')}
|
||||
].join('');
|
||||
|
||||
${importTheme ? `Theme.setTheme(${importTheme.as})` : ''}
|
||||
|
||||
const themes = [
|
||||
${importTheme ? `${registered.styles[0].as} && ${registered.styles[0].as}.getCommonThemeStyleSheet ? ${registered.styles[0].as}.getCommonThemeStyleSheet(${importTheme?.as}, undefined, styleProps) : ''` : ''},
|
||||
${importTheme ? registered.styles.map((item) => `${item.as} && ${item.as}.getThemeStyleSheet ? ${item.as}.getThemeStyleSheet(${importTheme?.as}, undefined, styleProps) : ''`).join(',') : ''}
|
||||
${importTheme ? `${registered.styles[0].as} && ${registered.styles[0].as}.getCommonThemeStyleSheet ? ${registered.styles[0].as}.getCommonThemeStyleSheet(undefined, styleProps) : ''` : ''},
|
||||
${importTheme ? registered.styles.map((item) => `${item.as} && ${item.as}.getThemeStyleSheet ? ${item.as}.getThemeStyleSheet(undefined, styleProps) : ''`).join(',') : ''}
|
||||
].join('');
|
||||
|
||||
export { styles, themes };
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @ts-expect-error
|
||||
import { styles } from '#primevue-style';
|
||||
import { styles, themes } from '#primevue-style';
|
||||
//import { useRuntimeConfig } from '#imports';
|
||||
|
||||
const defineNitroPlugin = (def) => def;
|
||||
|
@ -7,7 +7,7 @@ const defineNitroPlugin = (def) => def;
|
|||
export default defineNitroPlugin(async (nitroApp) => {
|
||||
nitroApp.hooks.hook('render:html', (html) => {
|
||||
html.head.push(styles);
|
||||
//html.head.push(themes);
|
||||
html.head.push(themes);
|
||||
//html.htmlAttrs.push('class="p-dark"'); // @todo
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue