vobyjs / voby

A high-performance framework with fine-grained observable-based reactivity for building rich applications.
https://voby.dev
MIT License
879 stars 22 forks source link

Template seems not to support children props #30

Open derolf opened 9 months ago

derolf commented 9 months ago

Here's a template for a Row:

export const Row = template(
  (props: { style?: JSX.StyleProperties; children?: JSX.Children }) => {
    props = {
      ...props,
      style: {
        display: "flex",
        flexDirection: "row",
        ...props.style,
      },
    };
    return <div {...props} />;
  },
);

Example usage:

<Row>test</Row>

Renders:

<div style="display: flex; flex-direction: row;"></div>

Expected:

<div style="display: flex; flex-direction: row;">test</div>
fabiospampinato commented 9 months ago

The template helper is a bit of a gimmick right now, very limited usage. Eventually it will probably be replaced with just more optimized tagged template literals, and an opt-in way to convert JSX to that at build time.