Skip to main content

based.

based is a Build System for Design.

Build scripts are written in Starlark:

palette = struct(primary=color.Oklch(0.5, 0.134, 242.749))
tokens = [Token("primary", light=palette.primary)]

target(
    id="acme",
    tokens=tokens,
    artifacts=[Artifact("css", "dist/acme/css")]
)

Installation

pip install basedbuild

Usage

Create a build.based in your project root and run:

based build

WCAG Contrast Validation

based supports accessibility testing by letting you declare contrast requirements using the wcag annotations.

load("wcag", "wcag")

surface = Token("surface", Color("#FFFFFF"))
primary = Token("primary", Color("#0284C7"))
text = Token(
    "text",
    Color("#1E293B"),
    # Will raise a validation error if text fails to meet the AA contrast
    # ratio against surface.
    annotations=wcag.against(surface, role=wcag.Role.Text, level=wcag.Level.AA)
)

target(
    id="acme",
    tokens=[surface, primary, text],
    artifacts=[Artifact("android", "acme/res")],
)

Extending based

Plugin interface is exposed via Python entry points. For a reference plugin implementation, see the built-in wcag module.

# DSL extension
[project.entry-points."based.dsl"]
myplugin = "myplugin.dsl:myplugin_module"

# Type adapter
[project.entry-points."based.adapter"]
mynode = "myplugin.models:mynode_adapter"

# Compiler pass
[project.entry-points."based.pass"]
myplugin = "myplugin.passes:MyValidation"

# Platform backend
[project.entry-points."based.backend"]
myplatform = "myplugin.backend:MyPlatformBackend"

The following plugins are maintained alongside based and can be installed directly:

Advanced Example

colors = [
    Token(
        "primary",
        light=color.Oklch(0.5, 0.134, 242.749),
        dark=color.Oklch(0.828, 0.111, 230.318),
    ),
    Token(
        "surface",
        light=color.Oklch(0.97, 0, 0),
        dark=color.Oklch(0.205, 0, 0),
    ),
]

space = [
    Token("space.s", dimen.Spacing(0.5)),
    Token("space.m", dimen.Spacing(1)),
    Token("space.l", dimen.Spacing(2)),
    Token("space.xl", dimen.Spacing(4)),
]

target(
    id="acme",
    tokens=colors + space,
    artifacts=[
        Artifact("android", "dist/acme/android"),
        Artifact("apple", "dist/acme/apple"),
        Artifact("compose", "dist/acme/compose", package="com.acme.android.design"),
        Artifact("css", "dist/acme/css"),
    ],
)
:root {
  --dimen-space-s: 0.5rem;
  --dimen-space-m: 1rem;
  --dimen-space-l: 2rem;
  --dimen-space-xl: 4rem;
}

:root {
  --color-primary: rgb(0 105 168);
  --color-surface: rgb(245 245 245);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: rgb(116 212 255);
    --color-surface: rgb(23 23 23);
  }
}

:root[data-theme="light"] {
  --color-primary: rgb(0 105 168);
  --color-surface: rgb(245 245 245);
}

:root[data-theme="dark"] {
  --color-primary: rgb(116 212 255);
  --color-surface: rgb(23 23 23);
}

@supports (color: oklch(0% 0 0)) {
  :root {
    --color-primary: oklch(0.5 0.134 242.749);
    --color-surface: oklch(0.97 0 none);
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --color-primary: oklch(0.828 0.111 230.318);
      --color-surface: oklch(0.205 0 none);
    }
  }

  :root[data-theme="light"] {
    --color-primary: oklch(0.5 0.134 242.749);
    --color-surface: oklch(0.97 0 none);
  }

  :root[data-theme="dark"] {
    --color-primary: oklch(0.828 0.111 230.318);
    --color-surface: oklch(0.205 0 none);
  }
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

basedbuild-0.3.0.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basedbuild-0.3.0-py3-none-any.whl (47.1 kB view details)

Uploaded Python 3

File details

Details for the file basedbuild-0.3.0.tar.gz.

File metadata

  • Download URL: basedbuild-0.3.0.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for basedbuild-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3aea96d73683ef854048a9e982986afdc835a7ae4f0827f8f751552029673661
MD5 5055393200ff22a50a65b5ce133ad672
BLAKE2b-256 836f22c06132a2a170299ef5b14d011d26c356a731fb1e558ce49344c15520d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for basedbuild-0.3.0.tar.gz:

Publisher: publish.yml on kipila-dev/based

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file basedbuild-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: basedbuild-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 47.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for basedbuild-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 057d90a6aed4fc7a1e1d6905db14d037a676d17e35001ff3568ab6413e1e25a3
MD5 d96645ea554db9247facc3a91c1f9a3d
BLAKE2b-256 6c727b8e341fac7bc66b6a37854562161c315493b81944db9e579df8e5a8a545

See more details on using hashes here.

Provenance

The following attestation bundles were made for basedbuild-0.3.0-py3-none-any.whl:

Publisher: publish.yml on kipila-dev/based

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 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