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:
basedbuild-tailwind: Tailwind CSS v4 color palette
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3741db1eb1cafd2ed7d12a470e282b14202ca44ec2f40aefcf989665d00a18eb
|
|
| MD5 |
e426505915be9df6554ab4618db1a96b
|
|
| BLAKE2b-256 |
14bb25bb4df606f50141383b1027998500aa1ab6b9cfe8402b10ebe364d24d6f
|
Provenance
The following attestation bundles were made for basedbuild-0.2.0.tar.gz:
Publisher:
publish.yml on kipila-dev/based
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
basedbuild-0.2.0.tar.gz -
Subject digest:
3741db1eb1cafd2ed7d12a470e282b14202ca44ec2f40aefcf989665d00a18eb - Sigstore transparency entry: 2668599781
- Sigstore integration time:
-
Permalink:
kipila-dev/based@eab888bb6cb4b6d9650b9ec013e392cfbf4d9d56 -
Branch / Tag:
refs/tags/basedbuild-v0.3.0 - Owner: https://github.com/kipila-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eab888bb6cb4b6d9650b9ec013e392cfbf4d9d56 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a87fc9a0c62862fc3973c6e567bf6ca33221776eef075feef018fdcdf0eae07
|
|
| MD5 |
c470831c485723f917ac3502e68a5642
|
|
| BLAKE2b-256 |
b8079f21f12989dab622b9c574e5e226662e2141c38f3845c8479f6729518fe6
|
Provenance
The following attestation bundles were made for basedbuild-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on kipila-dev/based
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
basedbuild-0.2.0-py3-none-any.whl -
Subject digest:
0a87fc9a0c62862fc3973c6e567bf6ca33221776eef075feef018fdcdf0eae07 - Sigstore transparency entry: 2668599840
- Sigstore integration time:
-
Permalink:
kipila-dev/based@eab888bb6cb4b6d9650b9ec013e392cfbf4d9d56 -
Branch / Tag:
refs/tags/basedbuild-v0.3.0 - Owner: https://github.com/kipila-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eab888bb6cb4b6d9650b9ec013e392cfbf4d9d56 -
Trigger Event:
push
-
Statement type: