Skip to main content

spaday-spectrum

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

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.

Run the local example

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

Open http://127.0.0.1:8028 for the review board: assets streamed from Python over transports and approved or sent back through Python endpoints, an activity feed, a brief form of text fields, checkboxes and a switch bound to spaday state and checked by the server, a pending button while it files, tabs and panels driven from the store, close and clear buttons, and switches for Spectrum's dark color and large scale. spaday-spectrum doesn't map spaday's shell palette yet, so the example maps it onto Spectrum's tokens itself.

[!NOTE] This library was generated using copier from the Base Python Project Template repository.

Metadata

Release files for spaday-spectrum 0.2.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.2.0
File Size Uploaded
spaday_spectrum-0.2.0.tar.gz 551.6 kB Details

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / spaday_spectrum-0.2.0.tar.gz

Download URL spaday_spectrum-0.2.0.tar.gz
Size 551.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a7af6f2dc4a2dfd9d12d3560d8b9398a71f9e45c961d4ee3c944c14dedd4eeaf
BLAKE2b-256 checksum
How to use checksums
95d5bc6fdc5241bc784243d5d74ea979e4cf991311205a75678c2012a4bb08d5
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.2.0-py3-none-any.whl

Download URL spaday_spectrum-0.2.0-py3-none-any.whl
Size 523.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad7032fd16860e433446dd40b57f22e8c5c6c420a3520e62f6514d01defc6cda
BLAKE2b-256 checksum
How to use checksums
b7fade8e4e2123bfe1294ef67fd6df50d100032f68c3d58f4c8e0ecd97744a18
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

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

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