deckkit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deckkit-0.1.0/LICENSE +21 -0
- deckkit-0.1.0/MANIFEST.in +8 -0
- deckkit-0.1.0/PKG-INFO +123 -0
- deckkit-0.1.0/README.md +93 -0
- deckkit-0.1.0/docs/assets/figure-caption.png +0 -0
- deckkit-0.1.0/docs/assets/figure-reference.png +0 -0
- deckkit-0.1.0/docs/assets/metrics-citation.png +0 -0
- deckkit-0.1.0/docs/assets/metrics-opening.png +0 -0
- deckkit-0.1.0/docs/assets/metrics-revealed.png +0 -0
- deckkit-0.1.0/docs/assets/metrics.png +0 -0
- deckkit-0.1.0/docs/assets/showcase.png +0 -0
- deckkit-0.1.0/docs/authoring.md +397 -0
- deckkit-0.1.0/docs/builds-and-export.md +246 -0
- deckkit-0.1.0/docs/charts-and-diagrams.md +239 -0
- deckkit-0.1.0/docs/design.md +113 -0
- deckkit-0.1.0/docs/presenting-code.md +199 -0
- deckkit-0.1.0/docs/themes-and-fonts.md +181 -0
- deckkit-0.1.0/docs/variables.md +222 -0
- deckkit-0.1.0/examples/README.md +30 -0
- deckkit-0.1.0/examples/api_sketch.py +417 -0
- deckkit-0.1.0/examples/card_surfaces.py +100 -0
- deckkit-0.1.0/examples/code_evolution.py +146 -0
- deckkit-0.1.0/examples/compact_tables.py +84 -0
- deckkit-0.1.0/examples/render.py +132 -0
- deckkit-0.1.0/examples/showcase.py +730 -0
- deckkit-0.1.0/examples/tables.py +97 -0
- deckkit-0.1.0/examples/themes.py +139 -0
- deckkit-0.1.0/pyproject.toml +51 -0
- deckkit-0.1.0/setup.cfg +4 -0
- deckkit-0.1.0/src/deckkit/__init__.py +12 -0
- deckkit-0.1.0/src/deckkit/_bundled_fonts.py +54 -0
- deckkit-0.1.0/src/deckkit/_diagnostics.py +48 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SOURCES.txt +9 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceCodePro-Bold.ttf +0 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceCodePro-BoldIt.ttf +0 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceCodePro-It.ttf +0 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceCodePro-LICENSE.txt +93 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceCodePro-Regular.ttf +0 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceSans3-Bold.ttf +0 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceSans3-BoldIt.ttf +0 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceSans3-It.ttf +0 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceSans3-LICENSE.txt +93 -0
- deckkit-0.1.0/src/deckkit/_font_assets/SourceSans3-Regular.ttf +0 -0
- deckkit-0.1.0/src/deckkit/_variable_evaluation.py +82 -0
- deckkit-0.1.0/src/deckkit/animation.py +211 -0
- deckkit-0.1.0/src/deckkit/annotations.py +161 -0
- deckkit-0.1.0/src/deckkit/backends/__init__.py +1 -0
- deckkit-0.1.0/src/deckkit/backends/_font_embedding.py +41 -0
- deckkit-0.1.0/src/deckkit/backends/_pptx_fonts.py +230 -0
- deckkit-0.1.0/src/deckkit/backends/_pptx_shadows.py +241 -0
- deckkit-0.1.0/src/deckkit/backends/_pptx_tables.py +251 -0
- deckkit-0.1.0/src/deckkit/backends/pptx.py +1225 -0
- deckkit-0.1.0/src/deckkit/backends/pptx_animation.py +175 -0
- deckkit-0.1.0/src/deckkit/backends/svg.py +527 -0
- deckkit-0.1.0/src/deckkit/canvas/__init__.py +40 -0
- deckkit-0.1.0/src/deckkit/canvas/_geometry.py +49 -0
- deckkit-0.1.0/src/deckkit/canvas/clipping.py +336 -0
- deckkit-0.1.0/src/deckkit/canvas/context.py +34 -0
- deckkit-0.1.0/src/deckkit/canvas/elements.py +306 -0
- deckkit-0.1.0/src/deckkit/canvas/path.py +250 -0
- deckkit-0.1.0/src/deckkit/canvas/scene.py +74 -0
- deckkit-0.1.0/src/deckkit/canvas/style.py +31 -0
- deckkit-0.1.0/src/deckkit/charts/__init__.py +59 -0
- deckkit-0.1.0/src/deckkit/charts/axes.py +249 -0
- deckkit-0.1.0/src/deckkit/charts/chart.py +244 -0
- deckkit-0.1.0/src/deckkit/charts/content.py +132 -0
- deckkit-0.1.0/src/deckkit/charts/context.py +45 -0
- deckkit-0.1.0/src/deckkit/charts/interval.py +166 -0
- deckkit-0.1.0/src/deckkit/charts/legends.py +82 -0
- deckkit-0.1.0/src/deckkit/charts/marks.py +410 -0
- deckkit-0.1.0/src/deckkit/charts/scales.py +205 -0
- deckkit-0.1.0/src/deckkit/citations.py +200 -0
- deckkit-0.1.0/src/deckkit/compiler.py +410 -0
- deckkit-0.1.0/src/deckkit/context.py +72 -0
- deckkit-0.1.0/src/deckkit/deck.py +168 -0
- deckkit-0.1.0/src/deckkit/drawables/__init__.py +42 -0
- deckkit-0.1.0/src/deckkit/drawables/bounds.py +17 -0
- deckkit-0.1.0/src/deckkit/drawables/connector.py +22 -0
- deckkit-0.1.0/src/deckkit/drawables/drawable.py +38 -0
- deckkit-0.1.0/src/deckkit/drawables/ellipse.py +21 -0
- deckkit-0.1.0/src/deckkit/drawables/group.py +10 -0
- deckkit-0.1.0/src/deckkit/drawables/image.py +14 -0
- deckkit-0.1.0/src/deckkit/drawables/line.py +18 -0
- deckkit-0.1.0/src/deckkit/drawables/path.py +78 -0
- deckkit-0.1.0/src/deckkit/drawables/rectangle.py +24 -0
- deckkit-0.1.0/src/deckkit/drawables/rich_text.py +176 -0
- deckkit-0.1.0/src/deckkit/drawables/table.py +42 -0
- deckkit-0.1.0/src/deckkit/drawables/text.py +29 -0
- deckkit-0.1.0/src/deckkit/effects.py +84 -0
- deckkit-0.1.0/src/deckkit/expanded_views.py +561 -0
- deckkit-0.1.0/src/deckkit/fonts.py +329 -0
- deckkit-0.1.0/src/deckkit/geometry.py +48 -0
- deckkit-0.1.0/src/deckkit/identity.py +72 -0
- deckkit-0.1.0/src/deckkit/layout.py +398 -0
- deckkit-0.1.0/src/deckkit/layouts/__init__.py +20 -0
- deckkit-0.1.0/src/deckkit/layouts/_content.py +27 -0
- deckkit-0.1.0/src/deckkit/layouts/annotations.py +217 -0
- deckkit-0.1.0/src/deckkit/layouts/containers.py +202 -0
- deckkit-0.1.0/src/deckkit/layouts/grid.py +299 -0
- deckkit-0.1.0/src/deckkit/layouts/modifiers.py +200 -0
- deckkit-0.1.0/src/deckkit/layouts/primitives.py +213 -0
- deckkit-0.1.0/src/deckkit/layouts/table.py +139 -0
- deckkit-0.1.0/src/deckkit/measurement.py +420 -0
- deckkit-0.1.0/src/deckkit/paint.py +73 -0
- deckkit-0.1.0/src/deckkit/py.typed +0 -0
- deckkit-0.1.0/src/deckkit/reconcile.py +119 -0
- deckkit-0.1.0/src/deckkit/semantic.py +47 -0
- deckkit-0.1.0/src/deckkit/theme.py +364 -0
- deckkit-0.1.0/src/deckkit/themes/__init__.py +91 -0
- deckkit-0.1.0/src/deckkit/themes/clarity.py +98 -0
- deckkit-0.1.0/src/deckkit/tokens.py +226 -0
- deckkit-0.1.0/src/deckkit/units.py +73 -0
- deckkit-0.1.0/src/deckkit/variables.py +212 -0
- deckkit-0.1.0/src/deckkit/view_expansion.py +185 -0
- deckkit-0.1.0/src/deckkit/views/__init__.py +100 -0
- deckkit-0.1.0/src/deckkit/views/_code_source.py +42 -0
- deckkit-0.1.0/src/deckkit/views/_drawing.py +52 -0
- deckkit-0.1.0/src/deckkit/views/canvas.py +27 -0
- deckkit-0.1.0/src/deckkit/views/code.py +481 -0
- deckkit-0.1.0/src/deckkit/views/code_evolution.py +284 -0
- deckkit-0.1.0/src/deckkit/views/composite_view.py +19 -0
- deckkit-0.1.0/src/deckkit/views/divider.py +38 -0
- deckkit-0.1.0/src/deckkit/views/ellipse.py +38 -0
- deckkit-0.1.0/src/deckkit/views/grid.py +156 -0
- deckkit-0.1.0/src/deckkit/views/hstack.py +43 -0
- deckkit-0.1.0/src/deckkit/views/image.py +43 -0
- deckkit-0.1.0/src/deckkit/views/layout_view.py +30 -0
- deckkit-0.1.0/src/deckkit/views/line.py +31 -0
- deckkit-0.1.0/src/deckkit/views/modifier_views.py +281 -0
- deckkit-0.1.0/src/deckkit/views/path.py +36 -0
- deckkit-0.1.0/src/deckkit/views/primitive_view.py +16 -0
- deckkit-0.1.0/src/deckkit/views/pygments_highlighter.py +67 -0
- deckkit-0.1.0/src/deckkit/views/rectangle.py +61 -0
- deckkit-0.1.0/src/deckkit/views/section_number.py +21 -0
- deckkit-0.1.0/src/deckkit/views/semantic/__init__.py +51 -0
- deckkit-0.1.0/src/deckkit/views/semantic/before_after.py +109 -0
- deckkit-0.1.0/src/deckkit/views/semantic/bullet_graph.py +216 -0
- deckkit-0.1.0/src/deckkit/views/semantic/card.py +129 -0
- deckkit-0.1.0/src/deckkit/views/semantic/code_block.py +41 -0
- deckkit-0.1.0/src/deckkit/views/semantic/diff.py +642 -0
- deckkit-0.1.0/src/deckkit/views/semantic/estimate_interval.py +137 -0
- deckkit-0.1.0/src/deckkit/views/semantic/figure.py +55 -0
- deckkit-0.1.0/src/deckkit/views/semantic/item_list.py +171 -0
- deckkit-0.1.0/src/deckkit/views/semantic/metric.py +74 -0
- deckkit-0.1.0/src/deckkit/views/semantic/pill.py +69 -0
- deckkit-0.1.0/src/deckkit/views/semantic/pipeline.py +94 -0
- deckkit-0.1.0/src/deckkit/views/semantic/pipeline_stage.py +59 -0
- deckkit-0.1.0/src/deckkit/views/semantic/semantic_view.py +76 -0
- deckkit-0.1.0/src/deckkit/views/semantic/sparkline.py +164 -0
- deckkit-0.1.0/src/deckkit/views/semantic/table.py +439 -0
- deckkit-0.1.0/src/deckkit/views/semantic/terminal.py +361 -0
- deckkit-0.1.0/src/deckkit/views/semantic/timeline.py +158 -0
- deckkit-0.1.0/src/deckkit/views/slide.py +37 -0
- deckkit-0.1.0/src/deckkit/views/slide_number.py +20 -0
- deckkit-0.1.0/src/deckkit/views/slides/__init__.py +16 -0
- deckkit-0.1.0/src/deckkit/views/slides/section_slide.py +89 -0
- deckkit-0.1.0/src/deckkit/views/slides/slide_margins.py +32 -0
- deckkit-0.1.0/src/deckkit/views/slides/slide_with_margins.py +22 -0
- deckkit-0.1.0/src/deckkit/views/slides/title_and_content.py +49 -0
- deckkit-0.1.0/src/deckkit/views/slides/title_and_content_slide.py +55 -0
- deckkit-0.1.0/src/deckkit/views/spacer.py +45 -0
- deckkit-0.1.0/src/deckkit/views/stack.py +36 -0
- deckkit-0.1.0/src/deckkit/views/text.py +142 -0
- deckkit-0.1.0/src/deckkit/views/view.py +229 -0
- deckkit-0.1.0/src/deckkit/views/vstack.py +31 -0
- deckkit-0.1.0/src/deckkit/views/zstack.py +27 -0
- deckkit-0.1.0/src/deckkit.egg-info/PKG-INFO +123 -0
- deckkit-0.1.0/src/deckkit.egg-info/SOURCES.txt +205 -0
- deckkit-0.1.0/src/deckkit.egg-info/dependency_links.txt +1 -0
- deckkit-0.1.0/src/deckkit.egg-info/requires.txt +18 -0
- deckkit-0.1.0/src/deckkit.egg-info/top_level.txt +1 -0
- deckkit-0.1.0/tests/conftest.py +122 -0
- deckkit-0.1.0/tests/test_animation.py +645 -0
- deckkit-0.1.0/tests/test_annotations.py +229 -0
- deckkit-0.1.0/tests/test_architecture.py +282 -0
- deckkit-0.1.0/tests/test_canvas.py +515 -0
- deckkit-0.1.0/tests/test_card_surface.py +110 -0
- deckkit-0.1.0/tests/test_charts.py +324 -0
- deckkit-0.1.0/tests/test_code.py +376 -0
- deckkit-0.1.0/tests/test_code_evolution.py +186 -0
- deckkit-0.1.0/tests/test_compact_data_views.py +139 -0
- deckkit-0.1.0/tests/test_deck.py +287 -0
- deckkit-0.1.0/tests/test_design_tokens.py +201 -0
- deckkit-0.1.0/tests/test_diagnostics.py +135 -0
- deckkit-0.1.0/tests/test_diff.py +234 -0
- deckkit-0.1.0/tests/test_divider.py +68 -0
- deckkit-0.1.0/tests/test_drawables.py +56 -0
- deckkit-0.1.0/tests/test_effects.py +333 -0
- deckkit-0.1.0/tests/test_fonts.py +437 -0
- deckkit-0.1.0/tests/test_grid.py +156 -0
- deckkit-0.1.0/tests/test_item_list.py +181 -0
- deckkit-0.1.0/tests/test_layout_policies.py +505 -0
- deckkit-0.1.0/tests/test_pptx_fonts.py +277 -0
- deckkit-0.1.0/tests/test_rounded_rectangles.py +119 -0
- deckkit-0.1.0/tests/test_semantic_views.py +343 -0
- deckkit-0.1.0/tests/test_shape_views.py +100 -0
- deckkit-0.1.0/tests/test_sparkline.py +160 -0
- deckkit-0.1.0/tests/test_styling.py +118 -0
- deckkit-0.1.0/tests/test_table.py +321 -0
- deckkit-0.1.0/tests/test_terminal.py +241 -0
- deckkit-0.1.0/tests/test_theme_contract.py +81 -0
- deckkit-0.1.0/tests/test_timeline.py +164 -0
- deckkit-0.1.0/tests/test_typography.py +350 -0
- deckkit-0.1.0/tests/test_units.py +109 -0
- deckkit-0.1.0/tests/test_variables.py +319 -0
- deckkit-0.1.0/tests/test_view_categories.py +190 -0
- deckkit-0.1.0/tests/typing/public_api.py +313 -0
deckkit-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeckKit contributors
|
|
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,8 @@
|
|
|
1
|
+
recursive-include examples *.py
|
|
2
|
+
include examples/README.md
|
|
3
|
+
recursive-include tests *.py
|
|
4
|
+
recursive-include docs *.md
|
|
5
|
+
include docs/assets/metrics.png docs/assets/showcase.png
|
|
6
|
+
include docs/assets/metrics-opening.png docs/assets/metrics-revealed.png
|
|
7
|
+
include docs/assets/metrics-citation.png
|
|
8
|
+
include docs/assets/figure-reference.png docs/assets/figure-caption.png
|
deckkit-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deckkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Declarative presentation views compiled to backend-independent scenes
|
|
5
|
+
License-Expression: MIT AND OFL-1.1
|
|
6
|
+
Project-URL: Repository, https://github.com/jonathanvdc/deckkit
|
|
7
|
+
Project-URL: Documentation, https://github.com/jonathanvdc/deckkit#documentation
|
|
8
|
+
Project-URL: Issues, https://github.com/jonathanvdc/deckkit/issues
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: src/deckkit/_font_assets/SourceCodePro-LICENSE.txt
|
|
13
|
+
License-File: src/deckkit/_font_assets/SourceSans3-LICENSE.txt
|
|
14
|
+
Requires-Dist: Pillow>=10
|
|
15
|
+
Requires-Dist: uharfbuzz>=0.40
|
|
16
|
+
Requires-Dist: fonttools>=4.49
|
|
17
|
+
Requires-Dist: regex>=2024.11.6
|
|
18
|
+
Requires-Dist: typing-extensions>=4.6
|
|
19
|
+
Provides-Extra: pptx
|
|
20
|
+
Requires-Dist: python-pptx>=1.0; extra == "pptx"
|
|
21
|
+
Provides-Extra: highlight
|
|
22
|
+
Requires-Dist: Pygments>=2.18; extra == "highlight"
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
25
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy<2,>=1.19; extra == "dev"
|
|
27
|
+
Requires-Dist: ruff<1,>=0.16; extra == "dev"
|
|
28
|
+
Requires-Dist: Pygments>=2.18; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# DeckKit
|
|
32
|
+
|
|
33
|
+
DeckKit is a Python library for building presentations from reusable views. Compose
|
|
34
|
+
slides with text, charts, and diagrams, and let DeckKit calculate their layout.
|
|
35
|
+
Export editable text and shapes to PowerPoint, or render a slide as SVG. Give
|
|
36
|
+
a slide a sequence of states to create click-through builds in PowerPoint.
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
## Make a slide
|
|
41
|
+
|
|
42
|
+
With Python 3.9 or later, install DeckKit with PowerPoint support.
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
python -m venv .venv
|
|
46
|
+
source .venv/bin/activate
|
|
47
|
+
python -m pip install --upgrade pip
|
|
48
|
+
python -m pip install 'deckkit[pptx]'
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In Windows PowerShell, use `.\.venv\Scripts\Activate.ps1` in place of the
|
|
52
|
+
`source` command.
|
|
53
|
+
|
|
54
|
+
Save the following as `metrics.py` and run `python metrics.py`. Clarity uses
|
|
55
|
+
fonts bundled with DeckKit, so the example works without installing fonts
|
|
56
|
+
separately.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from deckkit import Deck
|
|
60
|
+
from deckkit.themes import ClarityTheme, MutedColor
|
|
61
|
+
from deckkit.units import pt
|
|
62
|
+
from deckkit.views import HStack, Text
|
|
63
|
+
from deckkit.views.semantic import Metric
|
|
64
|
+
from deckkit.views.slides import TitleAndContentSlide
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
slide = TitleAndContentSlide.of(
|
|
68
|
+
"Illustrative compile times",
|
|
69
|
+
HStack(
|
|
70
|
+
Metric(Text("−26%"), Text("Compile time")),
|
|
71
|
+
Text("282 ms before\n210 ms after").foreground_style(MutedColor),
|
|
72
|
+
alignment="center",
|
|
73
|
+
spacing=pt(56),
|
|
74
|
+
),
|
|
75
|
+
)
|
|
76
|
+
deck = Deck([slide], theme=ClarityTheme())
|
|
77
|
+
deck.write_pptx("metrics.pptx")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`TitleAndContentSlide.of()` provides the title layout and margins. `HStack`
|
|
81
|
+
arranges the metrics horizontally, and `ClarityTheme` supplies their
|
|
82
|
+
typography and colors. The script writes `metrics.pptx` in your current
|
|
83
|
+
directory and embeds its font in the file.
|
|
84
|
+
|
|
85
|
+

|
|
86
|
+
|
|
87
|
+
Once you have a slide, you can [compose your own layout](https://github.com/jonathanvdc/deckkit/blob/main/docs/authoring.md#compose-views),
|
|
88
|
+
[reveal the metric on a click](https://github.com/jonathanvdc/deckkit/blob/main/docs/builds-and-export.md#add-a-build-to-a-slide),
|
|
89
|
+
or [preview a specific build as SVG](https://github.com/jonathanvdc/deckkit/blob/main/docs/builds-and-export.md#preview-a-state-in-svg).
|
|
90
|
+
|
|
91
|
+
## Run the showcase
|
|
92
|
+
|
|
93
|
+
The [showcase](https://github.com/jonathanvdc/deckkit/blob/main/examples/showcase.py) is a deck about DeckKit, made with
|
|
94
|
+
DeckKit. It follows an illustrative benchmark through composition, charting,
|
|
95
|
+
layout, a click-through build, and two theme treatments. Code excerpts show
|
|
96
|
+
how to reproduce each effect and how to export the result to PowerPoint or
|
|
97
|
+
SVG. Run these commands from a checkout to use the matching library and examples.
|
|
98
|
+
Open `output/deckkit.pptx` in PowerPoint to play the build.
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
python -m pip install -e '.[pptx]'
|
|
102
|
+
python -m examples.render
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The [example instructions](https://github.com/jonathanvdc/deckkit/blob/main/examples/README.md) cover the component gallery,
|
|
106
|
+
SVG previews of the full deck, and using your own fonts.
|
|
107
|
+
|
|
108
|
+
## Documentation
|
|
109
|
+
|
|
110
|
+
Follow the guide that matches what you want to add to your deck.
|
|
111
|
+
|
|
112
|
+
- [Authoring slides](https://github.com/jonathanvdc/deckkit/blob/main/docs/authoring.md) covers slide templates, reusable views, and layout.
|
|
113
|
+
- [Number and reference content](https://github.com/jonathanvdc/deckkit/blob/main/docs/variables.md) covers citations, figures, sections, and values that carry across builds.
|
|
114
|
+
- [Present source code and terminal output](https://github.com/jonathanvdc/deckkit/blob/main/docs/presenting-code.md) covers listings, diffs, and animated code walkthroughs.
|
|
115
|
+
- [Charts and diagrams](https://github.com/jonathanvdc/deckkit/blob/main/docs/charts-and-diagrams.md) covers data marks, custom drawing, and annotations.
|
|
116
|
+
- [Themes and fonts](https://github.com/jonathanvdc/deckkit/blob/main/docs/themes-and-fonts.md) covers styling, font resolution, and embedding.
|
|
117
|
+
- [Builds and export](https://github.com/jonathanvdc/deckkit/blob/main/docs/builds-and-export.md) covers slide states, PowerPoint timing, and SVG previews.
|
|
118
|
+
- [Architecture](https://github.com/jonathanvdc/deckkit/blob/main/docs/design.md) explains compilation, custom layout, and how to run the project's checks.
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
DeckKit is available under the [MIT License](https://github.com/jonathanvdc/deckkit/blob/main/LICENSE).
|
|
123
|
+
Its bundled fonts use the SIL Open Font License 1.1.
|
deckkit-0.1.0/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# DeckKit
|
|
2
|
+
|
|
3
|
+
DeckKit is a Python library for building presentations from reusable views. Compose
|
|
4
|
+
slides with text, charts, and diagrams, and let DeckKit calculate their layout.
|
|
5
|
+
Export editable text and shapes to PowerPoint, or render a slide as SVG. Give
|
|
6
|
+
a slide a sequence of states to create click-through builds in PowerPoint.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## Make a slide
|
|
11
|
+
|
|
12
|
+
With Python 3.9 or later, install DeckKit with PowerPoint support.
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
python -m venv .venv
|
|
16
|
+
source .venv/bin/activate
|
|
17
|
+
python -m pip install --upgrade pip
|
|
18
|
+
python -m pip install 'deckkit[pptx]'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
In Windows PowerShell, use `.\.venv\Scripts\Activate.ps1` in place of the
|
|
22
|
+
`source` command.
|
|
23
|
+
|
|
24
|
+
Save the following as `metrics.py` and run `python metrics.py`. Clarity uses
|
|
25
|
+
fonts bundled with DeckKit, so the example works without installing fonts
|
|
26
|
+
separately.
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from deckkit import Deck
|
|
30
|
+
from deckkit.themes import ClarityTheme, MutedColor
|
|
31
|
+
from deckkit.units import pt
|
|
32
|
+
from deckkit.views import HStack, Text
|
|
33
|
+
from deckkit.views.semantic import Metric
|
|
34
|
+
from deckkit.views.slides import TitleAndContentSlide
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
slide = TitleAndContentSlide.of(
|
|
38
|
+
"Illustrative compile times",
|
|
39
|
+
HStack(
|
|
40
|
+
Metric(Text("−26%"), Text("Compile time")),
|
|
41
|
+
Text("282 ms before\n210 ms after").foreground_style(MutedColor),
|
|
42
|
+
alignment="center",
|
|
43
|
+
spacing=pt(56),
|
|
44
|
+
),
|
|
45
|
+
)
|
|
46
|
+
deck = Deck([slide], theme=ClarityTheme())
|
|
47
|
+
deck.write_pptx("metrics.pptx")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`TitleAndContentSlide.of()` provides the title layout and margins. `HStack`
|
|
51
|
+
arranges the metrics horizontally, and `ClarityTheme` supplies their
|
|
52
|
+
typography and colors. The script writes `metrics.pptx` in your current
|
|
53
|
+
directory and embeds its font in the file.
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
Once you have a slide, you can [compose your own layout](https://github.com/jonathanvdc/deckkit/blob/main/docs/authoring.md#compose-views),
|
|
58
|
+
[reveal the metric on a click](https://github.com/jonathanvdc/deckkit/blob/main/docs/builds-and-export.md#add-a-build-to-a-slide),
|
|
59
|
+
or [preview a specific build as SVG](https://github.com/jonathanvdc/deckkit/blob/main/docs/builds-and-export.md#preview-a-state-in-svg).
|
|
60
|
+
|
|
61
|
+
## Run the showcase
|
|
62
|
+
|
|
63
|
+
The [showcase](https://github.com/jonathanvdc/deckkit/blob/main/examples/showcase.py) is a deck about DeckKit, made with
|
|
64
|
+
DeckKit. It follows an illustrative benchmark through composition, charting,
|
|
65
|
+
layout, a click-through build, and two theme treatments. Code excerpts show
|
|
66
|
+
how to reproduce each effect and how to export the result to PowerPoint or
|
|
67
|
+
SVG. Run these commands from a checkout to use the matching library and examples.
|
|
68
|
+
Open `output/deckkit.pptx` in PowerPoint to play the build.
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
python -m pip install -e '.[pptx]'
|
|
72
|
+
python -m examples.render
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The [example instructions](https://github.com/jonathanvdc/deckkit/blob/main/examples/README.md) cover the component gallery,
|
|
76
|
+
SVG previews of the full deck, and using your own fonts.
|
|
77
|
+
|
|
78
|
+
## Documentation
|
|
79
|
+
|
|
80
|
+
Follow the guide that matches what you want to add to your deck.
|
|
81
|
+
|
|
82
|
+
- [Authoring slides](https://github.com/jonathanvdc/deckkit/blob/main/docs/authoring.md) covers slide templates, reusable views, and layout.
|
|
83
|
+
- [Number and reference content](https://github.com/jonathanvdc/deckkit/blob/main/docs/variables.md) covers citations, figures, sections, and values that carry across builds.
|
|
84
|
+
- [Present source code and terminal output](https://github.com/jonathanvdc/deckkit/blob/main/docs/presenting-code.md) covers listings, diffs, and animated code walkthroughs.
|
|
85
|
+
- [Charts and diagrams](https://github.com/jonathanvdc/deckkit/blob/main/docs/charts-and-diagrams.md) covers data marks, custom drawing, and annotations.
|
|
86
|
+
- [Themes and fonts](https://github.com/jonathanvdc/deckkit/blob/main/docs/themes-and-fonts.md) covers styling, font resolution, and embedding.
|
|
87
|
+
- [Builds and export](https://github.com/jonathanvdc/deckkit/blob/main/docs/builds-and-export.md) covers slide states, PowerPoint timing, and SVG previews.
|
|
88
|
+
- [Architecture](https://github.com/jonathanvdc/deckkit/blob/main/docs/design.md) explains compilation, custom layout, and how to run the project's checks.
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
DeckKit is available under the [MIT License](https://github.com/jonathanvdc/deckkit/blob/main/LICENSE).
|
|
93
|
+
Its bundled fonts use the SIL Open Font License 1.1.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
# Authoring slides
|
|
2
|
+
|
|
3
|
+
A `Deck` holds an ordered sequence of slides, a theme, and a canvas size. A
|
|
4
|
+
slide describes its content as a tree of views. DeckKit measures and places
|
|
5
|
+
that tree before exporting it. The [first-slide example](../README.md#make-a-slide)
|
|
6
|
+
shows the entire workflow.
|
|
7
|
+
|
|
8
|
+
## Compose views
|
|
9
|
+
|
|
10
|
+
Choose a slide constructor based on how you want to supply the layout.
|
|
11
|
+
Use `TitleAndContentSlide.of("Results", chart)` to place a view in a slide with
|
|
12
|
+
a themed title and margins. The title can be a string or a view, so you can
|
|
13
|
+
use a styled `Text` or a richer composition in the same slot.
|
|
14
|
+
|
|
15
|
+
If you already have a complete layout, use `Slide.from_view(layout)` from
|
|
16
|
+
`deckkit.views`. To inset the layout by the theme's slide margins, wrap it
|
|
17
|
+
with `Slide.from_view(SlideMargins(layout))` using `SlideMargins` from
|
|
18
|
+
`deckkit.views.slides`.
|
|
19
|
+
|
|
20
|
+
The summary puts a status line under a themed title. The cover arranges its
|
|
21
|
+
own label and headline, then applies the slide margins. The results slide
|
|
22
|
+
keeps the themed title and reads a timing supplied at compile time.
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from deckkit import Deck
|
|
26
|
+
from deckkit.context import State
|
|
27
|
+
from deckkit.themes import ClarityTheme, MutedColor, TitleTextStyle
|
|
28
|
+
from deckkit.units import pt
|
|
29
|
+
from deckkit.views import Slide, Text, VStack
|
|
30
|
+
from deckkit.views.slides import SlideMargins, TitleAndContentSlide
|
|
31
|
+
|
|
32
|
+
summary = TitleAndContentSlide.of("Benchmark", Text("Run complete."))
|
|
33
|
+
cover = Slide.from_view(
|
|
34
|
+
SlideMargins(
|
|
35
|
+
VStack(
|
|
36
|
+
Text("Compiler benchmark").foreground_style(MutedColor),
|
|
37
|
+
Text("Performance review").font(TitleTextStyle),
|
|
38
|
+
spacing=pt(12),
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class Results(TitleAndContentSlide):
|
|
45
|
+
@property
|
|
46
|
+
def title(self):
|
|
47
|
+
return Text("Build time")
|
|
48
|
+
|
|
49
|
+
def content(self, context):
|
|
50
|
+
return Text(f"{context.state['duration_ms']} ms after optimization")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
deck = Deck([cover, summary, Results()], theme=ClarityTheme())
|
|
54
|
+
deck.write_svg("results.svg", slide=3, state=State(duration_ms=210))
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
A `TitleAndContentSlide` subclass supplies a `title` property and a
|
|
58
|
+
`content(context)` method that each return a view. For a custom slide
|
|
59
|
+
layout that reads context, implement `Slide.body(context)`. Implement
|
|
60
|
+
`CompositeView.body(context)` to package a reusable part of a slide.
|
|
61
|
+
A [build timeline](builds-and-export.md#add-a-build-to-a-slide) can also
|
|
62
|
+
supply state to your slide.
|
|
63
|
+
|
|
64
|
+
Stacks and primitives live in `deckkit.views`. Components such as `Card`,
|
|
65
|
+
`Pill`, `Metric`, `BeforeAfter`, and `Pipeline` live in
|
|
66
|
+
`deckkit.views.semantic`. They accept views in their content slots, so you can
|
|
67
|
+
use a stack as a card's content or a styled `Text` as a metric's value.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from deckkit.units import pt
|
|
71
|
+
from deckkit.views import HStack, Spacer, Text
|
|
72
|
+
from deckkit.views.semantic import Pill
|
|
73
|
+
|
|
74
|
+
status = HStack(
|
|
75
|
+
Text("Release build"),
|
|
76
|
+
Spacer(min_length=pt(12)),
|
|
77
|
+
Pill(Text("Ready")),
|
|
78
|
+
alignment="center",
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Number slides and sections
|
|
83
|
+
|
|
84
|
+
Use `SlideNumber()` wherever you would place text, including in a shared
|
|
85
|
+
footer. It measures using the one-based logical slide number and exports as
|
|
86
|
+
a live number field in PowerPoint. All build states of a logical slide share
|
|
87
|
+
that number. If you [expand builds into static slides](builds-and-export.md#export-powerpoint),
|
|
88
|
+
each resulting PowerPoint slide receives its own number.
|
|
89
|
+
|
|
90
|
+
Insert `SectionSlide("Performance", subtitle="What we measured")` from
|
|
91
|
+
`deckkit.views.slides` to start a section. The title and subtitle each accept
|
|
92
|
+
a string or a view. The default theme displays the section number above the
|
|
93
|
+
title. Set `.style(show_number=False)` to hide that label while still
|
|
94
|
+
starting the section. Use `SectionNumber()`
|
|
95
|
+
from `deckkit.views` to show the active section on subsequent slides. It
|
|
96
|
+
displays nothing before the first opener. See [Number and reference content](variables.md)
|
|
97
|
+
for figures, build-by-build counters, and citations.
|
|
98
|
+
|
|
99
|
+
## Size and arrange content
|
|
100
|
+
|
|
101
|
+
Use `HStack` for rows, `VStack` for columns, and `ZStack` for layered views.
|
|
102
|
+
Set stack spacing and other physical dimensions with `pt(...)`, `inch(...)`,
|
|
103
|
+
or `cm(...)`. For example, `pt(72)` and `inch(1)` describe the same length.
|
|
104
|
+
The default deck is 960 × 540 points. Pass `width` and `height` to `Deck` for
|
|
105
|
+
a different canvas.
|
|
106
|
+
|
|
107
|
+
Stacks align children across their main axis. `HStack` accepts `"top"`,
|
|
108
|
+
`"center"`, and `"bottom"`. `VStack` accepts `"leading"`, `"center"`, and
|
|
109
|
+
`"trailing"`. Use `Spacer()` to take up spare room along the stack axis,
|
|
110
|
+
`Spacer(pt(12))` for a fixed gap, or `Divider()` for a rule perpendicular to
|
|
111
|
+
the stack axis. The stack applies its normal spacing around spacers and
|
|
112
|
+
dividers.
|
|
113
|
+
|
|
114
|
+
Use `HStack(alignment="first_baseline")` to align the first lines of
|
|
115
|
+
mixed-size text, or `"last_baseline"` to align the last lines of multiline
|
|
116
|
+
labels. A view without text aligns by its bottom edge. For a swatch or icon
|
|
117
|
+
beside a label, use `"cap_center"` to align the shape's center with the
|
|
118
|
+
middle of the capitals on the first text line. When cap height is unavailable,
|
|
119
|
+
DeckKit uses the center of that line's measured box. Guides follow the
|
|
120
|
+
positions of text through nested stacks, padding, and frames.
|
|
121
|
+
PowerPoint still determines where text sits inside each editable textbox.
|
|
122
|
+
|
|
123
|
+
To change a particular child's guide, use `.alignment_guide()` with a
|
|
124
|
+
function that returns an offset from the top of its measured box. For
|
|
125
|
+
example, `icon.alignment_guide("first_baseline", lambda box: box.height / 2)`
|
|
126
|
+
places the icon's center on the baseline. You can also create a
|
|
127
|
+
`VerticalAlignment` with a fallback function and pass it both to
|
|
128
|
+
`HStack` and to `.alignment_guide()`. A custom guide averages the positions
|
|
129
|
+
reported by nested children unless you supply a different combining function.
|
|
130
|
+
|
|
131
|
+
Layout modifiers wrap views in call order. In the following badge, the
|
|
132
|
+
background follows the size of the text including its padding. Moving the
|
|
133
|
+
padding call after the background call puts that space outside the badge.
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from deckkit.themes import SurfaceColor
|
|
137
|
+
from deckkit.units import pt
|
|
138
|
+
from deckkit.views import Rectangle, Text
|
|
139
|
+
|
|
140
|
+
badge = (
|
|
141
|
+
Text("Ready")
|
|
142
|
+
.padding(pt(6))
|
|
143
|
+
.background(Rectangle(fill=SurfaceColor, corner_radius=pt(4)))
|
|
144
|
+
)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Use `frame(width=..., height=...)` for a fixed allocation. To negotiate size
|
|
148
|
+
with the parent, use minimum, ideal, and maximum dimensions. For example,
|
|
149
|
+
`frame(min_width=pt(120), max_width=unbounded)` takes the offered width when
|
|
150
|
+
it is large enough and uses the child's ideal size when the parent leaves
|
|
151
|
+
the width unspecified. Import `unbounded` from `deckkit.views`. Frames can
|
|
152
|
+
align an oversized child, and their contents can extend past their edges.
|
|
153
|
+
|
|
154
|
+
Use `background()` and `overlay()` for decoration by reference to a single
|
|
155
|
+
view's measured size. Use `ZStack` when the layers should contribute to the
|
|
156
|
+
size of the composition. For different padding on each edge, pass an
|
|
157
|
+
`EdgeInsets` value to `padding()`. Omitted edges default to zero.
|
|
158
|
+
|
|
159
|
+
`offset(x=..., y=...)` shifts the drawing while
|
|
160
|
+
preserving its layout space. `position(x=..., y=...)` places the view's center
|
|
161
|
+
at coordinates measured from the top left of its container. Pass an
|
|
162
|
+
`anchor` such as `RelativePoint.top_left` to place another point on the view.
|
|
163
|
+
Apply `.key()` before positioning a view when annotations should follow its
|
|
164
|
+
moved bounds.
|
|
165
|
+
|
|
166
|
+
An `Image` uses 96 DPI for its intrinsic size unless you provide a `dpi`
|
|
167
|
+
value. A frame and the image's contain or cover fit determine how it is
|
|
168
|
+
drawn. For vector graphics inside a layout, use `Rectangle`, `Ellipse`,
|
|
169
|
+
`Line`, or `Path` from `deckkit.views`. For size-dependent drawing, see
|
|
170
|
+
[Charts and diagrams](charts-and-diagrams.md).
|
|
171
|
+
|
|
172
|
+
Pass a `LinearGradient` as the fill for text or a rectangle when you need
|
|
173
|
+
more than one color. Use `.opacity(0.5)` to make a view translucent without
|
|
174
|
+
changing its layout. Nested opacity values multiply and apply to individual
|
|
175
|
+
paint operations, so overlapping shapes remain visible through one another.
|
|
176
|
+
|
|
177
|
+
## Align views in a grid
|
|
178
|
+
|
|
179
|
+
Use `Grid` when views in different rows need to share column widths. Each
|
|
180
|
+
`GridRow` places its views in successive columns, and each row is as tall
|
|
181
|
+
as its tallest cell after text wraps. The example gives two panels flexible
|
|
182
|
+
columns, with a divider above a note that spans both.
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from deckkit.units import pt
|
|
186
|
+
from deckkit.views import ColumnWidth, Divider, Grid, GridCell, GridRow, Text
|
|
187
|
+
|
|
188
|
+
overview = Grid(
|
|
189
|
+
GridRow(Text("Pilot"), Text("Full rollout")),
|
|
190
|
+
GridRow(Text("One support team"), Text("All support teams")),
|
|
191
|
+
Divider(),
|
|
192
|
+
GridRow(
|
|
193
|
+
GridCell(Text("Both plans use the same training material."), column_span=2)
|
|
194
|
+
),
|
|
195
|
+
columns=(ColumnWidth(weight=1), ColumnWidth(weight=1)),
|
|
196
|
+
horizontal_spacing=pt(24),
|
|
197
|
+
vertical_spacing=pt(8),
|
|
198
|
+
).frame(width=pt(460))
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Pass a length to fix a column's width, or use `ColumnWidth` for width limits
|
|
202
|
+
and a share of any extra space. Other columns size to their content. Use
|
|
203
|
+
`None` inside a row to leave a column empty before the next cell. A view
|
|
204
|
+
placed directly in the grid, like the divider, spans the whole grid.
|
|
205
|
+
|
|
206
|
+
The grid aligns content to the top left of each cell by default. Use a
|
|
207
|
+
`RelativePoint` on the grid, a row, or a cell to change that alignment.
|
|
208
|
+
Set `contributes_width=False` on a `GridCell` when the view should take the
|
|
209
|
+
width assigned to it without influencing the width of the columns.
|
|
210
|
+
|
|
211
|
+
## Present a list of items
|
|
212
|
+
|
|
213
|
+
Use `ItemList` to present related points or a sequence. It accepts strings
|
|
214
|
+
and views, keeps them in the order you supply them, and uses bullets by
|
|
215
|
+
default. Pass `ordered=True` when the sequence matters and you want numbered
|
|
216
|
+
markers. Both marker styles inherit the text color. Clarity leaves 10 pt
|
|
217
|
+
after the marker column and 12 pt between rows.
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
from deckkit.views.semantic import ItemList
|
|
221
|
+
|
|
222
|
+
requirements = ItemList(
|
|
223
|
+
"Support Python 3.9 and later.",
|
|
224
|
+
"Keep PowerPoint export optional.",
|
|
225
|
+
)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Rows take the width offered by the parent and grow with their content. Use
|
|
229
|
+
`.frame(width=...)` to wrap longer labels to a specific width. With no width
|
|
230
|
+
proposal, rows use their natural widths. DeckKit sizes the shared marker
|
|
231
|
+
column to the widest marker and aligns markers with the first line of text,
|
|
232
|
+
so wrapped lines start at the same inset as the first line.
|
|
233
|
+
|
|
234
|
+
A custom `marker` factory receives the one-based ordinal for a numbered
|
|
235
|
+
list or `None` for a bulleted list. A `row` factory receives the assembled
|
|
236
|
+
marker and content together. Here the marker adds a leading zero to
|
|
237
|
+
each step number, and the row factory wraps the whole step in a card.
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
from typing import Optional
|
|
241
|
+
|
|
242
|
+
from deckkit.themes import AccentColor
|
|
243
|
+
from deckkit.units import pt
|
|
244
|
+
from deckkit.views import Text, View
|
|
245
|
+
from deckkit.views.semantic import Card, ItemList
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def step_marker(ordinal: Optional[int]) -> View:
|
|
249
|
+
label = f"{ordinal:02d}" if ordinal is not None else "•"
|
|
250
|
+
return Text(label).foreground_style(AccentColor)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def step_row(content: View) -> View:
|
|
254
|
+
return Card(content).style(padding=pt(12))
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
procedure = ItemList(
|
|
258
|
+
"Run the benchmark.",
|
|
259
|
+
"Compare against the baseline.",
|
|
260
|
+
ordered=True,
|
|
261
|
+
).style(marker=step_marker, row=step_row)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
To add a stripe to the card, supply a custom `surface` factory to
|
|
265
|
+
`Card.style(...)`. The [banded surface example](../examples/card_surfaces.py)
|
|
266
|
+
draws bands along any edge of the padded row and layers overlapping bands
|
|
267
|
+
in the order supplied.
|
|
268
|
+
|
|
269
|
+
Set `ItemList.style_token` in a theme to share the factories and spacing
|
|
270
|
+
across a deck. A list's `.style(...)` can override individual fields.
|
|
271
|
+
Use consistent leading padding across rows to keep their content aligned.
|
|
272
|
+
Wrap content in `ListItem` and give it a distinct `.key(...)` when you want
|
|
273
|
+
the whole row to keep its identity as it moves across builds.
|
|
274
|
+
For a different arrangement, register a
|
|
275
|
+
[semantic renderer](themes-and-fonts.md#customize-clarity) for `ItemList`.
|
|
276
|
+
|
|
277
|
+
## Present exact values in a table
|
|
278
|
+
|
|
279
|
+
Use `Table` when readers need to compare or look up values. A `TableColumn`
|
|
280
|
+
gives a header and selects a value from each row. Numeric columns align to
|
|
281
|
+
the trailing edge, including when a formatter adds a unit or percent sign.
|
|
282
|
+
Headers follow their column's alignment by default.
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
from dataclasses import dataclass
|
|
286
|
+
|
|
287
|
+
from deckkit.themes import SurfaceColor
|
|
288
|
+
from deckkit.units import pt
|
|
289
|
+
from deckkit.views.semantic import ColumnWidth, RowStyle, Table, TableColumn
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
@dataclass(frozen=True)
|
|
293
|
+
class Timing:
|
|
294
|
+
name: str
|
|
295
|
+
before_ms: int
|
|
296
|
+
after_ms: int
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
timings = [
|
|
300
|
+
Timing("Parse", 40, 38),
|
|
301
|
+
Timing("Optimize", 160, 112),
|
|
302
|
+
Timing("Emit", 60, 54),
|
|
303
|
+
]
|
|
304
|
+
comparison = (
|
|
305
|
+
Table(
|
|
306
|
+
timings,
|
|
307
|
+
row_key=lambda row: row.name,
|
|
308
|
+
columns=(
|
|
309
|
+
TableColumn(
|
|
310
|
+
"Compiler pass", lambda row: row.name, width=ColumnWidth(weight=1)
|
|
311
|
+
),
|
|
312
|
+
TableColumn("Before (ms)", lambda row: row.before_ms),
|
|
313
|
+
TableColumn("After (ms)", lambda row: row.after_ms),
|
|
314
|
+
TableColumn(
|
|
315
|
+
"Change",
|
|
316
|
+
lambda row: row.after_ms / row.before_ms - 1,
|
|
317
|
+
format=lambda change: f"{change:+.0%}",
|
|
318
|
+
),
|
|
319
|
+
),
|
|
320
|
+
)
|
|
321
|
+
.style(alternate_row=RowStyle(background=SurfaceColor))
|
|
322
|
+
.frame(width=pt(550))
|
|
323
|
+
)
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
A length sets a fixed column width. `ColumnWidth` can set a minimum, ideal,
|
|
327
|
+
and maximum. With a finite width proposal, a positive `weight` lets the
|
|
328
|
+
column share extra room. At narrower widths, labels wrap within their
|
|
329
|
+
columns and the tallest cell determines the row height. If the content and
|
|
330
|
+
width limits cannot fit the proposal, DeckKit reports a layout overflow.
|
|
331
|
+
|
|
332
|
+
Use `cell=` to turn the selected value into a view. The
|
|
333
|
+
[timings example](../examples/tables.py) returns a `Sparkline` on a shared
|
|
334
|
+
scale for each row and reserves a fixed width for its column. Its `style_cell`
|
|
335
|
+
callback tints selected values while keeping their ordinary text formatting.
|
|
336
|
+
`TableColumn.style` and `header_style` can set a cell's background,
|
|
337
|
+
foreground, font, padding, and alignment. A header can also be a view.
|
|
338
|
+
|
|
339
|
+
Use `Table.style_token` for a theme's header, body, alternate rows,
|
|
340
|
+
cell defaults, and row separators. Fields set on `alternate_row` augment
|
|
341
|
+
the body style. A table's `row_style` callback can adjust the result for
|
|
342
|
+
each body row, such as adding a rule above a total. From there, column
|
|
343
|
+
overrides and `style_cell` refine each cell. A cell fill sits over the row
|
|
344
|
+
fill, and the rules draw over both. Use `separator=` on a column for a rule
|
|
345
|
+
at its trailing edge. At a shared row boundary, the following row's
|
|
346
|
+
`rule_above` takes precedence over the preceding row's `rule_below`.
|
|
347
|
+
|
|
348
|
+
Use distinct row and column keys if they can move across builds. The
|
|
349
|
+
[PowerPoint export guide](builds-and-export.md#export-tables-to-powerpoint)
|
|
350
|
+
covers native tables and the default shape export.
|
|
351
|
+
|
|
352
|
+
## Add shadows and preserve groups
|
|
353
|
+
|
|
354
|
+
Attach `.shadow()` to the view that should cast the shadow. In this example
|
|
355
|
+
the rounded background casts the shadow and the text sits above it. Moving
|
|
356
|
+
`.shadow(lift)` after `.background(surface)` uses the assembled view's
|
|
357
|
+
combined silhouette. Shadows can extend beyond a view's layout bounds,
|
|
358
|
+
while its measured size and annotation anchors stay in place.
|
|
359
|
+
|
|
360
|
+
```python
|
|
361
|
+
from deckkit.effects import Shadow
|
|
362
|
+
from deckkit.themes import Color, SurfaceColor
|
|
363
|
+
from deckkit.units import pt
|
|
364
|
+
from deckkit.views import Rectangle, Text
|
|
365
|
+
from deckkit.views.semantic import Card
|
|
366
|
+
|
|
367
|
+
lift = Shadow.drop(color=Color("#142033"), opacity=0.18, radius=pt(8), y=pt(3))
|
|
368
|
+
surface = Rectangle(fill=SurfaceColor, corner_radius=pt(10))
|
|
369
|
+
badge = Text("Ready").padding(pt(8)).background(surface.shadow(lift))
|
|
370
|
+
card = Card(Text("Release complete")).style(shadow=lift)
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
`Card` applies its `shadow` style field to the default recipe's surface. Set
|
|
374
|
+
that field through `Card.style_token` for a shared theme treatment.
|
|
375
|
+
`.shadow()` also accepts a `DesignToken[Shadow]`, and `Shadow.color` accepts
|
|
376
|
+
a color token. Canvas elements such as `Rect` and `CanvasText` accept the
|
|
377
|
+
same shadow values via their `shadow` argument.
|
|
378
|
+
|
|
379
|
+
Use `.grouped().key("results")` on a composite when its contents should
|
|
380
|
+
stay together in the exported file. PowerPoint recipients can select it
|
|
381
|
+
as a group and edit its children. Keyed children can still be revealed or
|
|
382
|
+
moved in builds. PowerPoint also creates an editable group when a native
|
|
383
|
+
shadow spans multiple shapes.
|
|
384
|
+
See [Builds and export](builds-and-export.md#export-shadows-to-powerpoint)
|
|
385
|
+
for PowerPoint shadow support.
|
|
386
|
+
|
|
387
|
+
## Set text
|
|
388
|
+
|
|
389
|
+
`Text` accepts plain strings or structured `TextLine` and `TextSpan` values.
|
|
390
|
+
Use spans to style parts of a line, and a line background when the highlight
|
|
391
|
+
should follow every wrapped line. The default wrapped flow uses whitespace
|
|
392
|
+
breaks. Choose `flow="verbatim"` to preserve spaces and line breaks. If text
|
|
393
|
+
is too long for the available width, adjust the text, layout, or typography
|
|
394
|
+
explicitly.
|
|
395
|
+
|
|
396
|
+
See [Present source code and terminal output](presenting-code.md) for syntax
|
|
397
|
+
highlighting, code marks, diffs, and animated walkthroughs.
|