0.3.1 • Published 1 year ago

@ivi/portal v0.3.1

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

ivi Portals

EXPERIMENTAL API

Example

import { createRoot, update, component, useState } from "ivi";
import { htm } from "@ivi/htm";
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 () => (
    htm`
    <div class="App">
      <span
        @mouseenter=${onMouseEnter}
        @mouseleave=${onMouseLeave}
      >
        Portal Example
      </span>
      ${visible() && portal(htm`<span>rendered inside of a portal</span>`)}
    </div>
    `
  );
});

update(
  createRoot(document.getElementById("root")!),
  App(),
);
0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago