Compare commits
2 Commits
860ceba320
...
a1578a770a
| Author | SHA1 | Date | |
|---|---|---|---|
| a1578a770a | |||
| 30db3822d6 |
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@because/forge",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"type": "module",
|
||||
"main": "src/index.tsx",
|
||||
"module": "src/index.tsx",
|
||||
|
|
|
|||
|
|
@ -286,14 +286,18 @@ export function define(nameOrDef: string | TagDef, defIfNamed?: TagDef) {
|
|||
if (styles[`.${name}`]) throw `${name} is already defined! Must use unique names.`
|
||||
registerStyles(name, def)
|
||||
|
||||
const currentProps: Record<string, any> = {}
|
||||
const Root = makeComponent(name, def, currentProps)
|
||||
|
||||
return (props: Record<string, any>) => {
|
||||
const parts: Record<string, Function> = {}
|
||||
for (const key in currentProps) delete currentProps[key]
|
||||
Object.assign(currentProps, props)
|
||||
const parts: Record<string, Function> = { Root }
|
||||
|
||||
for (const [part] of Object.entries(def.parts ?? {}))
|
||||
parts[part] = makeComponent(name, def, props, part)
|
||||
|
||||
parts.Root = makeComponent(name, def, props)
|
||||
return def.render?.({ props, parts }) ?? <parts.Root {...props}>{props.children}</parts.Root>
|
||||
return def.render?.({ props, parts }) ?? <Root {...props}>{props.children}</Root>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user