-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #5502 - Add PrimeVueStyled and PrimeVueUnstyled plugins
- Loading branch information
1 parent
0e70f79
commit 71715f5
Showing
7 changed files
with
85 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '../config'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as PrimeVueConfig from 'primevue/config'; | ||
import Theme, { ThemeService } from 'primevue/themes'; | ||
import PrimeOne from 'primevue/themes/primeone'; | ||
import Aura from 'primevue/themes/primeone/aura'; | ||
import { ref, watch } from 'vue'; | ||
|
||
export const defaultOptions = { | ||
...PrimeVueConfig.defaultOptions, | ||
theme: { | ||
base: PrimeOne, | ||
preset: Aura, | ||
options: { | ||
prefix: 'p', | ||
darkModeSelector: 'system', | ||
cssLayer: false | ||
} | ||
} | ||
}; | ||
|
||
export const { usePrimeVue } = PrimeVueConfig; | ||
|
||
function setupTheme(app, PrimeVue) { | ||
const isChanged = ref(false); | ||
|
||
watch( | ||
PrimeVue.config.theme, | ||
(newValue) => { | ||
if (!isChanged.value) { | ||
Theme.setTheme(newValue); | ||
} | ||
|
||
isChanged.value = false; | ||
}, | ||
{ immediate: true, deep: true } | ||
); | ||
|
||
ThemeService.on('theme:change', function (newTheme) { | ||
isChanged.value = true; | ||
app.config.globalProperties.$primevue.config.theme = newTheme; | ||
}); | ||
} | ||
|
||
export default { | ||
install: (app, options) => { | ||
const configOptions = { ...defaultOptions, ...options, unstyled: false }; | ||
const PrimeVue = PrimeVueConfig.setup(app, configOptions); | ||
|
||
setupTheme(app, PrimeVue); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"main": "./primevuestyled.cjs.js", | ||
"module": "./primevuestyled.esm.js", | ||
"unpkg": "./primevuestyled.min.js", | ||
"types": "./PrimeVueStyled.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '../config'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as PrimeVueConfig from 'primevue/config'; | ||
|
||
export const { defaultOptions, usePrimeVue } = PrimeVueConfig; | ||
|
||
export default { | ||
install: (app, options) => { | ||
const configOptions = { ...defaultOptions, ...options, unstyled: true }; | ||
|
||
PrimeVueConfig.setup(app, configOptions); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"main": "./primevueunstyled.cjs.js", | ||
"module": "./primevueunstyled.esm.js", | ||
"unpkg": "./primevueunstyled.min.js", | ||
"types": "./PrimeVueUnstyled.d.ts" | ||
} |