answerstyle 0.1.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.
- answerstyle-0.1.2/DEV.md +21 -0
- answerstyle-0.1.2/LICENSE +201 -0
- answerstyle-0.1.2/MANIFEST.in +2 -0
- answerstyle-0.1.2/PKG-INFO +39 -0
- answerstyle-0.1.2/README.md +21 -0
- answerstyle-0.1.2/answerstyle/__init__.py +8 -0
- answerstyle-0.1.2/answerstyle/_build.py +35 -0
- answerstyle-0.1.2/answerstyle/_modidx.py +8 -0
- answerstyle-0.1.2/answerstyle/assets/copy.js +7 -0
- answerstyle-0.1.2/answerstyle/assets/fit.js +92 -0
- answerstyle-0.1.2/answerstyle/assets/floating.js +78 -0
- answerstyle-0.1.2/answerstyle/assets/fonts/IBM-Plex.LICENSE +93 -0
- answerstyle-0.1.2/answerstyle/assets/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- answerstyle-0.1.2/answerstyle/assets/fonts/ibm-plex-sans-latin-400-italic.woff2 +0 -0
- answerstyle-0.1.2/answerstyle/assets/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- answerstyle-0.1.2/answerstyle/assets/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- answerstyle-0.1.2/answerstyle/assets/fonts/ibm-plex-serif-latin-600-normal.woff2 +0 -0
- answerstyle-0.1.2/answerstyle/assets/fonts.css +7 -0
- answerstyle-0.1.2/answerstyle/assets/interactions.js +92 -0
- answerstyle-0.1.2/answerstyle/assets/styles.css +760 -0
- answerstyle-0.1.2/answerstyle/preview.py +35 -0
- answerstyle-0.1.2/answerstyle.egg-info/PKG-INFO +39 -0
- answerstyle-0.1.2/answerstyle.egg-info/SOURCES.txt +36 -0
- answerstyle-0.1.2/answerstyle.egg-info/dependency_links.txt +1 -0
- answerstyle-0.1.2/answerstyle.egg-info/requires.txt +8 -0
- answerstyle-0.1.2/answerstyle.egg-info/top_level.txt +1 -0
- answerstyle-0.1.2/nbs/00_palette.ipynb +4807 -0
- answerstyle-0.1.2/nbs/01_typography.ipynb +465 -0
- answerstyle-0.1.2/nbs/02_layout.ipynb +224 -0
- answerstyle-0.1.2/nbs/03_controls.ipynb +453 -0
- answerstyle-0.1.2/nbs/04_interactions.ipynb +402 -0
- answerstyle-0.1.2/nbs/05_python_components.ipynb +968 -0
- answerstyle-0.1.2/nbs/_quarto.yml +12 -0
- answerstyle-0.1.2/nbs/index.ipynb +43 -0
- answerstyle-0.1.2/nbs/palette.css +38 -0
- answerstyle-0.1.2/package.json +22 -0
- answerstyle-0.1.2/pyproject.toml +38 -0
- answerstyle-0.1.2/setup.cfg +4 -0
answerstyle-0.1.2/DEV.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# AnswerStyle source
|
|
2
|
+
|
|
3
|
+
The notebooks in `nbs/` own the styles. A `#| asset styles.css` cell contains a CSS string. `nbdev-export` joins these sections in notebook and cell order. The palette notebook can regenerate `nbs/palette.css` from the color calculations. Export reads that file without rerunning the calculations.
|
|
4
|
+
|
|
5
|
+
Run `npm run build` to export the styles using nbdev from your Python environment. `answerstyle/assets/` contains the generated styles, fonts and dependency-free browser modules. `npm pack` and `uv build` package those assets without running the notebooks. Keep the generated styles up to date with their source.
|
|
6
|
+
|
|
7
|
+
Run the examples in a notebook. `from answerstyle.preview import preview` renders a markup string in an isolated frame using the built stylesheet. Use `width='24rem'` for a narrow viewport or `height='10rem'` for top-layer content. The saved notebook keeps the example markup. Run `uv run --extra dev nbdev-preview` for the docs site.
|
|
8
|
+
|
|
9
|
+
Both distributions ship the same browser modules. `floating.js` uses CSS anchor positioning with a small geometry fallback. `interactions.js` supplies tabs, toolbar focus and hover-opening settings. Neither needs a bundler or a JavaScript dependency.
|
|
10
|
+
|
|
11
|
+
Both distributions use the same version. Consumers declare an ordinary `@answerdotai/answerstyle` version dependency. In a fastws workspace, include `AnswerDotAI/answerstyle[dev]` in the repo list: `ws-sync` installs the Python development dependencies, links the local npm package and exports its styles before building dependent apps. No per-consumer link or checkout path is needed. Outside the workspace, use the published package or a built package artifact.
|
|
12
|
+
|
|
13
|
+
## Release
|
|
14
|
+
|
|
15
|
+
For the first npm release, commit and push the reviewed changes, build with `npm run build`, then publish once using your normal authenticated `npm publish`. [npm requires the package to exist](https://docs.npmjs.com/cli/v12/commands/npm-trust/) before a trusted publisher can be configured.
|
|
16
|
+
|
|
17
|
+
Configure npm's trusted publisher for `@answerdotai/answerstyle` with GitHub owner `AnswerDotAI`, repository `answerstyle` and workflow `ci.yml`, selecting [**Allow npm publish**](https://docs.npmjs.com/trusted-publishers/) rather than the default staged-publishing action. Register PyPI's pending trusted publisher for `answerstyle` with the same repository and workflow before its first release. The workflow uses no GitHub environment or registry tokens.
|
|
18
|
+
|
|
19
|
+
After that initial npm publication, run `ship-bump` to advance both `answerstyle/__init__.py` and `package.json` before the first tag-driven release, since the bootstrap version already exists on npm. Commit and push the reviewed changes, then run `ship-release`.
|
|
20
|
+
|
|
21
|
+
For subsequent releases, commit and push the reviewed changes, then run `ship-release`. It tags the current shared version; the workflow exports the assets and publishes both packages through trusted publishing. Fastship bumps both version files for the next release.
|
|
@@ -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 [yyyy] [name of copyright owner]
|
|
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,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: answerstyle
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Shared styles and browser behavior for semantic HTML
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Repository, https://github.com/AnswerDotAI/answerstyle
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
Requires-Dist: nbdev>=3.3.28; extra == "dev"
|
|
12
|
+
Requires-Dist: numpy; extra == "dev"
|
|
13
|
+
Requires-Dist: scipy; extra == "dev"
|
|
14
|
+
Requires-Dist: matplotlib; extra == "dev"
|
|
15
|
+
Requires-Dist: pandas; extra == "dev"
|
|
16
|
+
Requires-Dist: python-fasthtml; extra == "dev"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# AnswerStyle
|
|
20
|
+
|
|
21
|
+
AnswerStyle provides styles and browser behavior for semantic HTML. Add a named attribute to opt into a component's appearance. Use native elements and state for interaction and accessibility.
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<article card stack>
|
|
25
|
+
<h2>Workspace</h2>
|
|
26
|
+
<p>Invite someone to work with you.</p>
|
|
27
|
+
<div cluster>
|
|
28
|
+
<button btn type="button">Invite</button>
|
|
29
|
+
<a btn btn-variant="secondary" href="/members">Members</a>
|
|
30
|
+
</div>
|
|
31
|
+
</article>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The npm and Python packages are not published yet; see [DEV.md](DEV.md) for local development setup. JavaScript apps import `@answerdotai/answerstyle/styles.css` once. Svelte components emit the same attributes as the HTML above.
|
|
35
|
+
|
|
36
|
+
In Python, `from answerstyle import assets` gives the package's browser assets. Serve that directory and link `styles.css`. The stylesheet does not need a script. The browser modules `fit.js`, `floating.js`, `interactions.js` and `copy.js` are available separately. Native dropdowns use normal links and controls; tooltips use CSS. Shared controllers add fitting, popover placement, tabs and toolbar focus where needed.
|
|
37
|
+
|
|
38
|
+
The [notebooks](nbs/) explain the palette, typography, layout and components and include working previews. See [DEV.md](DEV.md) for the source build.
|
|
39
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# AnswerStyle
|
|
2
|
+
|
|
3
|
+
AnswerStyle provides styles and browser behavior for semantic HTML. Add a named attribute to opt into a component's appearance. Use native elements and state for interaction and accessibility.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<article card stack>
|
|
7
|
+
<h2>Workspace</h2>
|
|
8
|
+
<p>Invite someone to work with you.</p>
|
|
9
|
+
<div cluster>
|
|
10
|
+
<button btn type="button">Invite</button>
|
|
11
|
+
<a btn btn-variant="secondary" href="/members">Members</a>
|
|
12
|
+
</div>
|
|
13
|
+
</article>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The npm and Python packages are not published yet; see [DEV.md](DEV.md) for local development setup. JavaScript apps import `@answerdotai/answerstyle/styles.css` once. Svelte components emit the same attributes as the HTML above.
|
|
17
|
+
|
|
18
|
+
In Python, `from answerstyle import assets` gives the package's browser assets. Serve that directory and link `styles.css`. The stylesheet does not need a script. The browser modules `fit.js`, `floating.js`, `interactions.js` and `copy.js` are available separately. Native dropdowns use normal links and controls; tooltips use CSS. Shared controllers add fitting, popover placement, tabs and toolbar focus where needed.
|
|
19
|
+
|
|
20
|
+
The [notebooks](nbs/) explain the palette, typography, layout and components and include working previews. See [DEV.md](DEV.md) for the source build.
|
|
21
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Assemble browser stylesheets from the notebooks without running their lessons."""
|
|
2
|
+
|
|
3
|
+
from ast import literal_eval, parse
|
|
4
|
+
from collections import defaultdict
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class _Assets:
|
|
8
|
+
def __init__(self, nb): self.parts = defaultdict(list)
|
|
9
|
+
|
|
10
|
+
def _asset_(self, cell, name):
|
|
11
|
+
stmt, = parse(cell.source).body
|
|
12
|
+
self.parts[name].append(literal_eval(stmt.value).strip())
|
|
13
|
+
|
|
14
|
+
def _asset_include_(self, cell, name, filename):
|
|
15
|
+
from nbdev.config import get_config
|
|
16
|
+
self.parts[name].append((get_config().nbs_path / filename).read_text(encoding='utf-8').strip())
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def build_assets_(cell):
|
|
20
|
+
"Export the notebook stylesheet sections in notebook and cell order."
|
|
21
|
+
from nbdev.config import get_config
|
|
22
|
+
from nbdev.process import NBProcessor
|
|
23
|
+
|
|
24
|
+
cfg = get_config()
|
|
25
|
+
parts = defaultdict(list)
|
|
26
|
+
for nb in sorted(cfg.nbs_path.glob('[0-9]*.ipynb')):
|
|
27
|
+
proc = NBProcessor(nb, _Assets)
|
|
28
|
+
proc.process()
|
|
29
|
+
for name, sections in proc.procs[0].parts.items(): parts[name].extend(sections)
|
|
30
|
+
dest = cfg.lib_path / 'assets'
|
|
31
|
+
dest.mkdir(exist_ok=True)
|
|
32
|
+
for name, sections in parts.items():
|
|
33
|
+
out = dest / name
|
|
34
|
+
css = '/* Generated by nbdev-export. Edit the source notebooks. */\n\n' + '\n\n'.join(sections) + '\n'
|
|
35
|
+
if not out.exists() or out.read_text(encoding='utf-8') != css: out.write_text(css, encoding='utf-8')
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export async function copyText(textOrPromise) {
|
|
2
|
+
if (typeof textOrPromise === 'string') return navigator.clipboard.writeText(textOrPromise);
|
|
3
|
+
const type = 'text/plain';
|
|
4
|
+
// Safari checks for user activation when write() is called, not when the data is ready.
|
|
5
|
+
const data = Promise.resolve(textOrPromise).then(text => new Blob([text], {type}));
|
|
6
|
+
return navigator.clipboard.write([new ClipboardItem({[type]: data})]);
|
|
7
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
function inlineSize(style, box) {
|
|
2
|
+
const edges = ['Start', 'End'].reduce((n, end) => n + parseFloat(style[`paddingInline${end}`]) +
|
|
3
|
+
parseFloat(style[`borderInline${end}Width`]), 0);
|
|
4
|
+
const size = parseFloat(style.writingMode.startsWith('horizontal') ? style.width : style.height);
|
|
5
|
+
if (box === 'content') return style.boxSizing === 'border-box' ? size - edges : size;
|
|
6
|
+
return style.boxSizing === 'border-box' ? size : size + edges;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function watchInlineFit(host, row, onCompact) {
|
|
10
|
+
const doc = host.ownerDocument, win = doc.defaultView;
|
|
11
|
+
const events = new win.AbortController(), {signal} = events;
|
|
12
|
+
let frame, compact;
|
|
13
|
+
function measure() {
|
|
14
|
+
frame = undefined;
|
|
15
|
+
if (!host.getClientRects().length) return;
|
|
16
|
+
const available = inlineSize(win.getComputedStyle(host), 'content');
|
|
17
|
+
host.setAttribute('data-fitting', '');
|
|
18
|
+
const needed = inlineSize(win.getComputedStyle(row), 'border');
|
|
19
|
+
host.removeAttribute('data-fitting');
|
|
20
|
+
if (!Number.isFinite(needed) || !Number.isFinite(available)) return;
|
|
21
|
+
const next = needed > available;
|
|
22
|
+
if (compact !== next) onCompact(compact = next);
|
|
23
|
+
}
|
|
24
|
+
function schedule() { frame ??= win.requestAnimationFrame(measure); }
|
|
25
|
+
const resize = new win.ResizeObserver(schedule);
|
|
26
|
+
resize.observe(host);
|
|
27
|
+
if (row !== host) resize.observe(row);
|
|
28
|
+
const children = new Set();
|
|
29
|
+
function observeChildren() {
|
|
30
|
+
const next = new Set(row.children);
|
|
31
|
+
for (const child of children) if (!next.has(child)) { resize.unobserve(child); children.delete(child); }
|
|
32
|
+
for (const child of next) if (!children.has(child)) { resize.observe(child); children.add(child); }
|
|
33
|
+
}
|
|
34
|
+
const mutations = new win.MutationObserver(records => {
|
|
35
|
+
if (records.some(r => r.type === 'childList' && r.target === row)) observeChildren();
|
|
36
|
+
if (records.some(r => r.target !== host || r.attributeName !== 'data-fitting')) schedule();
|
|
37
|
+
});
|
|
38
|
+
mutations.observe(row, {subtree: true, attributes: true, childList: true, characterData: true});
|
|
39
|
+
row.addEventListener('load', schedule, {capture: true, signal});
|
|
40
|
+
doc.fonts?.addEventListener('loadingdone', schedule, {signal});
|
|
41
|
+
observeChildren();
|
|
42
|
+
measure();
|
|
43
|
+
return () => {
|
|
44
|
+
events.abort();
|
|
45
|
+
win.cancelAnimationFrame(frame);
|
|
46
|
+
resize.disconnect();
|
|
47
|
+
mutations.disconnect();
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function mountNavbar(host, {open = false, onOpenChange} = {}) {
|
|
52
|
+
const row = host.querySelector(':scope > [navbar-row]'), nav = row?.querySelector(':scope > nav');
|
|
53
|
+
const toggle = row?.querySelector(':scope > [navbar-toggle]');
|
|
54
|
+
if (!nav || !toggle) return {setOpen() {}, dispose() {}};
|
|
55
|
+
const doc = host.ownerDocument, events = new doc.defaultView.AbortController();
|
|
56
|
+
let compact, expanded = Boolean(open);
|
|
57
|
+
function setOpen(next) {
|
|
58
|
+
const changed = expanded !== Boolean(next);
|
|
59
|
+
expanded = Boolean(next);
|
|
60
|
+
host.toggleAttribute('data-open', compact && expanded);
|
|
61
|
+
toggle.setAttribute('aria-expanded', String(Boolean(compact && expanded)));
|
|
62
|
+
if (changed) onOpenChange?.(expanded);
|
|
63
|
+
}
|
|
64
|
+
const stop = watchInlineFit(host, row, next => {
|
|
65
|
+
const wasCompact = compact, focus = doc.activeElement;
|
|
66
|
+
compact = next;
|
|
67
|
+
if (compact && nav.contains(focus)) setOpen(true);
|
|
68
|
+
else if (wasCompact && !compact) setOpen(false);
|
|
69
|
+
else setOpen(expanded);
|
|
70
|
+
host.toggleAttribute('data-compact', compact);
|
|
71
|
+
if (wasCompact && !compact && toggle.contains(focus))
|
|
72
|
+
(nav.querySelector('a[href]') ?? row.querySelector('[navbar-brand]'))?.focus({preventScroll: true});
|
|
73
|
+
});
|
|
74
|
+
const {signal} = events;
|
|
75
|
+
toggle.addEventListener('click', () => setOpen(!expanded), {signal});
|
|
76
|
+
doc.addEventListener('click', event => {
|
|
77
|
+
if (compact && expanded && (!host.contains(event.target) || nav.contains(event.target.closest?.('a[href]') ?? null))) setOpen(false);
|
|
78
|
+
}, {signal});
|
|
79
|
+
host.addEventListener('keydown', event => {
|
|
80
|
+
if (!compact || !expanded || event.key !== 'Escape' || event.defaultPrevented) return;
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
setOpen(false);
|
|
83
|
+
toggle.focus({preventScroll: true});
|
|
84
|
+
}, {signal});
|
|
85
|
+
return {setOpen, dispose() {
|
|
86
|
+
events.abort();
|
|
87
|
+
stop();
|
|
88
|
+
host.removeAttribute('data-compact');
|
|
89
|
+
host.removeAttribute('data-open');
|
|
90
|
+
toggle.setAttribute('aria-expanded', 'false');
|
|
91
|
+
}};
|
|
92
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
let anchorId = 0;
|
|
2
|
+
|
|
3
|
+
export function positionFloating(trigger, panel, {side = 'bottom', align = 'start', sideOffset = 6, onReferenceHidden} = {}) {
|
|
4
|
+
const doc = trigger.ownerDocument, win = doc.defaultView, events = new win.AbortController();
|
|
5
|
+
const anchored = win.CSS.supports('position-area', 'center'), name = `--answerstyle-anchor-${++anchorId}`;
|
|
6
|
+
const previousAnchor = trigger.style.anchorName;
|
|
7
|
+
const horizontal = side === 'left' || side === 'right';
|
|
8
|
+
const start = horizontal ? 'top' : (win.getComputedStyle(trigger).direction === 'rtl' ? 'right' : 'left');
|
|
9
|
+
const end = horizontal ? 'bottom' : (start === 'left' ? 'right' : 'left');
|
|
10
|
+
const extent = align === 'center' ? '' : ` span-${align === 'start' ? end : start}`;
|
|
11
|
+
function place() {
|
|
12
|
+
const r = trigger.getBoundingClientRect(), vw = doc.documentElement.clientWidth, vh = doc.documentElement.clientHeight, edge = 8;
|
|
13
|
+
if (!trigger.getClientRects().length || r.bottom < 0 || r.top > vh || r.right < 0 || r.left > vw) return onReferenceHidden?.();
|
|
14
|
+
if (anchored) return;
|
|
15
|
+
const below = vh - r.bottom - sideOffset - edge, above = r.top - sideOffset - edge;
|
|
16
|
+
const right = vw - r.right - sideOffset - edge, left = r.left - sideOffset - edge;
|
|
17
|
+
const extent = horizontal ? panel.scrollWidth : panel.scrollHeight;
|
|
18
|
+
let placed = side;
|
|
19
|
+
if (side === 'bottom' && extent > below && above > below) placed = 'top';
|
|
20
|
+
if (side === 'top' && extent > above && below > above) placed = 'bottom';
|
|
21
|
+
if (side === 'right' && extent > right && left > right) placed = 'left';
|
|
22
|
+
if (side === 'left' && extent > left && right > left) placed = 'right';
|
|
23
|
+
panel.style.setProperty('--floating-available-height', `${Math.max(0, placed === 'top' ? above : placed === 'bottom' ? below : vh - edge * 2)}px`);
|
|
24
|
+
const cross = align === 'center' ? (horizontal ? (r.top + r.bottom - panel.offsetHeight) / 2 : (r.left + r.right - panel.offsetWidth) / 2) :
|
|
25
|
+
(align === 'start' ? start : end) === (horizontal ? 'top' : 'left') ? (horizontal ? r.top : r.left) :
|
|
26
|
+
(horizontal ? r.bottom - panel.offsetHeight : r.right - panel.offsetWidth);
|
|
27
|
+
const x = horizontal ? (placed === 'left' ? r.left - panel.offsetWidth - sideOffset : r.right + sideOffset) : cross;
|
|
28
|
+
const y = horizontal ? cross : (placed === 'top' ? r.top - panel.offsetHeight - sideOffset : r.bottom + sideOffset);
|
|
29
|
+
panel.style.left = `${Math.max(edge, Math.min(x, vw - panel.offsetWidth - edge))}px`;
|
|
30
|
+
panel.style.top = `${Math.max(edge, Math.min(y, vh - panel.offsetHeight - edge))}px`;
|
|
31
|
+
}
|
|
32
|
+
if (anchored) {
|
|
33
|
+
trigger.style.anchorName = previousAnchor ? `${previousAnchor}, ${name}` : name;
|
|
34
|
+
panel.style.positionAnchor = name;
|
|
35
|
+
panel.style.positionArea = `${side}${extent}`;
|
|
36
|
+
panel.style.setProperty(`margin-${{top: 'bottom', bottom: 'top', left: 'right', right: 'left'}[side]}`, `${sideOffset}px`);
|
|
37
|
+
} else {
|
|
38
|
+
win.addEventListener('resize', place, {signal: events.signal});
|
|
39
|
+
doc.addEventListener('scroll', place, {capture: true, signal: events.signal});
|
|
40
|
+
}
|
|
41
|
+
const resize = new win.ResizeObserver(place);
|
|
42
|
+
resize.observe(trigger);
|
|
43
|
+
if (!anchored) resize.observe(panel);
|
|
44
|
+
place();
|
|
45
|
+
return () => {
|
|
46
|
+
events.abort();
|
|
47
|
+
resize.disconnect();
|
|
48
|
+
if (anchored) trigger.style.anchorName = previousAnchor;
|
|
49
|
+
for (const prop of ['position-anchor', 'position-area', 'left', 'top', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', '--floating-available-height'])
|
|
50
|
+
panel.style.removeProperty(prop);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function mountPopover(trigger, panel, {onOpenChange, ...position} = {}) {
|
|
55
|
+
const win = panel.ownerDocument.defaultView, events = new win.AbortController();
|
|
56
|
+
let stop;
|
|
57
|
+
function update(open) {
|
|
58
|
+
stop?.();
|
|
59
|
+
trigger.setAttribute('aria-expanded', String(open));
|
|
60
|
+
stop = open ? positionFloating(trigger, panel, {...position, onReferenceHidden: () => panel.hidePopover()}) : undefined;
|
|
61
|
+
}
|
|
62
|
+
panel.addEventListener('beforetoggle', event => {
|
|
63
|
+
if (event.target !== panel) return;
|
|
64
|
+
update(event.newState === 'open');
|
|
65
|
+
}, {signal: events.signal});
|
|
66
|
+
panel.addEventListener('click', event => {
|
|
67
|
+
if (event.target.closest('a[href]') && panel.hasAttribute('dropdown')) panel.hidePopover();
|
|
68
|
+
}, {signal: events.signal});
|
|
69
|
+
panel.addEventListener('toggle', event => {
|
|
70
|
+
if (event.target !== panel) return;
|
|
71
|
+
onOpenChange?.(event.newState === 'open');
|
|
72
|
+
if (event.newState === 'open' && panel.hasAttribute('dropdown'))
|
|
73
|
+
[...panel.querySelectorAll('button:not(:disabled), a[href]:not([aria-disabled=true]), select:not(:disabled), input:not(:disabled), summary')]
|
|
74
|
+
.find(node => !node.closest('[inert]') && node.getClientRects().length)?.focus();
|
|
75
|
+
}, {signal: events.signal});
|
|
76
|
+
update(panel.matches(':popover-open'));
|
|
77
|
+
return () => { events.abort(); stop?.(); trigger.setAttribute('aria-expanded', 'false'); };
|
|
78
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2019 IBM Corp. All rights reserved. IBMPlexSans-Italic[wdth,wght].ttf: Copyright 2019 IBM Corp. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* Generated by nbdev-export. Edit the source notebooks. */
|
|
2
|
+
|
|
3
|
+
@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('./fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2'); }
|
|
4
|
+
@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; font-style: italic; font-display: swap; src: url('./fonts/ibm-plex-sans-latin-400-italic.woff2') format('woff2'); }
|
|
5
|
+
@font-face { font-family: 'IBM Plex Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('./fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2'); }
|
|
6
|
+
@font-face { font-family: 'IBM Plex Serif'; font-weight: 600; font-style: normal; font-display: swap; src: url('./fonts/ibm-plex-serif-latin-600-normal.woff2') format('woff2'); }
|
|
7
|
+
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url('./fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); }
|