Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 9433c77

Browse files
committed
feat(vue-system): add StyleProvider
1 parent a46df86 commit 9433c77

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

packages/system/src/composables/use-style-config.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { computed, ComputedRef, inject, provide, ref } from 'vue'
1+
import { computed, ComputedRef } from 'vue'
22

33
import { SystemStyleObject } from '@chakra-ui/styled-system'
44
import { ChakraComponentName, ComponentThemeConfig } from '@chakra-ui/vue-theme'
@@ -83,18 +83,3 @@ export function useMultiStyleConfig(
8383
) {
8484
return useStyleConfig(themeKey, themingProps, { isMultiPart: true })
8585
}
86-
87-
/** Provides Chakra Multi-parted component styles to descendants */
88-
export const provideComponentStyles = (
89-
component: AllThemedComponents,
90-
styles: SystemStyleObject
91-
) => {
92-
provide<SystemStyleObject>(`$chakra${component}Styles`, styles)
93-
}
94-
95-
/** Injects Chakra Multi-parted component styles from ancestor */
96-
export const useComponentStyles = (component: AllThemedComponents) => {
97-
return inject<Record<string, SystemStyleObject> & SystemStyleObject & any>(
98-
`$chakra${component}Styles`
99-
)
100-
}

packages/system/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './chakra'
2+
export * from './providers'
23
export * from './system.attrs'
34
export * from './system.types'
45
export * from './system.utils'

packages/system/src/providers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createContext, Dict } from '@chakra-ui/vue-utils'
2+
import { SystemStyleObject } from '@chakra-ui/styled-system'
3+
4+
const [StylesProvider, useStyles] = createContext<Dict<SystemStyleObject>>({
5+
name: 'StylesContext',
6+
errorMessage:
7+
'useStyles: `styles` is undefined. Seems you forgot to provide `StylesProvider(...)` ',
8+
})
9+
10+
export { StylesProvider, useStyles }

0 commit comments

Comments
 (0)