Module: sjdon
Type Aliases
SjdonElement
Ƭ SjdonElement: [SjdonElementType
, ...(SjdonElementOrPrimitive | Props)[]]
A SjdonElement
is an array containing at least one element.
The first element is of type SjdonElementType and specifies the type of the SjdonElement
.
The other elements are either children or props of the element.
Chidren can be either a complete SjdonElement
or a Primitive.
Props are always an object of type Props.
Example
// a heading 1 with no content
const minimalElement: SjdonElement = ['h1']
// a div containing a text and a paragraph
const elementWithChildren: SjdonElement = ['div', 'Test', ['p', 'Hello World!']]
// a button with specified onclick props and a text child.
const elementWithProps: SjdonElement = [
'button',
{ onclick: () => console.log('Button clicked!') },
'Click me!'
]
Defined in
SjdonElementFunction
Ƭ SjdonElementFunction<T
>: (props?
: T
& { children?
: SjdonElementOrPrimitive
[] }) => SjdonElement
Type parameters
Name | Type |
---|---|
T | Record <string , unknown > |
Type declaration
▸ (props?
): SjdonElement
A SjdonElementFunction
takes in props as a parameter and returns a SjdonElement.
Parameters
Name | Type | Description |
---|---|---|
props? | T & { children? : SjdonElementOrPrimitive [] } | The props of the element. Children are automatically passed via the reserved children property. |
Returns
Defined in
SjdonElementOrPrimitive
Ƭ SjdonElementOrPrimitive: SjdonElement
| Primitive
A SjdonElementOrPrimitive
is either a SjdonElement or a Primitive.
Defined in
SjdonElementType
Ƭ SjdonElementType: keyof HTMLElementTagNameMap
| SjdonElementFunction
The type of a SjdonElement, which is specified in the first element of the array. It can either be a HTML tag or a SjdonElementFunction.
Defined in
Functions
parseSjdon
▸ parseSjdon<T
>(param0
, create
): T
Parses a SjdonElement with all its children and creates a fiber tree. Uses the createElement function to create all fibers.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
param0 | SjdonElement | The SjdonElement which should be parsed. |
create | CreateElementFunction <T > | The function which is used to create the elements. It works properly with the SuiWeb implementation createElement, but also other implementations, like React.createElement , could be used. Note, however, that this is only partially supported, as the typing don't match and the props are not fully compatible. |
Returns
T
The root element of the tree containing all children.