Widget packs
Put several widgets in one Lightair package with a shared look, and arrange them with layout.json so Add all places them as your preview shows them.
In short
- A widget pack is a package with several
widgetcontent entries. - Each widget's page is built from its own folder only, so shared settings, code and fonts go into every widget's files.
- A
layout.jsonat the package's root places each widget on a canvas; Add all follows it.
A widget pack is one package that holds a matching set of widgets: alerts, a chat box, a goal, a ticker. People install it once and add every widget at once with Add all.
Make a pack
Section titled “Make a pack”- Make each widget as its own folder, as on Widgets.
- Put the folders under one package folder,
widgets/<name>/by convention. - List each folder in
lightair-package.json, in the order you want them shown. - Optionally add
layout.jsonat the package’s root to arrange them.
open-air/├── lightair-package.json├── layout.json├── LICENSE├── licences/│ └── outfit-OFL.txt└── widgets/ ├── alerts/ ├── chat/ ├── goal/ └── recent/{ "id": "com.example.open-air", "name": "Open Air", "version": "1.0.0", "lightair": ">=1.1 <2", "licence": "MIT AND OFL-1.1", "description": "Alerts, chat, recent events and a goal in soft plates with one accent colour.", "platforms": ["macos", "windows", "ios", "android"], "contents": [ { "kind": "widget", "path": "widgets/alerts" }, { "kind": "widget", "path": "widgets/chat" }, { "kind": "widget", "path": "widgets/recent" }, { "kind": "widget", "path": "widgets/goal" } ]}Share a look across widgets
Section titled “Share a look across widgets”Lightair builds each widget’s page from that widget’s folder alone, and serves files only from inside it. Each widget also keeps its own settings. So what the widgets share has to be in each of them:
- Look settings. Give every widget the same settings for the look, under one group, in its
fields.json. People then find the same Look controls on each widget. - Shared code and style. Repeat it at the top of every widget’s
main.jsandstyle.css. - Fonts and pictures. Put a copy in each widget’s folder, and load them by relative path
(
url(fonts/outfit-600.woff)).
{ "title": { "type": "text", "label": "Title", "value": "Follower goal", "group": "Goal" }, "target": { "type": "number", "label": "Target", "value": 500, "min": 1, "group": "Goal" }, "theme": { "type": "dropdown", "label": "Plates", "value": "dark", "options": { "dark": "Dark", "light": "Light" }, "group": "Look" }, "accent": { "type": "colorpicker", "label": "Accent", "value": "#3AA6F5", "group": "Look" }, "radius": { "type": "slider", "label": "Corner radius", "value": 12, "min": 0, "max": 28, "step": 1, "group": "Look" }}Copying by hand gets out of step quickly, so build the package from a source folder with a small script. Lightair’s own packs are written this way:
look.jsonholds the look settings once. The build adds each to every widget’sfields.json, after the widget’s own settings, unless the widget already has a setting of that name.shared.jsandshared.csshold the shared code and style. The build puts them in front of each widget’smain.jsandstyle.css.- The build copies the fonts into each widget’s
fonts/folder, writeslayout.jsonandlightair-package.json, then runslightair-pack build(see Publish).
look.json, shared.js and shared.css are files of that build, not of the package: Lightair
doesn’t read them.
Arrange the widgets: layout.json
Section titled “Arrange the widgets: layout.json”layout.json at the package’s root places each widget on a canvas, by its folder’s name:
{ "canvas": [1920, 1080], "widgets": { "goal": [610, 40], "recent": [1460, 40], "alerts": [440, 230], "chat": [40, 340] }}canvas: the size, in pixels, the places are given on. Both at least 1.widgets: each widget’s top-left corner,[x, y], keyed by the name of its folder (the last part of its content path). Widgets it leaves out have no place.
Lightair reads it only when it has a canvas and at least one place.
How Add all reads it
Section titled “How Add all reads it”Add all (on the package’s page in the Packages panel, and on its row when you point at it) adds every widget to the selected scene:
- The widgets go in one group named after the package, and each gets a mixer track.
- Each widget is its page’s size, from its
manifest.json(800 × 600 when it doesn’t say). - With a layout, the arrangement is scaled to fit each canvas of the show, keeping its shape, and
centred on it. Each widget sits at its place, scaled the same, and kept inside the canvas.
Widgets later in
contentsare in front. - A widget the layout doesn’t place is added hidden, in the middle of the canvas.
- Without a layout, the widgets are laid out side by side at their own sizes so none overlaps,
scaled down together to fit each canvas, and the first in
contentsis in front.
Adding some of the widgets follows the layout only when it places every one chosen. Adding one widget adds it as Add Object › Widgets does.