Skip to content

Commit 645b949

Browse files
feat: make theme injection reactive
1 parent a07004f commit 645b949

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/models/StyledComponent.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ export default (ComponentStyle) => {
3030
setup (props, { slots, attrs, emit }) {
3131
const theme = inject('theme')
3232

33+
const finalTheme = theme && theme.value ? theme.value : theme
34+
3335
return () => {
34-
const styleClass = componentStyle.generateAndInjectStyles({ theme, ...props, ...attrs })
36+
const styleClass = componentStyle.generateAndInjectStyles({ theme: finalTheme, ...props, ...attrs })
3537
const classes = [styleClass]
3638

3739
if (attrs.class) {

src/providers/ThemeProvider.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { h, provide } from 'vue'
1+
import { h, provide, toRefs } from 'vue'
22

33
export default {
44
props: {
55
theme: Object
66
},
7-
setup (props, { slots }) {
8-
provide('theme', props.theme)
7+
setup (props) {
8+
const { theme } = toRefs(props)
9+
10+
provide('theme', theme)
911
},
1012

1113
render () {

0 commit comments

Comments
 (0)