@scenar/embed
v0.3.0
Published
Drop-in host-side embedding for Scenar tours — a framework-agnostic <scenar-embed> web component and a matching React wrapper.
Downloads
108
Maintainers
Readme
@scenar/embed
Drop-in host-side embedding for hosted Scenar
tours. Frame a published tour as a responsive, theme-synced iframe without
hand-writing the postMessage listener, the theme sync, or the resize-to-fit
glue.
It builds on the framework-free embed host controller in @scenar/core, so the
wire protocol is single-sourced and never drifts. It does not pull in the
player runtime (@scenar/react) — embedding a hosted tour costs your host page
nothing but this small package.
Three ways to use it
1. Web component (any framework, or none)
<script type="module" src="https://cdn.jsdelivr.net/npm/@scenar/embed/dist/embed.global.js"></script>
<scenar-embed
src="https://you.github.io/scenar-embeds/welcome-tour/"
title="Welcome tour"
></scenar-embed>Or, with a bundler:
import "@scenar/embed/define"; // registers <scenar-embed>2. React
import { ScenarEmbed } from "@scenar/embed/react";
<ScenarEmbed
src="https://you.github.io/scenar-embeds/welcome-tour/"
title="Welcome tour"
/>;react and react-dom are optional peer dependencies — only needed for this
subpath.
3. Imperative (build your own host)
import { createEmbedMount } from "@scenar/embed";
const mount = createEmbedMount(iframeElement, {
src: "https://you.github.io/scenar-embeds/welcome-tour/",
theme: "auto",
onAspectRatio: ({ widthPx, heightPx }) => {
/* size your container */
},
});
// mount.controller.play(); mount.controller.pause(); …
// mount.destroy();Theme
theme is auto (default), light, or dark. auto tracks the host page's
dark class on <html> and re-themes the embed when it toggles.
License
Apache-2.0
