Skip to main content
spaday-spectrum logo, a prism splitting light inside a browser window

Spectrum for spaday

Build Status codecov License PyPI

Preview of Spectrum components in spaday rendering a review board

Overview

spaday-spectrum provides generated Python bindings and a self-contained registration bundle for a focused first slice of Adobe Spectrum Web Components:

  • Theme
  • Button, clear button, and close button
  • Textfield
  • Checkbox and switch
  • Tabs, tab panels, and tabs overflow

Generic controls

Select the spectrum design to render spaday's generic button, text input, text area, checkbox, and switch as Spectrum elements:

from spaday import Button, Column, TextInput
from spaday.backends.starlette import serve

page = Column(
    TextInput(label="Name").bind("value", "name", mode="two-way"),
    Button(label="Save", intent="primary"),
)
app = serve(page, packages=["spectrum"], design="spectrum", store={"name": ""})

Controls outside this focused Spectrum package use spaday's marked native fallback. The package's shared conformance test covers both the Spectrum controls and those substitutions.

Theming

Spectrum's palette drives the Spaday shell inside sp-theme. Override a Spectrum token on the theme or app root and shell components inherit the same value:

from spaday import App
from spaday_spectrum import SpTheme

SpTheme(App(...)).css(spectrum_accent_content_color_default="#0C4253")

spaday_spectrum.TOKENS lists the Spectrum properties connected to --spa-surface, --spa-border, --spa-accent, and the shell status colors.

Interactive example

The textfield updates the greeting immediately, the checkbox switches Spectrum themes, and the button resets state. All three interactions run in the browser through spaday's reactive store.

from spaday import SetField, cond, element, field
from spaday.backends.starlette import serve
from spaday_spectrum import SpButton, SpCheckbox, SpTextfield, SpTheme

page = (
    SpTheme(scale="medium")
    .compute("color", cond(field("dark"), "dark", "light"))
    .style(display="block", max_width="32rem", margin="2rem auto", padding="1.5rem")
    .child(element("h1").text("Spectrum profile"))
    .child(SpTextfield(label="Display name", placeholder="Your name").bind("value", "name", mode="two-way"))
    .child(SpCheckbox().text("Dark theme").bind("checked", "dark", mode="two-way"))
    .child(
        element("p")
        .child("Hello, ")
        .child(element("strong").bind("textContent", "name"))
    )
    .child(SpButton(treatment="fill").text("Reset name").on("click", SetField("name", "Ada")))
)

app = serve(page, packages=["spectrum"], store={"name": "Ada", "dark": False})

Save this as app.py, then run pip install spaday-spectrum starlette uvicorn and uvicorn app:app. Open http://127.0.0.1:8000.

Installing this project registers the spectrum entry point with spaday. The equivalent explicit forms are packages=[spaday_spectrum.package] and packages=["spaday_spectrum:package"].

The package pins six individual Spectrum packages to 1.12.2. It deliberately avoids the full @spectrum-web-components/bundle; more components should be added from concrete application needs.

The typed classes are generated from those packages' Custom Elements Manifests with make catalog. Spectrum publishes one package per component, and a published manifest leaves out what an element inherits from another package — size, disabled, href, and on sp-switch even checked. js/tools/manifests.mjs resolves each element's superclass and mixins through the manifests of the packages that declare them and writes the result to spaday_spectrum/manifests/, which the classes are generated from. base and shared publish no manifest at all, so the few declarations needed from them are transcribed in js/tools/unpublished.json; the tool fails on any class neither covers.

Browser examples

Both run Python locally through Pyodide; no install or server is required.

Run examples locally

python -m pip install -e ".[examples]"
python -m spaday_spectrum.example
python -m spaday_spectrum.gallery

Open http://127.0.0.1:8028 for the standard creative-review app or http://127.0.0.1:8029 for the component gallery. The standard app includes streamed assets, endpoint-backed review decisions and brief submission, an activity feed, bound fields and switches, tabs, dismissible feedback, and shared Spectrum color and scale state. The gallery includes every generated component in this focused package and a highlighted Python snippet for each family.

Both pass the local package descriptor directly, so they do not install or resolve the integration from GitHub.

Metadata

Release files for spaday-spectrum 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spaday-spectrum 0.4.0
File Size Uploaded
spaday_spectrum-0.4.0.tar.gz 563.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spaday-spectrum 0.4.0
File Interpreter ABI Platform
spaday_spectrum-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / spaday_spectrum-0.4.0.tar.gz

Download URL spaday_spectrum-0.4.0.tar.gz
Size 563.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f284d69c7ce5870e303f8ecdbd7a76d198b0f2006531cdd96ae0a22cc674376a
BLAKE2b-256 checksum
How to use checksums
29caa14ab1574185eee7ea329536609d6e92895269ff1e2365ff3ebc5e2e6dc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / spaday_spectrum-0.4.0-py3-none-any.whl

Download URL spaday_spectrum-0.4.0-py3-none-any.whl
Size 532.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a53bfd528d5bf74365254aa64244821254cb25a67122cc6cc2c7f8b186ffcceb
BLAKE2b-256 checksum
How to use checksums
337d5f2e4d560d90d5f29adfa2117138e6bc2b331699e0c4e8c9d7019d0da165
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page