Reference · Facts, line drawings and positions
embedCodefunction
The text that puts a body in a page, for one way of making the page. Each way is built, parsed or run by the package's tests: the plain HTML one with a script tag from jsDelivr, an ES module, a React component,
a Vue single-file component, an Angular standalone component, a Svelte component, and an iframe of the demo's embed.html.
Import it
import { embedCode } from "@johnmorrisdotca/wakusei-planets";
Definition
function embedCode(options: EmbedOptions, kind?: EmbedKind, settings?: EmbedSettings): string
Parameters
| Name | Type | Description |
|---|---|---|
options | EmbedOptions | The body, its look, the date, the moons, the turn and the size. |
kind (optional) | "html" | "iframe" | "module" | "react" | "vue" | "angular" | "svelte" | The way the page is made; |
settings (optional) | EmbedSettings | The CDN and the demo's address, when they are not the package's own. |
Returns
string
The text to paste into the page's source.
Examples
import { embedCode } from "@johnmorrisdotca/wakusei-planets";
console.log(embedCode({ body: "jupiter", look: "realistic", time: "now", moons: true }, "react"));import { useEffect } from "react";
export function Planet() {
useEffect(() => {
// The element needs a browser, so it is imported in an effect, never at the top of the file.
void import("@johnmorrisdotca/wakusei-planets/element");
void import("@johnmorrisdotca/wakusei-planets/jupiter");
}, []);
return <wakusei-body body="jupiter" look="realistic" time="now" moons />;
}What it prints (run when this page was built)