question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mitosis <Slot> support

See original GitHub issue

Mitosis needs content projection and we can support this by adding this to the jsx parser

<Layout>
  <Slot top={<NavBar/>} />
  <Slot left={<Sidebar/>} />
  <Slot center={<Content/>} />
  anything else
</Layout>
function Layout(props) {
  return (
    <div className="layout">
      <div className="top">
        <Slot name={props.top} />
      </div>
      <div className="left">
        <Slot name={props.left} />
      </div>
      <div className="center">
        <Slot name={props.center} />
      </div>
      <Slot />
    </div>
  );
}

When we see child slots without name we will just extend <Layout> props (the parent node). Inside Layout component when we see any <Slot> with name attribute we can replace that slow node with the reference to the prop. I think we should require slot in the name just as we do with on keywords

we can also provide a slot attributes

<Layout
  slot={
    {
      top: <NavBar/>,
      left: <Sidebar/>,
      center: <Content/>
    }
  }
/>
  anything else
</Layout>

or just like how we use on keyword we can do the same with slot

<Layout
  slotTop={<NavBar/>}
  slotLeft={<Sidebar/>}
  slotCenter={<Content/>}
/>
  anything else
</Layout>

In React we would write it as

<Layout
  left={<Sidebar/>}
  top={<NavBar/>}
  center={<Content/>}
>
  anything else
</Layout>
function Layout(props) {
  return (
    <div className="layout">
      <div className="top">
        {props.top}
      </div>
      <div className="left">
        {props.left}
      </div>
      <div className="center">
        {props.center}
      </div>
      {props.children}
    </div>
  );
}

we can also create a react convention for slots requiring slot to be in the name

<Layout
  slotLeft={<Sidebar/>}
  slotTop={<NavBar/>}
  slotCenter={<Content/>}
>
  anything else
</Layout>
function Layout(props) {
  return (
    <div className="layout">
      <div className="top">
        {props.slotTop}
      </div>
      <div className="left">
        {props.slotLeft}
      </div>
      <div className="center">
        {props.slotCenter}
      </div>
      {props.children}
    </div>
  );
}

angular we can use the attribute names and props var names to determine the correct selectors. Even if the names have slot prepended we can remove it to determine what the real name is.

<layout>
  <sidebar left></sidebar>
  <nav-bar top></nav-bar>
  <content center></content>
  anything else
</layout>
template: /*html*/`
    <div class="layout">
      <div class="top">
        <ng-content select="[top]"></ng-content>
      </div>
      <div class="left">
        <ng-content select="[left]"></ng-content>
      </div>
      <div class="center">
        <ng-content select="[center]"></ng-content>
      </div>
      <ng-content></ng-content>
    </div>
`

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
steve8708commented, May 8, 2022

This is exactly in line with what I’ve wanted to do for this, looks great to me 👍🏼

0reactions
PatrickJScommented, May 17, 2022

I’m going to close this since the jsx-way is done. We can the html-way later if others prefer like vue/angular users

Read more comments on GitHub >

github_iconTop Results From Across the Web

BuilderIO/mitosis: Write components once, run ... - GitHub
Write components once, run everywhere. Compiles to Vue, React, Solid, Angular, Svelte, and more. - GitHub - BuilderIO/mitosis: Write components once, ...
Read more >
Manipulating cultured mammalian cells for mitosis research
Cultured cells grown on glass coverslips require some type of support to facilitate imaging. For those labs using inverted microscopes for ...
Read more >
BIL 151 - Mechanisms of Mitosis - This is bio.miami.edu
This procedure will help you perform a successful chromosome squash. You will probably need to practice it several times before getting a good...
Read more >
Lysosomal Changes in Mitosis - Cells - MDPI
Mitotic cells had significantly reduced levels of lysosomal-associated membrane ... This is supported by data showing that cholesterol supplementation ...
Read more >
Mitosis is like a copy machine" and "Meiosis is like a slot ...
This is a modal window. The media could not be loaded, either because the server or network failed or because the format is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found