fasthtml-basecoatui 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fasthtml_basecoatui-1.1.0/.gitignore +17 -0
- fasthtml_basecoatui-1.1.0/BASECOAT-LICENSE +21 -0
- fasthtml_basecoatui-1.1.0/LICENSE +21 -0
- fasthtml_basecoatui-1.1.0/PKG-INFO +205 -0
- fasthtml_basecoatui-1.1.0/README.md +178 -0
- fasthtml_basecoatui-1.1.0/generation.json +73 -0
- fasthtml_basecoatui-1.1.0/hatch_build.py +28 -0
- fasthtml_basecoatui-1.1.0/pyproject.toml +53 -0
- fasthtml_basecoatui-1.1.0/scripts/__init__.py +0 -0
- fasthtml_basecoatui-1.1.0/scripts/check_release.py +46 -0
- fasthtml_basecoatui-1.1.0/scripts/generate.py +169 -0
- fasthtml_basecoatui-1.1.0/scripts/parser.py +221 -0
- fasthtml_basecoatui-1.1.0/scripts/render.py +119 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/__init__.py +116 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/basecoat-luma.bundle.css +3319 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/basecoat-lyra.bundle.css +3302 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/basecoat-maia.bundle.css +3287 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/basecoat-mira.bundle.css +3296 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/basecoat-nova.bundle.css +3314 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/basecoat-rhea.bundle.css +3324 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/basecoat-sera.bundle.css +3312 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/basecoat-vega.bundle.css +3301 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/luma.css +3 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/lyra.css +3 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/maia.css +3 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/mira.css +3 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/nova.css +3 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/rhea.css +3 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/sera.css +3 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/css/vega.css +3 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets/js/all.min.js +1 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/assets.py +25 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/components.py +597 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/helpers.py +107 -0
- fasthtml_basecoatui-1.1.0/src/fasthtml_basecoat/py.typed +0 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/LICENSE.md +21 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/README.md +10 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/components/button.css +6 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/components/card.css +26 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/components/switch.css +8 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/components/tabs.css +31 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/docs/button.mdx +243 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/docs/card.mdx +180 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/docs/switch.mdx +149 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/docs/tabs.mdx +307 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/styles/nova.css +1387 -0
- fasthtml_basecoatui-1.1.0/tests/fixtures/upstream/styles/vega.css +1386 -0
- fasthtml_basecoatui-1.1.0/tests/test_assets.py +87 -0
- fasthtml_basecoatui-1.1.0/tests/test_generator.py +156 -0
- fasthtml_basecoatui-1.1.0/tests/test_helpers.py +124 -0
- fasthtml_basecoatui-1.1.0/tests/test_parser.py +157 -0
- fasthtml_basecoatui-1.1.0/tests/test_releases.py +68 -0
- fasthtml_basecoatui-1.1.0/tests/test_theme.py +52 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ronan Berder
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SpaceShaman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: fasthtml-basecoatui
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Basecoat components and bundled assets for FastHTML.
|
|
5
|
+
Project-URL: Documentation, https://github.com/SpaceShaman/fasthtml-basecoatui#readme
|
|
6
|
+
Project-URL: Homepage, https://github.com/SpaceShaman/fasthtml-basecoatui
|
|
7
|
+
Project-URL: Issues, https://github.com/SpaceShaman/fasthtml-basecoatui/issues
|
|
8
|
+
Project-URL: Repository, https://github.com/SpaceShaman/fasthtml-basecoatui
|
|
9
|
+
Author-email: SpaceShaman <spaceshaman@tuta.io>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: BASECOAT-LICENSE
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: basecoat,components,fasthtml,tailwindcss,web
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: fasthtml-tailwindcss>=4.3.3.post1
|
|
25
|
+
Requires-Dist: python-fasthtml>=0.14.14
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# fasthtml-basecoatui
|
|
29
|
+
|
|
30
|
+
[](LICENSE)
|
|
31
|
+
[](https://pypi.org/project/fasthtml-basecoatui/)
|
|
32
|
+
[](https://pypi.org/project/fasthtml-basecoatui/)
|
|
33
|
+
[](https://github.com/SpaceShaman/fasthtml-basecoatui/actions/workflows/release.yml)
|
|
34
|
+
[](https://github.com/AnswerDotAI/fasthtml)
|
|
35
|
+
[](https://basecoatui.com/)
|
|
36
|
+
|
|
37
|
+
Basecoat components and bundled assets for [FastHTML](https://github.com/AnswerDotAI/fasthtml).
|
|
38
|
+
|
|
39
|
+
Typed Python components generated from [Basecoat](https://basecoatui.com/), with local CSS and JavaScript. CSS builds and watch mode are provided by [fasthtml-tailwindcss](https://github.com/SpaceShaman/fasthtml-tailwindcss). No Node.js, npm, or CDN is needed in your application.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
- With uv:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
uv add fasthtml-basecoatui
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- With pip:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
pip install fasthtml-basecoatui
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
For development and CSS builds, also install the Tailwind compiler:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
uv add "fasthtml-tailwindcss[dev]"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or `pip install "fasthtml-tailwindcss[dev]"`. Production only needs `fasthtml-basecoatui` and the generated CSS. Alpine Linux also requires `apk add --no-cache libstdc++ libgcc` when using the compiler.
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from fasthtml.common import FastHTML, StaticImmutable
|
|
67
|
+
from fasthtml_tailwindcss import TailwindHead
|
|
68
|
+
from fasthtml_basecoat import BasecoatInput, BasecoatJS, Button
|
|
69
|
+
|
|
70
|
+
app = FastHTML(
|
|
71
|
+
hdrs=[
|
|
72
|
+
BasecoatJS(),
|
|
73
|
+
TailwindHead(input=BasecoatInput("nova"), watch=True),
|
|
74
|
+
]
|
|
75
|
+
)
|
|
76
|
+
app.mount("/static", StaticImmutable(directory="static"), name="static")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@app.route("/")
|
|
80
|
+
def get():
|
|
81
|
+
return Button("Save", variant="outline", size="sm", cls="w-full")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Run `uv run uvicorn main:app --reload`. For `app/main.py`, run `uv run --directory app uvicorn main:app --reload` from the project directory.
|
|
85
|
+
|
|
86
|
+
`TailwindHead` creates `static/`, writes CSS to `static/tailwind.css`, and adds a content-versioned stylesheet link for browser caching. Compilation starts on the first page render. The watcher rebuilds CSS as your classes change and survives server reloads; refresh the browser to see updates.
|
|
87
|
+
|
|
88
|
+
### Examples
|
|
89
|
+
|
|
90
|
+
Each file in [examples](examples) is a standalone application following Basecoat's HTML structure, with local CSS and JavaScript:
|
|
91
|
+
|
|
92
|
+
- [Contact form](examples/form.py) — fields, validation, and form submission.
|
|
93
|
+
- [Workspace cards](examples/cards.py) — cards, badges, progress, and theme switching.
|
|
94
|
+
- [Settings tabs](examples/tabs.py) — accessible tabs and panels.
|
|
95
|
+
- [Profile dialog](examples/dialog.py) — a native modal with an editable field.
|
|
96
|
+
- [FAQ accordion](examples/accordion.py) — expandable questions and answers.
|
|
97
|
+
- [Invoice table](examples/table.py) — a responsive table with status badges.
|
|
98
|
+
- [Preferences](examples/preferences.py) — a native select, slider, and switch.
|
|
99
|
+
- [Resource dropdown](examples/dropdown.py) — a dropdown menu with navigation links.
|
|
100
|
+
- [Dimensions popover](examples/popover.py) — editable fields inside a popover.
|
|
101
|
+
- [Toast notifications](examples/toast.py) — server-rendered notifications through HTMX.
|
|
102
|
+
- [Search input](examples/search.py) — an input group with a keyboard hint and query handling.
|
|
103
|
+
- [Empty state](examples/empty.py) — replace an empty state with a card through HTMX.
|
|
104
|
+
|
|
105
|
+
With the development dependencies installed, run an example from the project directory:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
uv run --directory examples uvicorn form:app --reload
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Replace `form` with any example's filename without `.py`, or copy an example into `main.py` and run `uv run uvicorn main:app --reload`.
|
|
112
|
+
|
|
113
|
+
### Components
|
|
114
|
+
|
|
115
|
+
Components accept children, `cls`, a `tag` override, and standard [FastHTML](https://github.com/AnswerDotAI/fasthtml) attributes. Variants and sizes have explicit `Literal` types for editor autocomplete and type checking; invalid values also raise `ValueError`.
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from fasthtml.common import H2, Header, Section
|
|
119
|
+
from fasthtml_basecoat import Card
|
|
120
|
+
|
|
121
|
+
Card(Header(H2("Account")), Section("Your account details"), size="sm")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Use native HTML elements for component children. See [Basecoat's component documentation](https://basecoatui.com/) for markup and behavior.
|
|
125
|
+
|
|
126
|
+
Tooltips work through attributes on any component:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
Button("Save", data_tooltip="Save your changes", data_side="bottom")
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Chart is not supported yet. Chart.js integration is planned for a future release; Chart.js and Basecoat's chart helper are currently not bundled.
|
|
133
|
+
|
|
134
|
+
### Styles and JavaScript
|
|
135
|
+
|
|
136
|
+
`BasecoatInput()` returns the default Vega input. Supported styles are `vega`, `nova`, `maia`, `lyra`, `mira`, `luma`, `sera`, and `rhea`; `Style` and `STYLES` are also exported.
|
|
137
|
+
|
|
138
|
+
The input imports Tailwind and the bundled Basecoat source CSS. Tailwind detects utilities in your application automatically; the imported Basecoat bundle includes its component styles. For custom themes or additional source paths, use the standard `TailwindHead` arguments.
|
|
139
|
+
|
|
140
|
+
`BasecoatJS()` restores `localStorage.themeMode`, falling back to the system preference, then loads the bundled Basecoat JavaScript inline. Place it before `TailwindHead` to apply the theme before CSS loads. It accepts script attributes such as `nonce`; include it once for interactive components and `ThemeSwitcher`.
|
|
141
|
+
|
|
142
|
+
`Spinner` and `ThemeSwitcher` include their SVGs. For additional typed inline icons, see [fasthtml-lucide](https://github.com/SpaceShaman/fasthtml-lucide).
|
|
143
|
+
|
|
144
|
+
### Production
|
|
145
|
+
|
|
146
|
+
Use `TailwindHead(input=BasecoatInput("nova"))` with the default `watch=False`, then build CSS in your deployment pipeline:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
uv run fasthtml-tailwindcss build main:app
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
For `app/main.py`, you can run `uv run fasthtml-tailwindcss build app.main:app` from the project directory. The build uses the application module's directory, so both approaches produce `app/static/tailwind.css` by default.
|
|
153
|
+
|
|
154
|
+
Deploy the generated stylesheet with the application. The compiler is only needed in the build environment.
|
|
155
|
+
|
|
156
|
+
## Development
|
|
157
|
+
|
|
158
|
+
### Setup and tests
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
uv sync --group dev
|
|
162
|
+
uv run --group dev python -m scripts.generate
|
|
163
|
+
uv run --group dev pytest
|
|
164
|
+
uv run --group dev ruff check src scripts tests hatch_build.py
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The development group includes the generator dependencies and Tailwind compiler. They are not dependencies of the published wrapper. Theme bootstrap tests also use Node.js when available; the application does not require it.
|
|
168
|
+
|
|
169
|
+
### Regenerate components and assets
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
uv run --group dev python -m scripts.generate
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
This downloads the exact `basecoat-css` version from `pyproject.toml` (without a `.postN` suffix), verifies npm integrity, and downloads the matching GitHub tag. Source and npm versions must agree. The generator parses CSS once, produces ordinary Python functions, copies local assets, and updates `generation.json`. It stops if previously generated components disappear.
|
|
176
|
+
|
|
177
|
+
For local upstream sources:
|
|
178
|
+
|
|
179
|
+
```sh
|
|
180
|
+
uv run --group dev python -m scripts.generate --source ../basecoat --package /path/to/extracted/npm/package
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Generated Python components and `generation.json` are committed to this repository. Composed helpers live in `helpers.py` and are not overwritten during regeneration. Input stylesheets register their Tailwind classes automatically. Downloaded CSS and JavaScript stay in the ignored `src/fasthtml_basecoat/assets/` directory. CI regenerates them before building packages.
|
|
184
|
+
|
|
185
|
+
### Build
|
|
186
|
+
|
|
187
|
+
```sh
|
|
188
|
+
uv build --no-sources
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Generate assets first when building from a Git checkout; the build stops if they are missing. The universal wheel and source distribution include all CSS, JavaScript, and license notices, so installation and wheel builds from the source distribution need no Basecoat download. BeautifulSoup and tinycss2 are used only by the development generator.
|
|
192
|
+
|
|
193
|
+
### Automated releases
|
|
194
|
+
|
|
195
|
+
A daily [Release workflow](.github/workflows/release.yml) checks `basecoat-css` on npm. A new stable npm version triggers regeneration, wheel tests, and publication to PyPI. GitHub supplies only the matching source tag; it does not determine the released version.
|
|
196
|
+
|
|
197
|
+
Configure PyPI Trusted Publishing for repository `SpaceShaman/fasthtml-basecoatui`, workflow `release.yml`, and environment `pypi`. The workflow needs permission to commit generated files and version updates to the default branch.
|
|
198
|
+
|
|
199
|
+
### Manual releases
|
|
200
|
+
|
|
201
|
+
For Python-only fixes, run `uv version --bump post --no-sync`, commit and push the changes, then run **Actions → Release → Run workflow**. The workflow creates the tag and publishes the package. Versions follow Basecoat, with `.postN` for wrapper fixes.
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
MIT. Bundled Basecoat resources retain their [upstream license](BASECOAT-LICENSE).
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# fasthtml-basecoatui
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://pypi.org/project/fasthtml-basecoatui/)
|
|
5
|
+
[](https://pypi.org/project/fasthtml-basecoatui/)
|
|
6
|
+
[](https://github.com/SpaceShaman/fasthtml-basecoatui/actions/workflows/release.yml)
|
|
7
|
+
[](https://github.com/AnswerDotAI/fasthtml)
|
|
8
|
+
[](https://basecoatui.com/)
|
|
9
|
+
|
|
10
|
+
Basecoat components and bundled assets for [FastHTML](https://github.com/AnswerDotAI/fasthtml).
|
|
11
|
+
|
|
12
|
+
Typed Python components generated from [Basecoat](https://basecoatui.com/), with local CSS and JavaScript. CSS builds and watch mode are provided by [fasthtml-tailwindcss](https://github.com/SpaceShaman/fasthtml-tailwindcss). No Node.js, npm, or CDN is needed in your application.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
- With uv:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
uv add fasthtml-basecoatui
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- With pip:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
pip install fasthtml-basecoatui
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For development and CSS builds, also install the Tailwind compiler:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
uv add "fasthtml-tailwindcss[dev]"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or `pip install "fasthtml-tailwindcss[dev]"`. Production only needs `fasthtml-basecoatui` and the generated CSS. Alpine Linux also requires `apk add --no-cache libstdc++ libgcc` when using the compiler.
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from fasthtml.common import FastHTML, StaticImmutable
|
|
40
|
+
from fasthtml_tailwindcss import TailwindHead
|
|
41
|
+
from fasthtml_basecoat import BasecoatInput, BasecoatJS, Button
|
|
42
|
+
|
|
43
|
+
app = FastHTML(
|
|
44
|
+
hdrs=[
|
|
45
|
+
BasecoatJS(),
|
|
46
|
+
TailwindHead(input=BasecoatInput("nova"), watch=True),
|
|
47
|
+
]
|
|
48
|
+
)
|
|
49
|
+
app.mount("/static", StaticImmutable(directory="static"), name="static")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@app.route("/")
|
|
53
|
+
def get():
|
|
54
|
+
return Button("Save", variant="outline", size="sm", cls="w-full")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Run `uv run uvicorn main:app --reload`. For `app/main.py`, run `uv run --directory app uvicorn main:app --reload` from the project directory.
|
|
58
|
+
|
|
59
|
+
`TailwindHead` creates `static/`, writes CSS to `static/tailwind.css`, and adds a content-versioned stylesheet link for browser caching. Compilation starts on the first page render. The watcher rebuilds CSS as your classes change and survives server reloads; refresh the browser to see updates.
|
|
60
|
+
|
|
61
|
+
### Examples
|
|
62
|
+
|
|
63
|
+
Each file in [examples](examples) is a standalone application following Basecoat's HTML structure, with local CSS and JavaScript:
|
|
64
|
+
|
|
65
|
+
- [Contact form](examples/form.py) — fields, validation, and form submission.
|
|
66
|
+
- [Workspace cards](examples/cards.py) — cards, badges, progress, and theme switching.
|
|
67
|
+
- [Settings tabs](examples/tabs.py) — accessible tabs and panels.
|
|
68
|
+
- [Profile dialog](examples/dialog.py) — a native modal with an editable field.
|
|
69
|
+
- [FAQ accordion](examples/accordion.py) — expandable questions and answers.
|
|
70
|
+
- [Invoice table](examples/table.py) — a responsive table with status badges.
|
|
71
|
+
- [Preferences](examples/preferences.py) — a native select, slider, and switch.
|
|
72
|
+
- [Resource dropdown](examples/dropdown.py) — a dropdown menu with navigation links.
|
|
73
|
+
- [Dimensions popover](examples/popover.py) — editable fields inside a popover.
|
|
74
|
+
- [Toast notifications](examples/toast.py) — server-rendered notifications through HTMX.
|
|
75
|
+
- [Search input](examples/search.py) — an input group with a keyboard hint and query handling.
|
|
76
|
+
- [Empty state](examples/empty.py) — replace an empty state with a card through HTMX.
|
|
77
|
+
|
|
78
|
+
With the development dependencies installed, run an example from the project directory:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
uv run --directory examples uvicorn form:app --reload
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Replace `form` with any example's filename without `.py`, or copy an example into `main.py` and run `uv run uvicorn main:app --reload`.
|
|
85
|
+
|
|
86
|
+
### Components
|
|
87
|
+
|
|
88
|
+
Components accept children, `cls`, a `tag` override, and standard [FastHTML](https://github.com/AnswerDotAI/fasthtml) attributes. Variants and sizes have explicit `Literal` types for editor autocomplete and type checking; invalid values also raise `ValueError`.
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from fasthtml.common import H2, Header, Section
|
|
92
|
+
from fasthtml_basecoat import Card
|
|
93
|
+
|
|
94
|
+
Card(Header(H2("Account")), Section("Your account details"), size="sm")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Use native HTML elements for component children. See [Basecoat's component documentation](https://basecoatui.com/) for markup and behavior.
|
|
98
|
+
|
|
99
|
+
Tooltips work through attributes on any component:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
Button("Save", data_tooltip="Save your changes", data_side="bottom")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Chart is not supported yet. Chart.js integration is planned for a future release; Chart.js and Basecoat's chart helper are currently not bundled.
|
|
106
|
+
|
|
107
|
+
### Styles and JavaScript
|
|
108
|
+
|
|
109
|
+
`BasecoatInput()` returns the default Vega input. Supported styles are `vega`, `nova`, `maia`, `lyra`, `mira`, `luma`, `sera`, and `rhea`; `Style` and `STYLES` are also exported.
|
|
110
|
+
|
|
111
|
+
The input imports Tailwind and the bundled Basecoat source CSS. Tailwind detects utilities in your application automatically; the imported Basecoat bundle includes its component styles. For custom themes or additional source paths, use the standard `TailwindHead` arguments.
|
|
112
|
+
|
|
113
|
+
`BasecoatJS()` restores `localStorage.themeMode`, falling back to the system preference, then loads the bundled Basecoat JavaScript inline. Place it before `TailwindHead` to apply the theme before CSS loads. It accepts script attributes such as `nonce`; include it once for interactive components and `ThemeSwitcher`.
|
|
114
|
+
|
|
115
|
+
`Spinner` and `ThemeSwitcher` include their SVGs. For additional typed inline icons, see [fasthtml-lucide](https://github.com/SpaceShaman/fasthtml-lucide).
|
|
116
|
+
|
|
117
|
+
### Production
|
|
118
|
+
|
|
119
|
+
Use `TailwindHead(input=BasecoatInput("nova"))` with the default `watch=False`, then build CSS in your deployment pipeline:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
uv run fasthtml-tailwindcss build main:app
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
For `app/main.py`, you can run `uv run fasthtml-tailwindcss build app.main:app` from the project directory. The build uses the application module's directory, so both approaches produce `app/static/tailwind.css` by default.
|
|
126
|
+
|
|
127
|
+
Deploy the generated stylesheet with the application. The compiler is only needed in the build environment.
|
|
128
|
+
|
|
129
|
+
## Development
|
|
130
|
+
|
|
131
|
+
### Setup and tests
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
uv sync --group dev
|
|
135
|
+
uv run --group dev python -m scripts.generate
|
|
136
|
+
uv run --group dev pytest
|
|
137
|
+
uv run --group dev ruff check src scripts tests hatch_build.py
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The development group includes the generator dependencies and Tailwind compiler. They are not dependencies of the published wrapper. Theme bootstrap tests also use Node.js when available; the application does not require it.
|
|
141
|
+
|
|
142
|
+
### Regenerate components and assets
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
uv run --group dev python -m scripts.generate
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
This downloads the exact `basecoat-css` version from `pyproject.toml` (without a `.postN` suffix), verifies npm integrity, and downloads the matching GitHub tag. Source and npm versions must agree. The generator parses CSS once, produces ordinary Python functions, copies local assets, and updates `generation.json`. It stops if previously generated components disappear.
|
|
149
|
+
|
|
150
|
+
For local upstream sources:
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
uv run --group dev python -m scripts.generate --source ../basecoat --package /path/to/extracted/npm/package
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Generated Python components and `generation.json` are committed to this repository. Composed helpers live in `helpers.py` and are not overwritten during regeneration. Input stylesheets register their Tailwind classes automatically. Downloaded CSS and JavaScript stay in the ignored `src/fasthtml_basecoat/assets/` directory. CI regenerates them before building packages.
|
|
157
|
+
|
|
158
|
+
### Build
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
uv build --no-sources
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Generate assets first when building from a Git checkout; the build stops if they are missing. The universal wheel and source distribution include all CSS, JavaScript, and license notices, so installation and wheel builds from the source distribution need no Basecoat download. BeautifulSoup and tinycss2 are used only by the development generator.
|
|
165
|
+
|
|
166
|
+
### Automated releases
|
|
167
|
+
|
|
168
|
+
A daily [Release workflow](.github/workflows/release.yml) checks `basecoat-css` on npm. A new stable npm version triggers regeneration, wheel tests, and publication to PyPI. GitHub supplies only the matching source tag; it does not determine the released version.
|
|
169
|
+
|
|
170
|
+
Configure PyPI Trusted Publishing for repository `SpaceShaman/fasthtml-basecoatui`, workflow `release.yml`, and environment `pypi`. The workflow needs permission to commit generated files and version updates to the default branch.
|
|
171
|
+
|
|
172
|
+
### Manual releases
|
|
173
|
+
|
|
174
|
+
For Python-only fixes, run `uv version --bump post --no-sync`, commit and push the changes, then run **Actions → Release → Run workflow**. The workflow creates the tag and publishes the package. Versions follow Basecoat, with `.postN` for wrapper fixes.
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT. Bundled Basecoat resources retain their [upstream license](BASECOAT-LICENSE).
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.1.0",
|
|
3
|
+
"styles": [
|
|
4
|
+
"luma",
|
|
5
|
+
"lyra",
|
|
6
|
+
"maia",
|
|
7
|
+
"mira",
|
|
8
|
+
"nova",
|
|
9
|
+
"rhea",
|
|
10
|
+
"sera",
|
|
11
|
+
"vega"
|
|
12
|
+
],
|
|
13
|
+
"components": [
|
|
14
|
+
"Accordion",
|
|
15
|
+
"Alert",
|
|
16
|
+
"AlertDialog",
|
|
17
|
+
"Avatar",
|
|
18
|
+
"AvatarBadge",
|
|
19
|
+
"AvatarGroup",
|
|
20
|
+
"Badge",
|
|
21
|
+
"Breadcrumb",
|
|
22
|
+
"Button",
|
|
23
|
+
"ButtonGroup",
|
|
24
|
+
"Card",
|
|
25
|
+
"CardAction",
|
|
26
|
+
"Checkbox",
|
|
27
|
+
"Combobox",
|
|
28
|
+
"ComboboxTriggerIcon",
|
|
29
|
+
"Command",
|
|
30
|
+
"CommandDialog",
|
|
31
|
+
"Dialog",
|
|
32
|
+
"Drawer",
|
|
33
|
+
"DropdownMenu",
|
|
34
|
+
"Empty",
|
|
35
|
+
"Field",
|
|
36
|
+
"Fieldset",
|
|
37
|
+
"Input",
|
|
38
|
+
"InputGroup",
|
|
39
|
+
"Item",
|
|
40
|
+
"ItemGroup",
|
|
41
|
+
"Kbd",
|
|
42
|
+
"Label",
|
|
43
|
+
"NativeSelect",
|
|
44
|
+
"Popover",
|
|
45
|
+
"Progress",
|
|
46
|
+
"Radio",
|
|
47
|
+
"Select",
|
|
48
|
+
"Sidebar",
|
|
49
|
+
"Skeleton",
|
|
50
|
+
"Slider",
|
|
51
|
+
"Switch",
|
|
52
|
+
"Table",
|
|
53
|
+
"TableContainer",
|
|
54
|
+
"Tabs",
|
|
55
|
+
"Textarea",
|
|
56
|
+
"Toast",
|
|
57
|
+
"ToastContent"
|
|
58
|
+
],
|
|
59
|
+
"helpers": [
|
|
60
|
+
"Pagination",
|
|
61
|
+
"PaginationLink",
|
|
62
|
+
"ScrollArea",
|
|
63
|
+
"Separator",
|
|
64
|
+
"Spinner",
|
|
65
|
+
"ThemeSwitcher"
|
|
66
|
+
],
|
|
67
|
+
"attributes": {
|
|
68
|
+
"tooltip": "data-tooltip"
|
|
69
|
+
},
|
|
70
|
+
"skipped": [
|
|
71
|
+
"chart"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CustomBuildHook(BuildHookInterface):
|
|
8
|
+
def initialize(self, version, build_data):
|
|
9
|
+
if version == "editable":
|
|
10
|
+
return
|
|
11
|
+
root = Path(self.root)
|
|
12
|
+
report = json.loads((root / "generation.json").read_text(encoding="utf-8"))
|
|
13
|
+
expected = self.metadata.version.split(".post")[0]
|
|
14
|
+
if report["version"] != expected:
|
|
15
|
+
raise ValueError("Regenerate components for the current Basecoat version")
|
|
16
|
+
assets = root / "src/fasthtml_basecoat/assets"
|
|
17
|
+
required = [assets / "js/all.min.js"]
|
|
18
|
+
for style in report["styles"]:
|
|
19
|
+
required.extend(
|
|
20
|
+
(
|
|
21
|
+
assets / "css" / f"{style}.css",
|
|
22
|
+
assets / "css" / f"basecoat-{style}.bundle.css",
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
if not all(path.is_file() for path in required):
|
|
26
|
+
raise RuntimeError(
|
|
27
|
+
"Missing Basecoat assets. Run: uv run --group dev python -m scripts.generate"
|
|
28
|
+
)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "fasthtml-basecoatui"
|
|
3
|
+
version = "1.1.0"
|
|
4
|
+
description = "Basecoat components and bundled assets for FastHTML."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["BASECOAT-LICENSE", "LICENSE"]
|
|
9
|
+
authors = [{ name = "SpaceShaman", email = "spaceshaman@tuta.io" }]
|
|
10
|
+
keywords = ["basecoat", "components", "fasthtml", "tailwindcss", "web"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
14
|
+
"Programming Language :: Python :: 3.11",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
"Programming Language :: Python :: 3.13",
|
|
17
|
+
"Programming Language :: Python :: 3.14",
|
|
18
|
+
"Programming Language :: Python :: 3.15",
|
|
19
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
20
|
+
"Typing :: Typed",
|
|
21
|
+
]
|
|
22
|
+
dependencies = ["fasthtml-tailwindcss>=4.3.3.post1", "python-fasthtml>=0.14.14"]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Documentation = "https://github.com/SpaceShaman/fasthtml-basecoatui#readme"
|
|
26
|
+
Homepage = "https://github.com/SpaceShaman/fasthtml-basecoatui"
|
|
27
|
+
Issues = "https://github.com/SpaceShaman/fasthtml-basecoatui/issues"
|
|
28
|
+
Repository = "https://github.com/SpaceShaman/fasthtml-basecoatui"
|
|
29
|
+
|
|
30
|
+
[dependency-groups]
|
|
31
|
+
dev = ["beautifulsoup4>=4.13", "fasthtml-tailwindcss[dev]>=4.3.3.post1,<5", "hatchling>=1.27", "httpx", "pytest>=8", "ruff", "tinycss2>=1.4"]
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = ["hatchling>=1.27"]
|
|
35
|
+
build-backend = "hatchling.build"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build]
|
|
38
|
+
artifacts = ["src/fasthtml_basecoat/assets/**"]
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.hooks.custom]
|
|
41
|
+
path = "hatch_build.py"
|
|
42
|
+
|
|
43
|
+
[tool.hatch.build.targets.wheel]
|
|
44
|
+
packages = ["src/fasthtml_basecoat"]
|
|
45
|
+
|
|
46
|
+
[tool.hatch.build.targets.sdist]
|
|
47
|
+
include = ["/src", "/scripts", "/tests", "/hatch_build.py", "/pyproject.toml", "/README.md", "/LICENSE", "/BASECOAT-LICENSE", "/generation.json"]
|
|
48
|
+
|
|
49
|
+
[tool.pytest.ini_options]
|
|
50
|
+
pythonpath = ["."]
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint]
|
|
53
|
+
select = ["E4", "E7", "E9", "F", "I"]
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import re
|
|
4
|
+
import subprocess
|
|
5
|
+
import tomllib
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from urllib.error import HTTPError
|
|
8
|
+
from urllib.request import urlopen
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def published_files(version):
|
|
12
|
+
try:
|
|
13
|
+
with urlopen(
|
|
14
|
+
f"https://pypi.org/pypi/fasthtml-basecoatui/{version}/json", timeout=30
|
|
15
|
+
) as response:
|
|
16
|
+
return {item["filename"] for item in json.load(response)["urls"]}
|
|
17
|
+
except HTTPError as error:
|
|
18
|
+
if error.code != 404:
|
|
19
|
+
raise
|
|
20
|
+
return set()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def main():
|
|
24
|
+
current = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
|
|
25
|
+
with urlopen(
|
|
26
|
+
"https://registry.npmjs.org/basecoat-css/latest", timeout=30
|
|
27
|
+
) as response:
|
|
28
|
+
latest = json.load(response)["version"]
|
|
29
|
+
if not re.fullmatch(r"\d+\.\d+\.\d+", latest):
|
|
30
|
+
raise ValueError(f"Expected stable npm version, got {latest!r}")
|
|
31
|
+
if tuple(map(int, latest.split("."))) > tuple(
|
|
32
|
+
map(int, current.split(".post")[0].split("."))
|
|
33
|
+
):
|
|
34
|
+
subprocess.run(["uv", "version", latest, "--frozen", "--no-sync"], check=True)
|
|
35
|
+
current = latest
|
|
36
|
+
expected = {
|
|
37
|
+
f"fasthtml_basecoatui-{current}-py3-none-any.whl",
|
|
38
|
+
f"fasthtml_basecoatui-{current}.tar.gz",
|
|
39
|
+
}
|
|
40
|
+
release = not expected <= published_files(current)
|
|
41
|
+
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
|
|
42
|
+
output.write(f"version={current}\nrelease={str(release).lower()}\n")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
main()
|