fjkit 0.1.0.dev0__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.
Files changed (165) hide show
  1. fjkit-0.1.0.dev0/.gitignore +37 -0
  2. fjkit-0.1.0.dev0/LICENSE +21 -0
  3. fjkit-0.1.0.dev0/PKG-INFO +119 -0
  4. fjkit-0.1.0.dev0/README.md +92 -0
  5. fjkit-0.1.0.dev0/docs/README.md +127 -0
  6. fjkit-0.1.0.dev0/docs/workbench/assets/brand.css +223 -0
  7. fjkit-0.1.0.dev0/docs/workbench/assets/common.js +90 -0
  8. fjkit-0.1.0.dev0/docs/workbench/assets/components.js +1113 -0
  9. fjkit-0.1.0.dev0/docs/workbench/assets/learn.js +1155 -0
  10. fjkit-0.1.0.dev0/docs/workbench/assets/mock-server.js +99 -0
  11. fjkit-0.1.0.dev0/docs/workbench/build.py +488 -0
  12. fjkit-0.1.0.dev0/docs/workbench/build_data.py +682 -0
  13. fjkit-0.1.0.dev0/docs/workbench/cheatsheet.py +1177 -0
  14. fjkit-0.1.0.dev0/docs/workbench/data.json +1 -0
  15. fjkit-0.1.0.dev0/docs/workbench/templates/_diagram.html +73 -0
  16. fjkit-0.1.0.dev0/docs/workbench/templates/_parts.html +140 -0
  17. fjkit-0.1.0.dev0/docs/workbench/templates/_shell_diagram.html +58 -0
  18. fjkit-0.1.0.dev0/docs/workbench/templates/base.html +148 -0
  19. fjkit-0.1.0.dev0/docs/workbench/templates/cheatsheet.html +196 -0
  20. fjkit-0.1.0.dev0/docs/workbench/templates/components.html +551 -0
  21. fjkit-0.1.0.dev0/docs/workbench/templates/introduction.html +109 -0
  22. fjkit-0.1.0.dev0/docs/workbench/templates/learn.html +1188 -0
  23. fjkit-0.1.0.dev0/docs/workbench/templates/plugins.html +585 -0
  24. fjkit-0.1.0.dev0/docs/workbench/templates/zh/cheatsheet.html +162 -0
  25. fjkit-0.1.0.dev0/docs/workbench/templates/zh/components.html +521 -0
  26. fjkit-0.1.0.dev0/docs/workbench/templates/zh/introduction.html +101 -0
  27. fjkit-0.1.0.dev0/docs/workbench/templates/zh/learn.html +1148 -0
  28. fjkit-0.1.0.dev0/docs/workbench/templates/zh/plugins.html +561 -0
  29. fjkit-0.1.0.dev0/pyproject.toml +99 -0
  30. fjkit-0.1.0.dev0/scripts/vendor_icons.py +64 -0
  31. fjkit-0.1.0.dev0/scripts/vendor_ui.py +117 -0
  32. fjkit-0.1.0.dev0/src/fjkit/__init__.py +49 -0
  33. fjkit-0.1.0.dev0/src/fjkit/auth/__init__.py +54 -0
  34. fjkit-0.1.0.dev0/src/fjkit/auth/csrf.py +88 -0
  35. fjkit-0.1.0.dev0/src/fjkit/auth/errors.py +31 -0
  36. fjkit-0.1.0.dev0/src/fjkit/auth/plugin.py +496 -0
  37. fjkit-0.1.0.dev0/src/fjkit/auth/sources.py +24 -0
  38. fjkit-0.1.0.dev0/src/fjkit/auth/stores.py +141 -0
  39. fjkit-0.1.0.dev0/src/fjkit/auth/types.py +141 -0
  40. fjkit-0.1.0.dev0/src/fjkit/cli/__init__.py +67 -0
  41. fjkit-0.1.0.dev0/src/fjkit/cli/build_css.py +135 -0
  42. fjkit-0.1.0.dev0/src/fjkit/cli/check.py +193 -0
  43. fjkit-0.1.0.dev0/src/fjkit/cli/eject.py +562 -0
  44. fjkit-0.1.0.dev0/src/fjkit/cli/ejected.py +202 -0
  45. fjkit-0.1.0.dev0/src/fjkit/cli/vocabulary.py +85 -0
  46. fjkit-0.1.0.dev0/src/fjkit/config.py +130 -0
  47. fjkit-0.1.0.dev0/src/fjkit/errors.py +156 -0
  48. fjkit-0.1.0.dev0/src/fjkit/flash.py +189 -0
  49. fjkit-0.1.0.dev0/src/fjkit/forms.py +145 -0
  50. fjkit-0.1.0.dev0/src/fjkit/htmx.py +76 -0
  51. fjkit-0.1.0.dev0/src/fjkit/icons.py +60 -0
  52. fjkit-0.1.0.dev0/src/fjkit/messages.py +227 -0
  53. fjkit-0.1.0.dev0/src/fjkit/mounting.py +72 -0
  54. fjkit-0.1.0.dev0/src/fjkit/plugins.py +223 -0
  55. fjkit-0.1.0.dev0/src/fjkit/py.typed +0 -0
  56. fjkit-0.1.0.dev0/src/fjkit/rendering.py +554 -0
  57. fjkit-0.1.0.dev0/src/fjkit/signing.py +63 -0
  58. fjkit-0.1.0.dev0/src/fjkit/static/brand/torii-bolt.png +0 -0
  59. fjkit-0.1.0.dev0/src/fjkit/static/dist/fjkit-luma.css +2 -0
  60. fjkit-0.1.0.dev0/src/fjkit/static/dist/fjkit-lyra.css +2 -0
  61. fjkit-0.1.0.dev0/src/fjkit/static/dist/fjkit-maia.css +2 -0
  62. fjkit-0.1.0.dev0/src/fjkit/static/dist/fjkit-mira.css +2 -0
  63. fjkit-0.1.0.dev0/src/fjkit/static/dist/fjkit-nova.css +2 -0
  64. fjkit-0.1.0.dev0/src/fjkit/static/dist/fjkit-rhea.css +2 -0
  65. fjkit-0.1.0.dev0/src/fjkit/static/dist/fjkit-sera.css +2 -0
  66. fjkit-0.1.0.dev0/src/fjkit/static/dist/fjkit-vega.css +2 -0
  67. fjkit-0.1.0.dev0/src/fjkit/static/icons/lucide.json +1 -0
  68. fjkit-0.1.0.dev0/src/fjkit/static/js/errors.js +117 -0
  69. fjkit-0.1.0.dev0/src/fjkit/static/js/multiselect.js +126 -0
  70. fjkit-0.1.0.dev0/src/fjkit/static/js/reveal.js +51 -0
  71. fjkit-0.1.0.dev0/src/fjkit/static/js/select.js +113 -0
  72. fjkit-0.1.0.dev0/src/fjkit/static/src/fjkit.css +385 -0
  73. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/base/base.css +136 -0
  74. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-base.css +2 -0
  75. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-components.css +39 -0
  76. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-luma.css +2 -0
  77. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-lyra.css +2 -0
  78. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-maia.css +2 -0
  79. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-mira.css +2 -0
  80. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-nova.css +2 -0
  81. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-rhea.css +2 -0
  82. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-sera.css +2 -0
  83. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat-vega.css +2 -0
  84. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat.all.css +1 -0
  85. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/basecoat.css +1 -0
  86. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/accordion.css +27 -0
  87. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/alert.css +38 -0
  88. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/avatar.css +47 -0
  89. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/badge.css +6 -0
  90. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/breadcrumb.css +30 -0
  91. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/button-group.css +54 -0
  92. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/button.css +6 -0
  93. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/card.css +26 -0
  94. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/chart.css +56 -0
  95. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/checkbox.css +12 -0
  96. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/collapsible.css +21 -0
  97. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/combobox.css +99 -0
  98. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/command.css +140 -0
  99. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/dialog.css +101 -0
  100. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/drawer.css +89 -0
  101. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/dropdown-menu.css +56 -0
  102. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/empty.css +26 -0
  103. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/field.css +82 -0
  104. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/form.css +9 -0
  105. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/input-group.css +74 -0
  106. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/input.css +32 -0
  107. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/item.css +50 -0
  108. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/kbd.css +6 -0
  109. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/label.css +13 -0
  110. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/native-select.css +12 -0
  111. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/popover.css +107 -0
  112. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/progress.css +14 -0
  113. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/radio.css +11 -0
  114. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/range.css +50 -0
  115. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/scrollbar.css +46 -0
  116. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/select.css +64 -0
  117. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/sidebar.css +101 -0
  118. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/skeleton.css +6 -0
  119. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/switch.css +8 -0
  120. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/table.css +34 -0
  121. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/tabs.css +31 -0
  122. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/textarea.css +7 -0
  123. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/toast.css +57 -0
  124. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/components/tooltip.css +82 -0
  125. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/js/all.min.js +1 -0
  126. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/styles/luma.css +1376 -0
  127. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/styles/lyra.css +1379 -0
  128. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/styles/maia.css +1364 -0
  129. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/styles/mira.css +1373 -0
  130. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/styles/nova.css +1387 -0
  131. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/styles/rhea.css +1381 -0
  132. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/styles/sera.css +1397 -0
  133. fjkit-0.1.0.dev0/src/fjkit/static/vendor/basecoat/styles/vega.css +1386 -0
  134. fjkit-0.1.0.dev0/src/fjkit/static/vendor/htmx/htmx.min.js +1 -0
  135. fjkit-0.1.0.dev0/src/fjkit/static/vendor/htmx/json-enc.js +38 -0
  136. fjkit-0.1.0.dev0/src/fjkit/styles.py +30 -0
  137. fjkit-0.1.0.dev0/src/fjkit/templates/errors/page.html +92 -0
  138. fjkit-0.1.0.dev0/src/fjkit/templates/ui/attrs.html +18 -0
  139. fjkit-0.1.0.dev0/src/fjkit/templates/ui/button.html +64 -0
  140. fjkit-0.1.0.dev0/src/fjkit/templates/ui/data.html +362 -0
  141. fjkit-0.1.0.dev0/src/fjkit/templates/ui/disclosure.html +89 -0
  142. fjkit-0.1.0.dev0/src/fjkit/templates/ui/feedback.html +313 -0
  143. fjkit-0.1.0.dev0/src/fjkit/templates/ui/form.html +595 -0
  144. fjkit-0.1.0.dev0/src/fjkit/templates/ui/icon.html +13 -0
  145. fjkit-0.1.0.dev0/src/fjkit/templates/ui/layout.html +189 -0
  146. fjkit-0.1.0.dev0/src/fjkit/templates/ui/nav.html +110 -0
  147. fjkit-0.1.0.dev0/src/fjkit/templates/ui/overlay.html +624 -0
  148. fjkit-0.1.0.dev0/src/fjkit/templates/ui/shell.html +170 -0
  149. fjkit-0.1.0.dev0/src/fjkit/templates/ui/sidebar.html +170 -0
  150. fjkit-0.1.0.dev0/src/fjkit/templates/ui/table.html +427 -0
  151. fjkit-0.1.0.dev0/src/fjkit/templates/ui/tabs.html +133 -0
  152. fjkit-0.1.0.dev0/src/fjkit/templating.py +365 -0
  153. fjkit-0.1.0.dev0/src/fjkit/vendored.py +46 -0
  154. fjkit-0.1.0.dev0/tests/conftest.py +27 -0
  155. fjkit-0.1.0.dev0/tests/test_auth.py +519 -0
  156. fjkit-0.1.0.dev0/tests/test_components.py +2124 -0
  157. fjkit-0.1.0.dev0/tests/test_docs_site.py +297 -0
  158. fjkit-0.1.0.dev0/tests/test_errors.py +583 -0
  159. fjkit-0.1.0.dev0/tests/test_flash.py +146 -0
  160. fjkit-0.1.0.dev0/tests/test_messages.py +294 -0
  161. fjkit-0.1.0.dev0/tests/test_mounting.py +106 -0
  162. fjkit-0.1.0.dev0/tests/test_plugins.py +205 -0
  163. fjkit-0.1.0.dev0/tests/test_rendering.py +902 -0
  164. fjkit-0.1.0.dev0/tests/test_style_packs.py +84 -0
  165. fjkit-0.1.0.dev0/tests/test_vocabulary.py +535 -0
@@ -0,0 +1,37 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ *.egg-info
5
+
6
+ # Packaging output — anchored to the repo root on purpose, so the pattern does
7
+ # not swallow app/static/dist/, which is a build artefact we DO commit.
8
+ /build/
9
+ /dist/
10
+ /wheels/
11
+
12
+ # Virtual environments
13
+ .venv
14
+
15
+ # Project
16
+ .env
17
+ # The admin demo's database — created and seeded on first start.
18
+ examples/fjkit-admin-demo/admin-demo.sqlite
19
+ .jinja-cache/
20
+ .pytest_cache/
21
+
22
+ # fjkit build output — regenerated by `uv run fjkit build-css`
23
+ packages/fjkit/src/fjkit/static/dist/
24
+
25
+ # Docs-site intermediate — regenerated by `docs/workbench/build.py`. The
26
+ # templates and the renderers are the source; this is the rendered previews on
27
+ # their way into docs/assets/data.js, which IS committed.
28
+ packages/fjkit/docs/workbench/data.json
29
+
30
+ # 私人目標文件 — 刻意不進版控
31
+ /goal/
32
+
33
+ # Agent worktrees — embedded checkouts, never part of a commit.
34
+ .claude/worktrees/
35
+
36
+ # The built editor extension; `tools/fjkit-vscode/build.py` recreates it.
37
+ tools/fjkit-vscode/dist/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 liweicheng00
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,119 @@
1
+ Metadata-Version: 2.5
2
+ Name: fjkit
3
+ Version: 0.1.0.dev0
4
+ Summary: Server-rendered UI kit for FastAPI — Jinja2 + Basecoat + htmx, no front-end build
5
+ Project-URL: Homepage, https://liweicheng00.github.io/fjkit/
6
+ Project-URL: Documentation, https://liweicheng00.github.io/fjkit/
7
+ Project-URL: Repository, https://github.com/liweicheng00/fjkit
8
+ Project-URL: Issues, https://github.com/liweicheng00/fjkit/issues
9
+ Author: liweicheng00
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: basecoat,dark-mode,fastapi,forms,html,htmx,jinja2,no-build,server-rendered,server-side-rendering,tables,templates,ui,ui-components
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Web Environment
15
+ Classifier: Framework :: FastAPI
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
19
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
20
+ Classifier: Topic :: Software Development :: User Interfaces
21
+ Classifier: Topic :: Text Processing :: Markup :: HTML
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.13
24
+ Requires-Dist: fastapi>=0.115
25
+ Requires-Dist: jinja2>=3.1.6
26
+ Description-Content-Type: text/markdown
27
+
28
+ # fjkit
29
+
30
+ fjkit is the UI layer FastAPI does not ship: pages, tables, forms, navigation,
31
+ dark mode and htmx swaps, composed as Jinja macros in the same codebase as your
32
+ handlers.
33
+
34
+ **Your app has no front-end build step.** The stylesheet is compiled when fjkit
35
+ is released, not when your app runs, so your repo has no `package.json`, no
36
+ `node_modules` and no Tailwind binary. Every other rule in fjkit protects that
37
+ one.
38
+
39
+ ## Install
40
+
41
+ Requires Python 3.13+. The runtime dependencies are `fastapi`, `jinja2` and
42
+ `pydantic`, and `fastapi` already requires `pydantic`.
43
+
44
+ ```bash
45
+ uv add fjkit
46
+ ```
47
+
48
+ ## A working page
49
+
50
+ ```python
51
+ from pathlib import Path
52
+
53
+ from fastapi import FastAPI
54
+ from fjkit import FjkitConfig, mount_fjkit
55
+
56
+ config = FjkitConfig(template_dir=Path(__file__).parent / "templates")
57
+
58
+ app = FastAPI()
59
+ mount_fjkit(app, config)
60
+ ```
61
+
62
+ ```jinja
63
+ {% extends "ui/shell.html" %}
64
+ {% from "ui/layout.html" import page_header, grid %}
65
+ {% from "ui/data.html" import stat %}
66
+
67
+ {% block content %}
68
+ {{ page_header("Overview", "How the board is doing") }}
69
+ {% call grid(cols=4) %}
70
+ {{ stat("Total", 42, icon_name="list") }}
71
+ {% endcall %}
72
+ {% endblock %}
73
+ ```
74
+
75
+ ## Rebranding
76
+
77
+ One knob, plain CSS, no build:
78
+
79
+ ```css
80
+ /* your own stylesheet, loaded after fjkit's */
81
+ :root { --primary: oklch(0.55 0.2 145); --primary-foreground: oklch(0.99 0 0); }
82
+ ```
83
+
84
+ ## One handler, two wire formats
85
+
86
+ A handler returns a model, not markup. `@render` picks the format from whether
87
+ the caller has markup waiting, so a fragment route is the app's JSON API
88
+ without a second route:
89
+
90
+ ```console
91
+ $ curl -s localhost:8000/tasks/board
92
+ {"tasks": [...], "stats": {"total": 8, "done_pct": 25}}
93
+
94
+ $ curl -s -H 'HX-Request: true' localhost:8000/tasks/board
95
+ <div id="board">...</div>
96
+ ```
97
+
98
+ The return annotation describes both, so FastAPI has already put the JSON in
99
+ `/docs`. `mode="html"` or `mode="json"` on the decorator forces one.
100
+
101
+ ## Checking your templates
102
+
103
+ fjkit's class vocabulary is closed — apps compose macros rather than writing
104
+ utility classes. That is what makes the no-build promise hold, and it is
105
+ enforceable:
106
+
107
+ ```bash
108
+ uv run fjkit check app/templates
109
+ ```
110
+
111
+ ## Documentation
112
+
113
+ **[Docs](https://liweicheng00.github.io/fjkit/)**
114
+
115
+ Status: pre-release, under active development.
116
+
117
+ ## License
118
+
119
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,92 @@
1
+ # fjkit
2
+
3
+ fjkit is the UI layer FastAPI does not ship: pages, tables, forms, navigation,
4
+ dark mode and htmx swaps, composed as Jinja macros in the same codebase as your
5
+ handlers.
6
+
7
+ **Your app has no front-end build step.** The stylesheet is compiled when fjkit
8
+ is released, not when your app runs, so your repo has no `package.json`, no
9
+ `node_modules` and no Tailwind binary. Every other rule in fjkit protects that
10
+ one.
11
+
12
+ ## Install
13
+
14
+ Requires Python 3.13+. The runtime dependencies are `fastapi`, `jinja2` and
15
+ `pydantic`, and `fastapi` already requires `pydantic`.
16
+
17
+ ```bash
18
+ uv add fjkit
19
+ ```
20
+
21
+ ## A working page
22
+
23
+ ```python
24
+ from pathlib import Path
25
+
26
+ from fastapi import FastAPI
27
+ from fjkit import FjkitConfig, mount_fjkit
28
+
29
+ config = FjkitConfig(template_dir=Path(__file__).parent / "templates")
30
+
31
+ app = FastAPI()
32
+ mount_fjkit(app, config)
33
+ ```
34
+
35
+ ```jinja
36
+ {% extends "ui/shell.html" %}
37
+ {% from "ui/layout.html" import page_header, grid %}
38
+ {% from "ui/data.html" import stat %}
39
+
40
+ {% block content %}
41
+ {{ page_header("Overview", "How the board is doing") }}
42
+ {% call grid(cols=4) %}
43
+ {{ stat("Total", 42, icon_name="list") }}
44
+ {% endcall %}
45
+ {% endblock %}
46
+ ```
47
+
48
+ ## Rebranding
49
+
50
+ One knob, plain CSS, no build:
51
+
52
+ ```css
53
+ /* your own stylesheet, loaded after fjkit's */
54
+ :root { --primary: oklch(0.55 0.2 145); --primary-foreground: oklch(0.99 0 0); }
55
+ ```
56
+
57
+ ## One handler, two wire formats
58
+
59
+ A handler returns a model, not markup. `@render` picks the format from whether
60
+ the caller has markup waiting, so a fragment route is the app's JSON API
61
+ without a second route:
62
+
63
+ ```console
64
+ $ curl -s localhost:8000/tasks/board
65
+ {"tasks": [...], "stats": {"total": 8, "done_pct": 25}}
66
+
67
+ $ curl -s -H 'HX-Request: true' localhost:8000/tasks/board
68
+ <div id="board">...</div>
69
+ ```
70
+
71
+ The return annotation describes both, so FastAPI has already put the JSON in
72
+ `/docs`. `mode="html"` or `mode="json"` on the decorator forces one.
73
+
74
+ ## Checking your templates
75
+
76
+ fjkit's class vocabulary is closed — apps compose macros rather than writing
77
+ utility classes. That is what makes the no-build promise hold, and it is
78
+ enforceable:
79
+
80
+ ```bash
81
+ uv run fjkit check app/templates
82
+ ```
83
+
84
+ ## Documentation
85
+
86
+ **[Docs](https://liweicheng00.github.io/fjkit/)**
87
+
88
+ Status: pre-release, under active development.
89
+
90
+ ## License
91
+
92
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,127 @@
1
+ # fjkit documentation
2
+
3
+ fjkit is the UI layer FastAPI does not ship: pages, tables, forms, navigation,
4
+ dark mode and htmx swaps, composed as Jinja macros in the same codebase as your
5
+ handlers, with no front-end toolchain on your side.
6
+
7
+ The [published site](https://liweicheng00.github.io/fjkit/) is five pages in two
8
+ languages — English at the root, 中文 under
9
+ [`zh/`](https://liweicheng00.github.io/fjkit/zh/). Two of them are operable: set
10
+ macro parameters and read the real output, fire genuine htmx requests and watch
11
+ the swap land, turn the brand knob and watch the page repaint, run the
12
+ vocabulary checker on your own markup.
13
+
14
+ Rebuild the site from this checkout:
15
+
16
+ ```bash
17
+ uv run python packages/fjkit/docs/workbench/build.py
18
+ ```
19
+
20
+ That writes five pages and their shared assets to `docs/` at the repo root,
21
+ which is what GitHub Pages serves (*Settings → Pages → Deploy from a branch →
22
+ `main` / `docs`*):
23
+
24
+ | Output | Page | Covers |
25
+ |---|---|---|
26
+ | `docs/index.html` | Introduction | the landing page — what fjkit is, who it is for, five decisions, what ships in the wheel |
27
+ | `docs/learn.html` | Learn | wiring, the htmx exchange, hx-target/hx-swap/hx-trigger, partials, `hx-swap-oob`, `hx-indicator`/`hx-disabled-elt`, rebranding, `fjkit check` |
28
+ | `docs/plugins.html` | Plugins | the extension seam — middleware, exception handlers and template globals in one registered object, and the session plugin that needed it |
29
+ | `docs/components.html` | Components | every macro, live, with the Jinja call and the HTML it emits — one section per file in `src/fjkit/templates/ui/`, in the order the directory lists them |
30
+ | `docs/cheatsheet.html` | Cheatsheet | the index — every macro with its full signature, whether it is called with a block and what goes inside it, plus the shell's blocks, the template globals and the htmx attributes. Rows come from `workbench/cheatsheet.py`, one source for both languages |
31
+ | `docs/assets/dist/`, `docs/assets/vendor/` | — | the default pack's `fjkit-vega.css`, htmx and Basecoat's JS, byte-identical to the wheel |
32
+ | `docs/assets/brand.css` | — | the site's own stylesheet — tokens, typography, and the gaps |
33
+ | `docs/zh/*.html` | 中文 | the same five pages, translated — `templates/zh/`, one directory deeper, sharing every asset |
34
+
35
+ ## Two languages, one skeleton
36
+
37
+ `base.html`, `_parts.html`, the request diagram and every `assets/*.js` file are
38
+ shared. `templates/zh/` holds the five translated pages, `build.py` holds the
39
+ chrome strings (rail headings, the footer, the diagram's labels), and
40
+ `cheatsheet.py` holds the macro index in both languages at once, so the two
41
+ indexes cannot describe different macros.
42
+
43
+ Each language is one `build_environment()` with its own `static_url` — `assets`
44
+ at the root, `../assets` from `zh/`. GitHub Pages serves the site from
45
+ `/fjkit/`, where an absolute link leaves the site. `test_docs_site.py` checks
46
+ that on the built files: no link starts with `/`, and every one of them resolves
47
+ to a file that is there.
48
+
49
+ ## The site is a fjkit app
50
+
51
+ `templates/base.html` extends `ui/shell.html`, the navigation is `sidebar` +
52
+ `sidebar_link`, and the pages are built from `page_header`, `section`, `card`,
53
+ `table`, `grid` and `stack` — the same macros `examples/fjkit-demo` calls.
54
+ `fjkit check` runs over `templates/` in CI (`tests/test_docs_site.py`) and it
55
+ passes, so the site cannot show you a component the package does not ship.
56
+
57
+ That makes it the kit's second acceptance test, and the harder one: a
58
+ documentation page reaches for shapes an admin never needs. What it cannot say
59
+ in the vocabulary is collected in PART 2 of `workbench/assets/brand.css`, each
60
+ block labelled with the macro that would remove it. **The length of PART 2 is
61
+ the honest answer to "is the vocabulary closed?"** — today it is four, down from
62
+ seven: `code_block`, `tabs` and a vertical `button_group` are components now, so
63
+ their rules moved into `fjkit.css`.
64
+
65
+ Of the four left, one is deliberate — syntax highlighting, because the kit
66
+ renders code as text and should never learn a language — and two are shapes only
67
+ a docs page wants. The fourth matters: the playground builds its controls in the
68
+ browser, so it cannot call `field_row`, and `fjkit check` reads templates and
69
+ never scripts. That is a missing capability and a hole in the gate, and the hole
70
+ is the more serious half.
71
+
72
+ Two knobs turn the app into a static site, both already on `FjkitConfig`:
73
+ `static_url="assets"` so `fjkit_static` resolves next to the page, and
74
+ `globals={"url_for": …, "is_active": …}` so route names still work without a
75
+ request. The shell is used unmodified.
76
+
77
+ ## Where the prose lives
78
+
79
+ There is no prose copy of any of this in the repository. The site is the
80
+ documentation, and `workbench/templates/` is its source. That is deliberate: a
81
+ Markdown page can describe a macro the package stopped shipping, and a rendered
82
+ page cannot — every preview on the site is produced by the kit itself at build
83
+ time.
84
+
85
+ Offline, the authority is the source: `src/fjkit/templates/ui/*.html` opens
86
+ every macro with a signature comment, and `src/fjkit/static/src/fjkit.css`
87
+ holds the token table.
88
+
89
+ ## The four contact points
90
+
91
+ Your app touches fjkit in exactly four places. Everything else is sealed inside
92
+ the package.
93
+
94
+ | Yours | Touches |
95
+ |---|---|
96
+ | `features/*/router.py` | imports `render` |
97
+ | `templates/base.html` | extends `ui/shell.html` |
98
+ | `templates/<feature>/*.html` | `{% from "ui/*.html" import … %}` |
99
+ | your own `brand.css` | overrides the `--primary` tokens |
100
+
101
+ All four point one way: your app depends on fjkit, and fjkit never references
102
+ your app.
103
+
104
+ ## The promises, and what makes each one hold
105
+
106
+ | Promise | Mechanism |
107
+ |---|---|
108
+ | No build step on your side | Tailwind runs in fjkit's release pipeline. All eight `dist/fjkit-<pack>.css`, htmx and Basecoat's JS ship in the wheel |
109
+ | …which only works if | the class vocabulary is closed — layout is a component too, and `fjkit check` enforces it |
110
+ | Rebranding is one file | every colour is a token. Templates name a role, never a hue |
111
+ | A macro cannot be misused | signatures take closed enumerations and never a class string |
112
+ | Page and htmx swap cannot drift | one partial, embedded by the page and returned by the endpoints |
113
+
114
+ The diagrams behind these decisions are in `docs/architecture.md`, at the repo
115
+ root.
116
+
117
+ ## Commands
118
+
119
+ ```bash
120
+ uv run fastapi dev app/main.py # no CSS watcher alongside it — there is nothing to rebuild
121
+ uv run fjkit check app/templates # every class is part of the vocabulary
122
+ uv run fjkit eject <component> # copy a component into your app to edit it
123
+ uv run pytest
124
+ ```
125
+
126
+ Status: pre-release (0.1.0.dev0), under active development. Signatures are not
127
+ frozen until 1.0.
@@ -0,0 +1,223 @@
1
+ /* ============================================================================
2
+ * The documentation site's own stylesheet.
3
+ *
4
+ * This is the fourth contact point the kit documents: "your own brand.css |
5
+ * overrides the --primary tokens". It is loaded after fjkit.css through the
6
+ * shell's `stylesheets` block, and it is the only CSS this site has.
7
+ *
8
+ * It is in two halves, and the split is the point.
9
+ *
10
+ * PART 1 — BRAND. Token overrides and element-level typography. Exactly what
11
+ * an app is supposed to write, and nothing here substitutes for a
12
+ * component. No class selectors.
13
+ *
14
+ * PART 2 — GAPS. Rules that exist only because the kit has no component for
15
+ * the thing being styled. Every block is labelled with what the
16
+ * missing macro would be. This half should shrink with each release;
17
+ * docs/BACKLOG.md tracks it. If you are looking for the honest
18
+ * answer to "is the vocabulary actually closed?", it is the length
19
+ * of part 2.
20
+ * ========================================================================= */
21
+
22
+ /* ---------------------------------------------------------------- PART 1 */
23
+
24
+ :root {
25
+ --docs-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
26
+ }
27
+
28
+ /* The shell drops its `max-w-6xl` when a sidebar is present, because the
29
+ sidebar owns the left edge. A documentation page still wants a measure. */
30
+ main {
31
+ max-width: 72rem;
32
+ }
33
+
34
+ /* Tailwind's preflight zeroes these; a docs page is mostly prose. Element
35
+ selectors, so no paragraph on this site carries a class. */
36
+ main p {
37
+ max-width: 74ch;
38
+ line-height: 1.65;
39
+ }
40
+
41
+ main li {
42
+ line-height: 1.6;
43
+ }
44
+
45
+ code {
46
+ font-family: var(--docs-mono);
47
+ font-size: 0.875em;
48
+ /* The file tree prints its own indentation. */
49
+ white-space: pre;
50
+ }
51
+
52
+ /* `code_block` sets the type and the scroll region; this is only the tree's
53
+ monospace measure and the site's own tab-size preference. */
54
+ .code-block {
55
+ font-family: var(--docs-mono);
56
+ }
57
+
58
+ /* `footer` is this site's caption element: the note under a code pane, the
59
+ line under a preview. Inside a card it sits below the body. */
60
+ main footer {
61
+ color: var(--muted-foreground);
62
+ font-size: 0.8rem;
63
+ line-height: 1.5;
64
+ padding: 0.6rem 1rem;
65
+ border-top: 1px solid var(--border);
66
+ }
67
+
68
+ main .card > footer:first-child {
69
+ border-top: 0;
70
+ border-bottom: 1px solid var(--border);
71
+ }
72
+
73
+ /* htmx puts `htmx-request` on whatever `hx-indicator` names. fjkit ships no
74
+ indicator styling yet (roadmap 0.6) — these two badges are named by id
75
+ rather than by a class, so the templates stay inside the vocabulary. */
76
+ #demo-searching,
77
+ #demo-board-busy {
78
+ opacity: 0;
79
+ transition: opacity 0.15s;
80
+ }
81
+
82
+ #demo-searching.htmx-request,
83
+ #demo-board-busy.htmx-request {
84
+ opacity: 1;
85
+ }
86
+
87
+ @media (prefers-reduced-motion: reduce) {
88
+ * {
89
+ transition: none !important;
90
+ animation: none !important;
91
+ }
92
+ }
93
+
94
+ /* ------------------------------------------------------------------ PART 2
95
+ *
96
+ * Four left. `code_block`, `tabs` and a vertical `button_group` used to live
97
+ * here; they are components now, so their rules moved into `fjkit.css` and this
98
+ * half got shorter. That is the loop this file exists to drive.
99
+ *
100
+ * GAP 1 — syntax highlighting.
101
+ *
102
+ * `code_block` is the kit's, and it deliberately knows no languages: it renders
103
+ * text. Which tokens are keywords is a question the kit should never answer, so
104
+ * the highlighter is this site's, and it marks tokens with `data-t` rather than
105
+ * a class so nothing it injects can be mistaken for vocabulary. Not a gap the
106
+ * kit should close — recorded here so the reason is on the record.
107
+ */
108
+ .code-block [data-t="k"] { color: var(--primary); }
109
+ .code-block [data-t="s"] { color: var(--success); }
110
+ .code-block [data-t="c"] { color: var(--muted-foreground); font-style: italic; }
111
+ .code-block [data-t="a"] { color: var(--info); }
112
+
113
+ /*
114
+ * GAP 2 — a diagram surface.
115
+ *
116
+ * `_diagram.html` is an SVG, and no component library should be drawing one.
117
+ * What is missing is only the frame and the "stage lighting" the request demo
118
+ * drives — both keyed off `data-lit`, so the markup carries no class either
119
+ * way. Arguably a `figure()` macro; more likely this stays an app's problem.
120
+ */
121
+ svg[role="img"] {
122
+ display: block;
123
+ width: 100%;
124
+ max-width: 46rem;
125
+ height: auto;
126
+ margin: 0 auto;
127
+ color: var(--foreground);
128
+ }
129
+
130
+ svg [data-lit="false"] { opacity: 0.32; transition: opacity 0.25s; }
131
+ svg [data-lit="true"] { opacity: 1; transition: opacity 0.25s; }
132
+ svg [data-lit="true"] [data-accent] { stroke: var(--primary); }
133
+ svg [data-lit="true"] text[data-accent] { fill: var(--primary); stroke: none; }
134
+
135
+ /*
136
+ * GAP 3 — a `tile` placeholder, and an `icon_grid`.
137
+ *
138
+ * The layout playground needs something to put *in* a stack or a grid, and a
139
+ * gallery of named things needs a cell. Both fail the inclusion test — a
140
+ * back office does not need either in week one — so they stay here rather than
141
+ * becoming macros nobody else would call.
142
+ */
143
+ [data-tile] {
144
+ border: 1px dashed var(--primary);
145
+ border-radius: var(--radius, 6px);
146
+ background: color-mix(in oklch, var(--primary) 8%, transparent);
147
+ color: var(--primary);
148
+ font-family: var(--docs-mono);
149
+ font-size: 0.72rem;
150
+ padding: 0.9rem 0.75rem;
151
+ text-align: center;
152
+ }
153
+
154
+ #icon-grid {
155
+ display: grid;
156
+ grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
157
+ gap: 0.5rem;
158
+ }
159
+
160
+ #icon-grid figure {
161
+ display: flex;
162
+ flex-direction: column;
163
+ align-items: center;
164
+ gap: 0.4rem;
165
+ margin: 0;
166
+ padding: 0.75rem 0.25rem;
167
+ border: 1px solid var(--border);
168
+ border-radius: var(--radius, 6px);
169
+ }
170
+
171
+ #icon-grid figcaption {
172
+ font-family: var(--docs-mono);
173
+ font-size: 0.66rem;
174
+ color: var(--muted-foreground);
175
+ text-align: center;
176
+ overflow-wrap: anywhere;
177
+ }
178
+
179
+ /*
180
+ * GAP 4 — a `field_row` a script can reach. **The one that matters.**
181
+ *
182
+ * `field_row("three")` is the right component and this site cannot call it: the
183
+ * playground controls are built in the browser from a data structure, not by a
184
+ * template. Copying the macro's utility classes into a .js file would put the
185
+ * markup outside the vocabulary in the one place `fjkit check` does not look —
186
+ * it reads templates, never scripts. So this is both a missing capability and a
187
+ * hole in the gate, and the second half is the more serious one.
188
+ *
189
+ * Two ways out, neither a macro: render the controls server-side and only bind
190
+ * them in the browser, or teach `fjkit check` to read script files too.
191
+ */
192
+ [data-field-row] {
193
+ display: grid;
194
+ gap: 0.75rem;
195
+ align-items: end;
196
+ }
197
+
198
+ @media (min-width: 640px) {
199
+ [data-field-row] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
200
+ }
201
+
202
+ #layout-controls,
203
+ #swap-controls {
204
+ padding: 0.85rem 1rem;
205
+ border-top: 1px solid var(--border);
206
+ }
207
+
208
+ #layout-controls,
209
+ [data-controls],
210
+ [data-picker] > [role="tabpanel"] {
211
+ display: grid;
212
+ gap: 0.75rem 1rem;
213
+ grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
214
+ align-items: end;
215
+ padding: 0.85rem 1rem;
216
+ }
217
+
218
+ /* No `border-top` on the macro panels, unlike the two above: the tablist above
219
+ them already draws one, and a second sits a hairline under the first. */
220
+
221
+ #pattern-list {
222
+ padding: 0.5rem;
223
+ }