prototype-slides
v0.2.2
Published
A draggable fullscreen slide widget for prototyping and presenting in any web app.
Downloads
724
Maintainers
Readme
Work in progress, not ready for usage
Prototype Slides
A small npm package that adds a draggable floating circle to any website. Clicking the circle expands it into a fullscreen slide editor with per-slide text color, slide color, text size, bold text, and list controls.
The package is framework-agnostic at its core, with an optional React entrypoint.
What It Does
- Renders a floating launcher above any web product
- Lets the user drag the launcher anywhere on screen
- Expands into a fullscreen editor when clicked
- Supports bold text plus bulleted and numbered lists
- Stores one shared slide deck per
branchKey - Works in plain JavaScript and React
- Keeps styles isolated with Shadow DOM
Install
npm install prototype-slidesJavaScript Usage
import { createSlideWidget } from "prototype-slides";
const branchKey = window.__APP_BRANCH__ ?? "local";
const widget = createSlideWidget({
branchKey,
title: "Product Slides",
defaultTheme: {
textColor: "#111827",
slideColor: "#ffffff",
fontSize: 20
}
});
widget.open();React Usage
import { SlideWidget } from "prototype-slides/react";
export function App() {
return (
<SlideWidget
branchKey={window.__APP_BRANCH__ ?? "staging"}
title="Product Slides"
defaultTheme={{
textColor: "#0f172a",
slideColor: "#f8fafc",
fontSize: 20
}}
/>
);
}API
createSlideWidget(options)
Creates and mounts the widget immediately.
Options:
branchKey: required string used to scope storagemountTo: optional mount element, defaults todocument.bodydefaultTheme: optional{ textColor, slideColor, fontSize }storage: optional custom storage adapterzIndex: optional z-index overridelauncherSize: optional closed-circle size in pixelsinitialPosition: optional{ x, y }for the floating launchertitle: optional label shown in the expanded editoronChange: optional callback fired after a deck save
Returned controller:
open()close()destroy()getDeck()setDeck(deck)
Storage Model
The default storage is browser localStorage.
- Key pattern:
prototype-slides:{branchKey} - Scope: one deck per branch key
- Not page-dependent
- Saves automatically after edits
This version does not write to git or GitHub directly. To make content truly branch-backed later, keep the widget UI as-is and swap in a custom storage adapter.
Passing A Branch Key
The host app is responsible for passing the branch key into the package. A browser package cannot safely detect the current git branch by itself.
Common approaches:
- Inject a branch name into
window.__APP_BRANCH__at deploy time - Expose the branch through your app config
- Use a staging-specific constant for the first version
Local Development
npm install
npm run build
npm run typecheckBuild output goes to dist/.
Local Demo
Run the built-in demo with:
npm run demoThat will build the package and start a tiny local server at http://localhost:4173/demo/.
The demo lets you:
- mount the widget locally
- change the
branchKey - change default text and slide colors
- verify that content is stored per branch in
localStorage
The examples/ directory contains simple usage references:
examples/vanilla/index.htmlexamples/react/App.tsx
The demo/ directory is the contributor-friendly local preview:
demo/index.htmldemo/main.jsdemo/server.mjs
Publish To npm
- Build and typecheck the package
- Log in with
npm login - Publish with
npm publish --access public - Install the package in a separate app and verify it there
Future Upgrade Path
The next clean step is a remote storage adapter. That would let the exact same package save decks to:
- your own API
- a GitHub-backed file store
- an environment-specific staging service
That keeps the npm package universal while storage becomes deployment-specific.
