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.2.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.2.0-py3-none-any.whl (47.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: basedbuild-0.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 3741db1eb1cafd2ed7d12a470e282b14202ca44ec2f40aefcf989665d00a18eb
MD5 e426505915be9df6554ab4618db1a96b
BLAKE2b-256 14bb25bb4df606f50141383b1027998500aa1ab6b9cfe8402b10ebe364d24d6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for basedbuild-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: basedbuild-0.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a87fc9a0c62862fc3973c6e567bf6ca33221776eef075feef018fdcdf0eae07
MD5 c470831c485723f917ac3502e68a5642
BLAKE2b-256 b8079f21f12989dab622b9c574e5e226662e2141c38f3845c8479f6729518fe6

See more details on using hashes here.

Provenance

The following attestation bundles were made for basedbuild-0.2.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

0.3.0

2 files

This release

0.2.0 This release

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