prevwong / reka.js

💎 State management system to build any no-code editor
https://reka.js.org/
MIT License
646 stars 48 forks source link

feat: add named slots #161

Closed prevwong closed 5 months ago

prevwong commented 5 months ago

Closes #162

This PR adds support to define named slots within a Reka component:

component Card() => (
  <div>
    <slot @name="top" />
   <div>
      <slot />
   </div>
 </div>
)

component App() => (
   <Card>
      <div @slot="top">
         <text value={"Card header"} />
      </div>
      <text value={"Card children"} />
  </Card>
)

This is equivalent to passing React elements as props:

type CardProps = {
  children: React.ReactNode; // slot with no name
  top: React.ReactNode;  // slot with the name "top"
}

const Card = (props: CardProps) => {...}

Named slots may also be useful to support LinkedNodes which currently exists in Craft.

changeset-bot[bot] commented 5 months ago

🦋 Changeset detected

Latest commit: 2eb013c6649d1bc9ccc1131d0a64c0c6b4173a9e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages | Name | Type | | -------------- | ----- | | @rekajs/parser | Patch | | @rekajs/types | Patch | | @rekajs/core | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 5 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
reka ✅ Ready (Inspect) Visit Preview Jun 17, 2024 0:43am