answerui-py 0.0.2__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 (38) hide show
  1. answerui_py-0.0.2/LICENSE +201 -0
  2. answerui_py-0.0.2/MANIFEST.in +4 -0
  3. answerui_py-0.0.2/PKG-INFO +136 -0
  4. answerui_py-0.0.2/README.md +112 -0
  5. answerui_py-0.0.2/answerui/__init__.py +20 -0
  6. answerui_py-0.0.2/answerui/_modidx.py +143 -0
  7. answerui_py-0.0.2/answerui/all.py +14 -0
  8. answerui_py-0.0.2/answerui/base.py +89 -0
  9. answerui_py-0.0.2/answerui/behaviors.py +83 -0
  10. answerui_py-0.0.2/answerui/controls.py +436 -0
  11. answerui_py-0.0.2/answerui/css/palette.css +12 -0
  12. answerui_py-0.0.2/answerui/css/typrose.LICENSE +21 -0
  13. answerui_py-0.0.2/answerui/css/typrose.css +358 -0
  14. answerui_py-0.0.2/answerui/data.py +43 -0
  15. answerui_py-0.0.2/answerui/demo.py +98 -0
  16. answerui_py-0.0.2/answerui/fonts/IBM-Plex.LICENSE +93 -0
  17. answerui_py-0.0.2/answerui/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  18. answerui_py-0.0.2/answerui/fonts/ibm-plex-sans-latin-400-italic.woff2 +0 -0
  19. answerui_py-0.0.2/answerui/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  20. answerui_py-0.0.2/answerui/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  21. answerui_py-0.0.2/answerui/fonts/ibm-plex-serif-latin-600-normal.woff2 +0 -0
  22. answerui_py-0.0.2/answerui/hdrs.py +80 -0
  23. answerui_py-0.0.2/answerui/layout.py +113 -0
  24. answerui_py-0.0.2/answerui/navigation.py +113 -0
  25. answerui_py-0.0.2/answerui/overlays.py +243 -0
  26. answerui_py-0.0.2/answerui/registry.py +238 -0
  27. answerui_py-0.0.2/answerui/skill.py +92 -0
  28. answerui_py-0.0.2/answerui/status.py +187 -0
  29. answerui_py-0.0.2/answerui/surfaces.py +100 -0
  30. answerui_py-0.0.2/answerui/tokens.py +157 -0
  31. answerui_py-0.0.2/answerui_py.egg-info/PKG-INFO +136 -0
  32. answerui_py-0.0.2/answerui_py.egg-info/SOURCES.txt +36 -0
  33. answerui_py-0.0.2/answerui_py.egg-info/dependency_links.txt +1 -0
  34. answerui_py-0.0.2/answerui_py.egg-info/entry_points.txt +5 -0
  35. answerui_py-0.0.2/answerui_py.egg-info/requires.txt +9 -0
  36. answerui_py-0.0.2/answerui_py.egg-info/top_level.txt +1 -0
  37. answerui_py-0.0.2/pyproject.toml +45 -0
  38. answerui_py-0.0.2/setup.cfg +4 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2022, fastai
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ include pyproject.toml
2
+ include LICENSE
3
+ include README.md
4
+ recursive-exclude * __pycache__
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.4
2
+ Name: answerui-py
3
+ Version: 0.0.2
4
+ Summary: A semantic HTML UI framework for FastHTML apps
5
+ Author-email: Jack Hogan <jackhogan4@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Repository, https://github.com/AnswerDotAI/answerui
8
+ Project-URL: Documentation, https://AnswerDotAI.github.io/answerui/
9
+ Keywords: nbdev
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Requires-Python: >=3.11
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: python-fasthtml
16
+ Requires-Dist: fastlucide
17
+ Provides-Extra: dev
18
+ Requires-Dist: nbdev>=3.3.28; extra == "dev"
19
+ Requires-Dist: numpy; extra == "dev"
20
+ Requires-Dist: scipy; extra == "dev"
21
+ Requires-Dist: matplotlib; extra == "dev"
22
+ Requires-Dist: pandas; extra == "dev"
23
+ Dynamic: license-file
24
+
25
+ # answerui
26
+
27
+
28
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
29
+
30
+ answerui styles semantic HTML for [FastHTML](https://fastht.ml) apps. A component is an HTML tag, a variant or a state is an attribute, and classes do only utility jobs, so page markup stays small and readable. Every component’s CSS and behavior lives in one registry, and a page carries the whole registry as one stylesheet and one script. An app changes the look by registering ordinary CSS in the same registry, scoped to a token, a component, or a region.
31
+ answerui is built for a human working with an LLM in a persistent Python kernel. Its pyskill, `answerui.skill`, teaches the model the library: how a page is built, how to read what is registered, how to change it, and how to check the result.
32
+
33
+ ## Install
34
+
35
+ ``` sh
36
+ pip install -e .
37
+ ```
38
+
39
+ ## Use
40
+
41
+ `reg.hdrs()` gives the stylesheet and the behavior script, and `reg.ftrs()` gives the sprite sheet for icons. Both render per response, so a rule registered later is in the next page:
42
+
43
+ ``` python
44
+ from fasthtml.common import *
45
+ from answerui.all import *
46
+ ```
47
+
48
+ ``` python
49
+ app = FastHTML(hdrs=reg.hdrs(), ftrs=reg.ftrs())
50
+ rt = app.route
51
+ ```
52
+
53
+ `reg.serve(app)` serves the same assets from URLs named by a hash of their content, which the browser caches. They are rebuilt when a rule changes, and the next page links the new build as a new URL.
54
+
55
+ A page is native HTML inside layout containers, with a component wherever the platform has no element for the job. Variants and severities are attributes:
56
+
57
+ ``` python
58
+ page = Card(H2('Profile'), Field('Name', Input(name='name')), Cluster(Button('Save'), Button('Cancel', secondary=True)))
59
+ print(to_xml(page, Alert('Saved.', success=True, dismissible=True)))
60
+ ```
61
+
62
+ <div stack card>
63
+ <h2>Profile</h2>
64
+ <div field>
65
+ <label>Name <input name="name">
66
+ </label> </div>
67
+ <div cluster>
68
+ <button>Save</button><button secondary>Cancel</button> </div>
69
+ </div>
70
+
71
+ <div card alert success>
72
+ <div stack style="--gap: var(--space-2);">Saved.</div>
73
+ <button type="button" secondary dismiss>Dismiss</button></div>
74
+
75
+ Rendered with the registry’s stylesheet. In a notebook, `demo(page)` shows the same thing live:
76
+
77
+ ![](index_files/page.png)
78
+
79
+ ## Customise
80
+
81
+ A change is ordinary CSS registered at the smallest scope that covers it: a token on the root for the whole app, a rule on a component, or a selector for a region. App rules sit in a cascade layer above the framework’s, so nothing in the framework needs editing:
82
+
83
+ ``` python
84
+ reg.rule('theme', ':root { --hue: 150; --radius: 0; }')
85
+ Button.rule('caps', 'text-transform: uppercase;')
86
+ ```
87
+
88
+ Button.caps [app] button, a[button]
89
+
90
+ A variant is a new treatment declared on the component. It becomes an attribute the constructor accepts and appears in the component’s documentation:
91
+
92
+ ``` python
93
+ Button.variant('cta', '--pad-block: var(--space); --pad-inline: var(--space2); font-size: var(--text1);', doc='The landing page call to action.')
94
+ ```
95
+
96
+ Button.cta [app] :is(button, a[button])[cta]: The landing page call to action.
97
+
98
+ ![](index_files/custom.png)
99
+
100
+ ``` python
101
+ Button
102
+ ```
103
+
104
+ ### `Button(*children, **attrs)`
105
+
106
+ Raised at rest, down while active, busy, or expanded, latched by `aria-pressed`; `secondary` for the lesser action; a link carrying `button` is styled the same way.
107
+
108
+ Root selector: `button, a[button]`.
109
+
110
+ Declared variants:
111
+ - `secondary`: The lesser action: the neutral surface with a hairline border, and the accent wash when latched.
112
+ - `quiet`: No face, border, or shadow at rest, for an action that should not compete: dismiss, close, and toolbar buttons.
113
+ - `editable`: A value drawn as the dashed ghost of the well it becomes; click to edit, and the app swaps the form in.
114
+ - `cta`: The landing page call to action.
115
+
116
+ Rules:
117
+ - `base` (components)
118
+ - `icon-only` (components): A button whose only child is an svg is square; give it an aria-label.
119
+ - `caps` (app)
120
+
121
+ ## Previews in notebooks
122
+
123
+ `demo(page)` renders markup in an iframe with the current stylesheet and behaviors. It returns a preview with two representations: the frame as HTML, and the markup as Markdown. The frame holds the whole stylesheet. Stored in a notebook, it would make a file with many previews large and rewrite every preview on each style change. The preview therefore marks its HTML with nbdev’s `strip` flag. `nbdev-clean` drops the frame and keeps the Markdown, so the committed notebook records what each preview showed. A fresh clone shows the frames again after the cells run.
124
+
125
+ For the docs, set `exec_all` in `pyproject.toml`:
126
+
127
+ ``` toml
128
+ [tool.nbdev]
129
+ exec_all = true
130
+ ```
131
+
132
+ `nbdev-docs` then runs every notebook and renders each preview from the current code.
133
+
134
+ ## With an LLM
135
+
136
+ `answerui.skill` is a [pyskill](https://github.com/AnswerDotAI/pyskills): a module whose docstring teaches a model the library. `list_pyskills()` finds it, `doc(answerui.skill)` is the guide, and `doc(Button)` describes a component, its variants, and its rules.
@@ -0,0 +1,112 @@
1
+ # answerui
2
+
3
+
4
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5
+
6
+ answerui styles semantic HTML for [FastHTML](https://fastht.ml) apps. A component is an HTML tag, a variant or a state is an attribute, and classes do only utility jobs, so page markup stays small and readable. Every component’s CSS and behavior lives in one registry, and a page carries the whole registry as one stylesheet and one script. An app changes the look by registering ordinary CSS in the same registry, scoped to a token, a component, or a region.
7
+ answerui is built for a human working with an LLM in a persistent Python kernel. Its pyskill, `answerui.skill`, teaches the model the library: how a page is built, how to read what is registered, how to change it, and how to check the result.
8
+
9
+ ## Install
10
+
11
+ ``` sh
12
+ pip install -e .
13
+ ```
14
+
15
+ ## Use
16
+
17
+ `reg.hdrs()` gives the stylesheet and the behavior script, and `reg.ftrs()` gives the sprite sheet for icons. Both render per response, so a rule registered later is in the next page:
18
+
19
+ ``` python
20
+ from fasthtml.common import *
21
+ from answerui.all import *
22
+ ```
23
+
24
+ ``` python
25
+ app = FastHTML(hdrs=reg.hdrs(), ftrs=reg.ftrs())
26
+ rt = app.route
27
+ ```
28
+
29
+ `reg.serve(app)` serves the same assets from URLs named by a hash of their content, which the browser caches. They are rebuilt when a rule changes, and the next page links the new build as a new URL.
30
+
31
+ A page is native HTML inside layout containers, with a component wherever the platform has no element for the job. Variants and severities are attributes:
32
+
33
+ ``` python
34
+ page = Card(H2('Profile'), Field('Name', Input(name='name')), Cluster(Button('Save'), Button('Cancel', secondary=True)))
35
+ print(to_xml(page, Alert('Saved.', success=True, dismissible=True)))
36
+ ```
37
+
38
+ <div stack card>
39
+ <h2>Profile</h2>
40
+ <div field>
41
+ <label>Name <input name="name">
42
+ </label> </div>
43
+ <div cluster>
44
+ <button>Save</button><button secondary>Cancel</button> </div>
45
+ </div>
46
+
47
+ <div card alert success>
48
+ <div stack style="--gap: var(--space-2);">Saved.</div>
49
+ <button type="button" secondary dismiss>Dismiss</button></div>
50
+
51
+ Rendered with the registry’s stylesheet. In a notebook, `demo(page)` shows the same thing live:
52
+
53
+ ![](index_files/page.png)
54
+
55
+ ## Customise
56
+
57
+ A change is ordinary CSS registered at the smallest scope that covers it: a token on the root for the whole app, a rule on a component, or a selector for a region. App rules sit in a cascade layer above the framework’s, so nothing in the framework needs editing:
58
+
59
+ ``` python
60
+ reg.rule('theme', ':root { --hue: 150; --radius: 0; }')
61
+ Button.rule('caps', 'text-transform: uppercase;')
62
+ ```
63
+
64
+ Button.caps [app] button, a[button]
65
+
66
+ A variant is a new treatment declared on the component. It becomes an attribute the constructor accepts and appears in the component’s documentation:
67
+
68
+ ``` python
69
+ Button.variant('cta', '--pad-block: var(--space); --pad-inline: var(--space2); font-size: var(--text1);', doc='The landing page call to action.')
70
+ ```
71
+
72
+ Button.cta [app] :is(button, a[button])[cta]: The landing page call to action.
73
+
74
+ ![](index_files/custom.png)
75
+
76
+ ``` python
77
+ Button
78
+ ```
79
+
80
+ ### `Button(*children, **attrs)`
81
+
82
+ Raised at rest, down while active, busy, or expanded, latched by `aria-pressed`; `secondary` for the lesser action; a link carrying `button` is styled the same way.
83
+
84
+ Root selector: `button, a[button]`.
85
+
86
+ Declared variants:
87
+ - `secondary`: The lesser action: the neutral surface with a hairline border, and the accent wash when latched.
88
+ - `quiet`: No face, border, or shadow at rest, for an action that should not compete: dismiss, close, and toolbar buttons.
89
+ - `editable`: A value drawn as the dashed ghost of the well it becomes; click to edit, and the app swaps the form in.
90
+ - `cta`: The landing page call to action.
91
+
92
+ Rules:
93
+ - `base` (components)
94
+ - `icon-only` (components): A button whose only child is an svg is square; give it an aria-label.
95
+ - `caps` (app)
96
+
97
+ ## Previews in notebooks
98
+
99
+ `demo(page)` renders markup in an iframe with the current stylesheet and behaviors. It returns a preview with two representations: the frame as HTML, and the markup as Markdown. The frame holds the whole stylesheet. Stored in a notebook, it would make a file with many previews large and rewrite every preview on each style change. The preview therefore marks its HTML with nbdev’s `strip` flag. `nbdev-clean` drops the frame and keeps the Markdown, so the committed notebook records what each preview showed. A fresh clone shows the frames again after the cells run.
100
+
101
+ For the docs, set `exec_all` in `pyproject.toml`:
102
+
103
+ ``` toml
104
+ [tool.nbdev]
105
+ exec_all = true
106
+ ```
107
+
108
+ `nbdev-docs` then runs every notebook and renders each preview from the current code.
109
+
110
+ ## With an LLM
111
+
112
+ `answerui.skill` is a [pyskill](https://github.com/AnswerDotAI/pyskills): a module whose docstring teaches a model the library. `list_pyskills()` finds it, `doc(answerui.skill)` is the guide, and `doc(Button)` describes a component, its variants, and its rules.
@@ -0,0 +1,20 @@
1
+ """A semantic HTML UI framework for FastHTML apps
2
+
3
+ Modules:
4
+
5
+ - `answerui.base`: The reset, the document on the tokens, and prose
6
+ - `answerui.behaviors`: The client runtime: delegated event rules that survive htmx swaps
7
+ - `answerui.controls`: Native form controls styled through their own states, raised to press and sunken to type into
8
+ - `answerui.data`: Tables and other displays of structured data
9
+ - `answerui.demo`: Isolated rendering of markup with current styles and behaviors, for notebooks and docs
10
+ - `answerui.hdrs`: App integration: the headers that carry the registry's assets
11
+ - `answerui.layout`: Stack, cluster, grid, and document flow
12
+ - `answerui.navigation`: The navbar
13
+ - `answerui.overlays`: Popovers, menus, dialogs, drawers, and tooltips
14
+ - `answerui.registry`: Defining hyperelements and collecting their styles and behaviors
15
+ - `answerui.skill`: Style a FastHTML app with answerui: build pages from its components, change how they look through the registry, and check the result
16
+ - `answerui.status`: Feedback, loading, and empty states
17
+ - `answerui.surfaces`: Containers and small pieces of visual information
18
+ - `answerui.tokens`: The styling surface: colour, space, radius, type, motion, and elevation"""
19
+
20
+ __version__ = "0.0.2"
@@ -0,0 +1,143 @@
1
+ # Autogenerated by nbdev
2
+
3
+ d = { 'settings': { 'branch': 'main',
4
+ 'doc_baseurl': '/answerui',
5
+ 'doc_host': 'https://AnswerDotAI.github.io',
6
+ 'git_url': 'https://github.com/AnswerDotAI/answerui',
7
+ 'lib_path': 'answerui'},
8
+ 'syms': { 'answerui.behaviors': { 'answerui.behaviors.Registry.behaviors': ('behaviors.html#registry.behaviors', 'answerui/behaviors.py'),
9
+ 'answerui.behaviors.Registry.build_js': ('behaviors.html#registry.build_js', 'answerui/behaviors.py'),
10
+ 'answerui.behaviors._entry': ('behaviors.html#_entry', 'answerui/behaviors.py'),
11
+ 'answerui.behaviors._event': ('behaviors.html#_event', 'answerui/behaviors.py'),
12
+ 'answerui.behaviors._spellings': ('behaviors.html#_spellings', 'answerui/behaviors.py')},
13
+ 'answerui.controls': { 'answerui.controls.Checkbox': ('controls.html#checkbox', 'answerui/controls.py'),
14
+ 'answerui.controls.Copy': ('controls.html#copy', 'answerui/controls.py'),
15
+ 'answerui.controls.Field': ('controls.html#field', 'answerui/controls.py'),
16
+ 'answerui.controls.Group': ('controls.html#group', 'answerui/controls.py'),
17
+ 'answerui.controls.Radio': ('controls.html#radio', 'answerui/controls.py'),
18
+ 'answerui.controls.Range': ('controls.html#range', 'answerui/controls.py'),
19
+ 'answerui.controls.Switch': ('controls.html#switch', 'answerui/controls.py'),
20
+ 'answerui.controls.Toolbar': ('controls.html#toolbar', 'answerui/controls.py'),
21
+ 'answerui.controls._button_example': ('controls.html#_button_example', 'answerui/controls.py'),
22
+ 'answerui.controls._checkbox_example': ('controls.html#_checkbox_example', 'answerui/controls.py'),
23
+ 'answerui.controls._copy_example': ('controls.html#_copy_example', 'answerui/controls.py'),
24
+ 'answerui.controls._field_example': ('controls.html#_field_example', 'answerui/controls.py'),
25
+ 'answerui.controls._fieldset_example': ('controls.html#_fieldset_example', 'answerui/controls.py'),
26
+ 'answerui.controls._group_example': ('controls.html#_group_example', 'answerui/controls.py'),
27
+ 'answerui.controls._input_example': ('controls.html#_input_example', 'answerui/controls.py'),
28
+ 'answerui.controls._radio_example': ('controls.html#_radio_example', 'answerui/controls.py'),
29
+ 'answerui.controls._range_example': ('controls.html#_range_example', 'answerui/controls.py'),
30
+ 'answerui.controls._range_parts': ('controls.html#_range_parts', 'answerui/controls.py'),
31
+ 'answerui.controls._select_example': ('controls.html#_select_example', 'answerui/controls.py'),
32
+ 'answerui.controls._switch_example': ('controls.html#_switch_example', 'answerui/controls.py'),
33
+ 'answerui.controls._textarea_example': ('controls.html#_textarea_example', 'answerui/controls.py'),
34
+ 'answerui.controls._toolbar_example': ('controls.html#_toolbar_example', 'answerui/controls.py')},
35
+ 'answerui.data': { 'answerui.data.DataTable': ('data.html#datatable', 'answerui/data.py'),
36
+ 'answerui.data._datatable_example': ('data.html#_datatable_example', 'answerui/data.py')},
37
+ 'answerui.demo': { 'answerui.demo.Hyperelement.demo': ('demo.html#hyperelement.demo', 'answerui/demo.py'),
38
+ 'answerui.demo.Preview': ('demo.html#preview', 'answerui/demo.py'),
39
+ 'answerui.demo.Preview.__init__': ('demo.html#preview.__init__', 'answerui/demo.py'),
40
+ 'answerui.demo.Preview.__repr__': ('demo.html#preview.__repr__', 'answerui/demo.py'),
41
+ 'answerui.demo.Preview._repr_mimebundle_': ('demo.html#preview._repr_mimebundle_', 'answerui/demo.py'),
42
+ 'answerui.demo._as_served': ('demo.html#_as_served', 'answerui/demo.py'),
43
+ 'answerui.demo.demo': ('demo.html#demo', 'answerui/demo.py'),
44
+ 'answerui.demo.demo_html': ('demo.html#demo_html', 'answerui/demo.py'),
45
+ 'answerui.demo.example': ('demo.html#example', 'answerui/demo.py')},
46
+ 'answerui.hdrs': { 'answerui.hdrs.Registry.assets': ('hdrs.html#registry.assets', 'answerui/hdrs.py'),
47
+ 'answerui.hdrs.Registry.ftrs': ('hdrs.html#registry.ftrs', 'answerui/hdrs.py'),
48
+ 'answerui.hdrs.Registry.hdrs': ('hdrs.html#registry.hdrs', 'answerui/hdrs.py'),
49
+ 'answerui.hdrs.Registry.serve': ('hdrs.html#registry.serve', 'answerui/hdrs.py'),
50
+ 'answerui.hdrs._Lazy': ('hdrs.html#_lazy', 'answerui/hdrs.py'),
51
+ 'answerui.hdrs._Lazy.__ft__': ('hdrs.html#_lazy.__ft__', 'answerui/hdrs.py'),
52
+ 'answerui.hdrs._Lazy.__init__': ('hdrs.html#_lazy.__init__', 'answerui/hdrs.py'),
53
+ 'answerui.hdrs._hash': ('hdrs.html#_hash', 'answerui/hdrs.py')},
54
+ 'answerui.layout': { 'answerui.layout.Cluster': ('layout.html#cluster', 'answerui/layout.py'),
55
+ 'answerui.layout.Flow': ('layout.html#flow', 'answerui/layout.py'),
56
+ 'answerui.layout.Grid': ('layout.html#grid', 'answerui/layout.py'),
57
+ 'answerui.layout.Stack': ('layout.html#stack', 'answerui/layout.py'),
58
+ 'answerui.layout._cluster_example': ('layout.html#_cluster_example', 'answerui/layout.py'),
59
+ 'answerui.layout._flow_example': ('layout.html#_flow_example', 'answerui/layout.py'),
60
+ 'answerui.layout._grid_example': ('layout.html#_grid_example', 'answerui/layout.py'),
61
+ 'answerui.layout._layout': ('layout.html#_layout', 'answerui/layout.py'),
62
+ 'answerui.layout._stack_example': ('layout.html#_stack_example', 'answerui/layout.py')},
63
+ 'answerui.navigation': { 'answerui.navigation.NavBar': ('navigation.html#navbar', 'answerui/navigation.py'),
64
+ 'answerui.navigation._links': ('navigation.html#_links', 'answerui/navigation.py'),
65
+ 'answerui.navigation._navbar_example': ('navigation.html#_navbar_example', 'answerui/navigation.py')},
66
+ 'answerui.overlays': { 'answerui.overlays.Dropdown': ('overlays.html#dropdown', 'answerui/overlays.py'),
67
+ 'answerui.overlays.Popover': ('overlays.html#popover', 'answerui/overlays.py'),
68
+ 'answerui.overlays.Tooltip': ('overlays.html#tooltip', 'answerui/overlays.py'),
69
+ 'answerui.overlays._dialog_example': ('overlays.html#_dialog_example', 'answerui/overlays.py'),
70
+ 'answerui.overlays._dropdown_example': ('overlays.html#_dropdown_example', 'answerui/overlays.py'),
71
+ 'answerui.overlays._popover_example': ('overlays.html#_popover_example', 'answerui/overlays.py'),
72
+ 'answerui.overlays._tooltip_example': ('overlays.html#_tooltip_example', 'answerui/overlays.py')},
73
+ 'answerui.registry': { 'answerui.registry.Hyperelement': ('registry.html#hyperelement', 'answerui/registry.py'),
74
+ 'answerui.registry.Hyperelement.__call__': ( 'registry.html#hyperelement.__call__',
75
+ 'answerui/registry.py'),
76
+ 'answerui.registry.Hyperelement.__init__': ( 'registry.html#hyperelement.__init__',
77
+ 'answerui/registry.py'),
78
+ 'answerui.registry.Hyperelement.__repr__': ( 'registry.html#hyperelement.__repr__',
79
+ 'answerui/registry.py'),
80
+ 'answerui.registry.Hyperelement.__signature__': ( 'registry.html#hyperelement.__signature__',
81
+ 'answerui/registry.py'),
82
+ 'answerui.registry.Hyperelement._repr_markdown_': ( 'registry.html#hyperelement._repr_markdown_',
83
+ 'answerui/registry.py'),
84
+ 'answerui.registry.Hyperelement.behaviors': ( 'registry.html#hyperelement.behaviors',
85
+ 'answerui/registry.py'),
86
+ 'answerui.registry.Hyperelement.rule': ('registry.html#hyperelement.rule', 'answerui/registry.py'),
87
+ 'answerui.registry.Hyperelement.variant': ('registry.html#hyperelement.variant', 'answerui/registry.py'),
88
+ 'answerui.registry.Hyperelement.variants': ( 'registry.html#hyperelement.variants',
89
+ 'answerui/registry.py'),
90
+ 'answerui.registry.Registry': ('registry.html#registry', 'answerui/registry.py'),
91
+ 'answerui.registry.Registry.__init__': ('registry.html#registry.__init__', 'answerui/registry.py'),
92
+ 'answerui.registry.Registry.__repr__': ('registry.html#registry.__repr__', 'answerui/registry.py'),
93
+ 'answerui.registry.Registry._repr_markdown_': ( 'registry.html#registry._repr_markdown_',
94
+ 'answerui/registry.py'),
95
+ 'answerui.registry.Registry.build_css': ('registry.html#registry.build_css', 'answerui/registry.py'),
96
+ 'answerui.registry.Registry.file': ('registry.html#registry.file', 'answerui/registry.py'),
97
+ 'answerui.registry.Registry.hypelt': ('registry.html#registry.hypelt', 'answerui/registry.py'),
98
+ 'answerui.registry.Registry.remove': ('registry.html#registry.remove', 'answerui/registry.py'),
99
+ 'answerui.registry.Registry.rule': ('registry.html#registry.rule', 'answerui/registry.py'),
100
+ 'answerui.registry.Rule': ('registry.html#rule', 'answerui/registry.py'),
101
+ 'answerui.registry.Rule.__init__': ('registry.html#rule.__init__', 'answerui/registry.py'),
102
+ 'answerui.registry.Rule.__repr__': ('registry.html#rule.__repr__', 'answerui/registry.py'),
103
+ 'answerui.registry.Rule.compiled_css': ('registry.html#rule.compiled_css', 'answerui/registry.py'),
104
+ 'answerui.registry.Rule.name': ('registry.html#rule.name', 'answerui/registry.py'),
105
+ 'answerui.registry.Rule.owner': ('registry.html#rule.owner', 'answerui/registry.py'),
106
+ 'answerui.registry.RuleView': ('registry.html#ruleview', 'answerui/registry.py'),
107
+ 'answerui.registry.RuleView.__getitem__': ('registry.html#ruleview.__getitem__', 'answerui/registry.py'),
108
+ 'answerui.registry.RuleView.__init__': ('registry.html#ruleview.__init__', 'answerui/registry.py'),
109
+ 'answerui.registry.RuleView.__iter__': ('registry.html#ruleview.__iter__', 'answerui/registry.py'),
110
+ 'answerui.registry.RuleView.__len__': ('registry.html#ruleview.__len__', 'answerui/registry.py'),
111
+ 'answerui.registry.RuleView.__repr__': ('registry.html#ruleview.__repr__', 'answerui/registry.py'),
112
+ 'answerui.registry.RuleView._matches': ('registry.html#ruleview._matches', 'answerui/registry.py'),
113
+ 'answerui.registry._behaviors': ('registry.html#_behaviors', 'answerui/registry.py'),
114
+ 'answerui.registry._generic': ('registry.html#_generic', 'answerui/registry.py'),
115
+ 'answerui.registry._nest': ('registry.html#_nest', 'answerui/registry.py')},
116
+ 'answerui.status': { 'answerui.status.Alert': ('status.html#alert', 'answerui/status.py'),
117
+ 'answerui.status.Skeleton': ('status.html#skeleton', 'answerui/status.py'),
118
+ 'answerui.status.Spinner': ('status.html#spinner', 'answerui/status.py'),
119
+ 'answerui.status.Toast': ('status.html#toast', 'answerui/status.py'),
120
+ 'answerui.status.Toasts': ('status.html#toasts', 'answerui/status.py'),
121
+ 'answerui.status._alert_example': ('status.html#_alert_example', 'answerui/status.py'),
122
+ 'answerui.status._notice': ('status.html#_notice', 'answerui/status.py'),
123
+ 'answerui.status._progress_example': ('status.html#_progress_example', 'answerui/status.py'),
124
+ 'answerui.status._skeleton_example': ('status.html#_skeleton_example', 'answerui/status.py'),
125
+ 'answerui.status._spinner_example': ('status.html#_spinner_example', 'answerui/status.py'),
126
+ 'answerui.status._toast_example': ('status.html#_toast_example', 'answerui/status.py'),
127
+ 'answerui.status.add_toast': ('status.html#add_toast', 'answerui/status.py'),
128
+ 'answerui.status.pop_toasts': ('status.html#pop_toasts', 'answerui/status.py'),
129
+ 'answerui.status.setup_toasts': ('status.html#setup_toasts', 'answerui/status.py'),
130
+ 'answerui.status.toast_after': ('status.html#toast_after', 'answerui/status.py'),
131
+ 'answerui.status.toasts_oob': ('status.html#toasts_oob', 'answerui/status.py')},
132
+ 'answerui.surfaces': { 'answerui.surfaces.Avatar': ('surfaces.html#avatar', 'answerui/surfaces.py'),
133
+ 'answerui.surfaces.Badge': ('surfaces.html#badge', 'answerui/surfaces.py'),
134
+ 'answerui.surfaces.Card': ('surfaces.html#card', 'answerui/surfaces.py'),
135
+ 'answerui.surfaces._avatar_example': ('surfaces.html#_avatar_example', 'answerui/surfaces.py'),
136
+ 'answerui.surfaces._badge_example': ('surfaces.html#_badge_example', 'answerui/surfaces.py'),
137
+ 'answerui.surfaces._card_example': ('surfaces.html#_card_example', 'answerui/surfaces.py')},
138
+ 'answerui.tokens': { 'answerui.tokens.Registry.context': ('tokens.html#registry.context', 'answerui/tokens.py'),
139
+ 'answerui.tokens.Registry.contexts': ('tokens.html#registry.contexts', 'answerui/tokens.py'),
140
+ 'answerui.tokens._context_css': ('tokens.html#_context_css', 'answerui/tokens.py'),
141
+ 'answerui.tokens._palette_css': ('tokens.html#_palette_css', 'answerui/tokens.py'),
142
+ 'answerui.tokens.font_face': ('tokens.html#font_face', 'answerui/tokens.py'),
143
+ 'answerui.tokens.relief': ('tokens.html#relief', 'answerui/tokens.py')}}}
@@ -0,0 +1,14 @@
1
+ """Every answerui module, for `from answerui.all import *`"""
2
+ from .registry import *
3
+ from .behaviors import *
4
+ from .demo import *
5
+ from .hdrs import *
6
+ from .tokens import *
7
+ from .base import *
8
+ from .layout import *
9
+ from .controls import *
10
+ from .surfaces import *
11
+ from .status import *
12
+ from .overlays import *
13
+ from .navigation import *
14
+ from .data import *