0.4.0 • Published 1 year ago

@ivi/portal v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ivi Portals

EXPERIMENTAL API

Example

import { createRoot, update, component, useState, html } from "ivi";
import { createPortal } from "@ivi/portal";

const [portalContainer, portal] = createPortal();

update(
  createRoot(document.getElementById("overlay")!),
  portalContainer,
);

const App = component((c) => {
  const [visible, setVisible] = useState(c, false);

  const onMouseEnter = () => { setVisible(true); };
  const onMouseLeave = () => { setVisible(false); };

  return () => (
    html`
    <div class="App">
      <span
        @mouseenter=${onMouseEnter}
        @mouseleave=${onMouseLeave}
      >
        Portal Example
      </span>
      ${visible() && portal(html`<span>rendered inside of a portal</span>`)}
    </div>
    `
  );
});

update(
  createRoot(document.getElementById("root")!),
  App(),
);
0.4.0-beta.1

1 year ago

0.4.0

1 year ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago