@@ -6,22 +6,28 @@ import { stringifyHastNode } from './stringify-hast-node-as-jsx'
6
6
import { toReactProps } from './to-react-props'
7
7
import { format } from './format'
8
8
import { getPropSyntax } from './util'
9
+ import { CodegenOptions } from './types'
10
+ import { Theme } from '../../types/theme'
9
11
10
- const h = ( tagName : string , props : any , children ?: any [ ] ) => {
11
- const newProps = toReactProps ( props )
12
+ const h =
13
+ ( theme ?: Theme ) => ( tagName : string , props : any , children ?: any [ ] ) => {
14
+ const newProps = toReactProps ( props )
12
15
13
- if ( newProps . style ) {
14
- const style = newProps . style
15
- delete newProps . style
16
- newProps . sx = toCSSObject ( style )
17
- }
16
+ if ( newProps . style ) {
17
+ const style = newProps . style
18
+ delete newProps . style
19
+ newProps . sx = toCSSObject ( style , theme )
20
+ }
18
21
19
- return { tagName, props : newProps , children }
20
- }
22
+ return { tagName, props : newProps , children }
23
+ }
21
24
22
- export const themeUI = async ( node : HtmlNode ) => {
25
+ export const themeUI = async (
26
+ node : HtmlNode ,
27
+ { theme } : CodegenOptions = { }
28
+ ) => {
23
29
const root = editorSchemaToHast ( node , { addSlotSyntax : true } )
24
- const functionBody = stringifyHastNode ( toH ( h , root ) )
30
+ const functionBody = stringifyHastNode ( toH ( h ( theme ) , root ) )
25
31
26
32
const output = `
27
33
/** @jsxImportSource theme-ui */
0 commit comments