Skip to content

Revert "fix(provider): [theme] incorrect object type provide to component tree" #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/src/providers/theme.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { defineComponent, h, PropType, provide, reactive, ref, watch } from 'vue'
import { defineComponent, h, PropType, provide, ref, watch } from 'vue'

Check failure on line 1 in packages/core/src/providers/theme.ts

View workflow job for this annotation

GitHub Actions / type-check

Cannot find module 'vue' or its corresponding type declarations.

Check failure on line 1 in packages/core/src/providers/theme.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find module 'vue' or its corresponding type declarations.

export interface DefaultTheme {
[key: string]: any
}

export const ThemeProvider = defineComponent(
(props, { slots }) => {

Check failure on line 8 in packages/core/src/providers/theme.ts

View workflow job for this annotation

GitHub Actions / type-check

Parameter 'props' implicitly has an 'any' type.

Check failure on line 8 in packages/core/src/providers/theme.ts

View workflow job for this annotation

GitHub Actions / build

Parameter 'props' implicitly has an 'any' type.
const theme = ref(props.theme)
provide('$theme', reactive(theme.value as DefaultTheme))
provide('$theme', theme)

watch(
() => props.theme,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
onUnmounted,
PropType,
PublicProps,
reactive,
Ref,
SlotsType,
watch,
} from 'vue'
Expand Down Expand Up @@ -66,9 +66,9 @@ function baseStyled<P extends Record<string, any>>(target: string | InstanceType
return defineComponent(
(props, { slots }) => {
const myAttrs = { ...attributes }
const theme = inject<Record<string, string | number>>('$theme', reactive({}))
const theme = inject<Ref<Record<string, string | number>>>('$theme')
let context = {
theme,
theme: theme?.value ?? {},
...props,
}

Expand All @@ -78,7 +78,7 @@ function baseStyled<P extends Record<string, any>>(target: string | InstanceType
[theme, props],
() => {
context = {
theme,
theme: theme?.value ?? {},
...props,
}
injectStyle<T & { theme: DefaultTheme }>(myAttrs.class, cssWithExpression, context)
Expand Down
Loading