import { type JSX, createContext, useContext } from 'solid-js' import { Dynamic } from 'solid-js/web' import { cx } from 'styled-system/css' import { isCssProperty, styled } from 'styled-system/jsx' import type { ElementType, StyledComponent } from 'styled-system/types' type Props = Record type Recipe = { (props?: Props): Props splitVariantProps: (props: Props) => [Props, Props] } type Slot = keyof ReturnType type Options = { forwardProps?: string[] } const shouldForwardProp = (prop: string, variantKeys: string[], options: Options = {}) => options.forwardProps?.includes(prop) || (!variantKeys.includes(prop) && !isCssProperty(prop)) export const createStyleContext = (recipe: R) => { const StyleContext = createContext, string> | null>(null) const withRootProvider =

(Component: ElementType): ((props: P) => JSX.Element) => { const StyledComponent = (props: P) => { const [variantProps, localProps] = recipe.splitVariantProps(props) const slotStyles = recipe(variantProps) as Record, string> return ( ) } return StyledComponent } const withProvider =

( Component: ElementType, slot: Slot, options?: Options, ): ((props: P) => JSX.Element) => { const StyledComponent = styled( Component, {}, { shouldForwardProp: (prop, variantKeys) => shouldForwardProp(prop, variantKeys, options), }, ) as StyledComponent return (props: P) => { const [variantProps, localProps] = recipe.splitVariantProps(props) const slotStyles = recipe(variantProps) as Record, string> return ( ) } } const withContext =

( Component: ElementType, slot: Slot, ): ((props: P) => JSX.Element) => { const StyledComponent = styled(Component) const Foo = (props: P) => { const slotStyles = useContext(StyleContext) return ( ) } return Foo } return { withRootProvider, withProvider, withContext, } }