cjm-fasthtml-card-stack 0.0.1__py3-none-any.whl → 0.0.3__py3-none-any.whl
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.
- cjm_fasthtml_card_stack/__init__.py +1 -1
- cjm_fasthtml_card_stack/components/__init__.py +0 -0
- cjm_fasthtml_card_stack/components/controls.py +115 -0
- cjm_fasthtml_card_stack/components/progress.py +44 -0
- cjm_fasthtml_card_stack/components/states.py +107 -0
- cjm_fasthtml_card_stack/components/viewport.py +320 -0
- cjm_fasthtml_card_stack/core/__init__.py +0 -0
- cjm_fasthtml_card_stack/core/button_ids.py +69 -0
- cjm_fasthtml_card_stack/core/config.py +48 -0
- cjm_fasthtml_card_stack/core/constants.py +41 -0
- cjm_fasthtml_card_stack/core/html_ids.py +94 -0
- cjm_fasthtml_card_stack/core/models.py +53 -0
- cjm_fasthtml_card_stack/helpers/__init__.py +0 -0
- cjm_fasthtml_card_stack/helpers/focus.py +72 -0
- cjm_fasthtml_card_stack/js/__init__.py +0 -0
- cjm_fasthtml_card_stack/js/core.py +303 -0
- cjm_fasthtml_card_stack/js/navigation.py +37 -0
- cjm_fasthtml_card_stack/js/scroll.py +76 -0
- cjm_fasthtml_card_stack/js/viewport.py +124 -0
- cjm_fasthtml_card_stack/keyboard/__init__.py +0 -0
- cjm_fasthtml_card_stack/keyboard/actions.py +200 -0
- cjm_fasthtml_card_stack/routes/__init__.py +0 -0
- cjm_fasthtml_card_stack/routes/handlers.py +158 -0
- cjm_fasthtml_card_stack/routes/router.py +150 -0
- {cjm_fasthtml_card_stack-0.0.1.dist-info → cjm_fasthtml_card_stack-0.0.3.dist-info}/METADATA +32 -24
- cjm_fasthtml_card_stack-0.0.3.dist-info/RECORD +36 -0
- {cjm_fasthtml_card_stack-0.0.1.dist-info → cjm_fasthtml_card_stack-0.0.3.dist-info}/top_level.txt +1 -0
- demos/__init__.py +0 -0
- demos/basic.py +115 -0
- demos/bottom.py +104 -0
- demos/data.py +29 -0
- demos/shared.py +153 -0
- cjm_fasthtml_card_stack-0.0.1.dist-info/RECORD +0 -8
- {cjm_fasthtml_card_stack-0.0.1.dist-info → cjm_fasthtml_card_stack-0.0.3.dist-info}/WHEEL +0 -0
- {cjm_fasthtml_card_stack-0.0.1.dist-info → cjm_fasthtml_card_stack-0.0.3.dist-info}/entry_points.txt +0 -0
- {cjm_fasthtml_card_stack-0.0.1.dist-info → cjm_fasthtml_card_stack-0.0.3.dist-info}/licenses/LICENSE +0 -0
demos/shared.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""Shared utilities for card stack demos."""
|
|
2
|
+
|
|
3
|
+
from fasthtml.common import Div, H1, P, Span
|
|
4
|
+
|
|
5
|
+
from cjm_fasthtml_daisyui.utilities.semantic_colors import bg_dui, text_dui
|
|
6
|
+
from cjm_fasthtml_tailwind.utilities.spacing import p, m
|
|
7
|
+
from cjm_fasthtml_tailwind.utilities.sizing import container, max_w
|
|
8
|
+
from cjm_fasthtml_tailwind.utilities.typography import font_size, font_weight
|
|
9
|
+
from cjm_fasthtml_tailwind.utilities.flexbox_and_grid import (
|
|
10
|
+
flex_display, items, justify, gap
|
|
11
|
+
)
|
|
12
|
+
from cjm_fasthtml_tailwind.utilities.borders import rounded
|
|
13
|
+
from cjm_fasthtml_tailwind.core.base import combine_classes
|
|
14
|
+
|
|
15
|
+
from cjm_fasthtml_keyboard_navigation.core.manager import ZoneManager
|
|
16
|
+
from cjm_fasthtml_keyboard_navigation.components.system import render_keyboard_system
|
|
17
|
+
|
|
18
|
+
from cjm_fasthtml_card_stack.components.viewport import render_viewport
|
|
19
|
+
from cjm_fasthtml_card_stack.components.controls import (
|
|
20
|
+
render_width_slider, render_scale_slider, render_card_count_select
|
|
21
|
+
)
|
|
22
|
+
from cjm_fasthtml_card_stack.components.progress import render_progress_indicator
|
|
23
|
+
from cjm_fasthtml_card_stack.js.core import generate_card_stack_js
|
|
24
|
+
from cjm_fasthtml_card_stack.keyboard.actions import (
|
|
25
|
+
create_card_stack_focus_zone, create_card_stack_nav_actions,
|
|
26
|
+
build_card_stack_url_map, render_card_stack_action_buttons
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def build_keyboard_system(config, btn_ids, ids, urls):
|
|
31
|
+
"""Build keyboard navigation system for a card stack."""
|
|
32
|
+
zone = create_card_stack_focus_zone(ids)
|
|
33
|
+
nav_actions = create_card_stack_nav_actions(zone.id, btn_ids, config)
|
|
34
|
+
manager = ZoneManager(zones=(zone,), actions=nav_actions)
|
|
35
|
+
|
|
36
|
+
url_map = build_card_stack_url_map(btn_ids, urls)
|
|
37
|
+
target_map = {btn_id: f"#{ids.card_stack}" for btn_id in url_map}
|
|
38
|
+
swap_map = {btn_id: "none" for btn_id in url_map}
|
|
39
|
+
include_map = {btn_id: f"#{ids.focused_index_input}" for btn_id in url_map}
|
|
40
|
+
|
|
41
|
+
return render_keyboard_system(
|
|
42
|
+
manager,
|
|
43
|
+
url_map=url_map,
|
|
44
|
+
target_map=target_map,
|
|
45
|
+
swap_map=swap_map,
|
|
46
|
+
include_map=include_map,
|
|
47
|
+
show_hints=False,
|
|
48
|
+
include_state_inputs=True,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def render_demo_page(
|
|
53
|
+
title,
|
|
54
|
+
description,
|
|
55
|
+
state_getter,
|
|
56
|
+
items_getter,
|
|
57
|
+
render_card,
|
|
58
|
+
config,
|
|
59
|
+
ids,
|
|
60
|
+
btn_ids,
|
|
61
|
+
urls,
|
|
62
|
+
container_id,
|
|
63
|
+
progress_label="Item",
|
|
64
|
+
):
|
|
65
|
+
"""Render a standard card stack demo page.
|
|
66
|
+
|
|
67
|
+
Returns a page_content() callable for use with handle_htmx_request.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
def page_content():
|
|
71
|
+
state = state_getter()
|
|
72
|
+
card_items = items_getter()
|
|
73
|
+
|
|
74
|
+
kb_system = build_keyboard_system(config, btn_ids, ids, urls)
|
|
75
|
+
|
|
76
|
+
js_script = generate_card_stack_js(
|
|
77
|
+
ids=ids,
|
|
78
|
+
button_ids=btn_ids,
|
|
79
|
+
config=config,
|
|
80
|
+
urls=urls,
|
|
81
|
+
container_id=container_id,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return Div(
|
|
85
|
+
# Visual content container (used for viewport height calculation)
|
|
86
|
+
Div(
|
|
87
|
+
# Header
|
|
88
|
+
Div(
|
|
89
|
+
H1(title, cls=combine_classes(font_size._2xl, font_weight.bold)),
|
|
90
|
+
P(description,
|
|
91
|
+
cls=combine_classes(text_dui.base_content, font_size.sm, m.b(4))),
|
|
92
|
+
cls=m.b(2)
|
|
93
|
+
),
|
|
94
|
+
|
|
95
|
+
# Controls row
|
|
96
|
+
Div(
|
|
97
|
+
Div(
|
|
98
|
+
render_card_count_select(config, ids, state.visible_count),
|
|
99
|
+
cls=combine_classes(flex_display, items.center, gap(2)),
|
|
100
|
+
),
|
|
101
|
+
Div(
|
|
102
|
+
Span("Width:", cls=combine_classes(font_size.sm, text_dui.base_content)),
|
|
103
|
+
render_width_slider(config, ids, state.card_width),
|
|
104
|
+
cls=combine_classes(flex_display, items.center, gap(2)),
|
|
105
|
+
),
|
|
106
|
+
Div(
|
|
107
|
+
Span("Scale:", cls=combine_classes(font_size.sm, text_dui.base_content)),
|
|
108
|
+
render_scale_slider(config, ids, state.card_scale),
|
|
109
|
+
cls=combine_classes(flex_display, items.center, gap(2)),
|
|
110
|
+
),
|
|
111
|
+
cls=combine_classes(
|
|
112
|
+
flex_display, items.center, justify.between,
|
|
113
|
+
gap(4), m.b(2), p(2),
|
|
114
|
+
bg_dui.base_200, rounded.lg,
|
|
115
|
+
)
|
|
116
|
+
),
|
|
117
|
+
|
|
118
|
+
# Viewport
|
|
119
|
+
render_viewport(
|
|
120
|
+
card_items=card_items,
|
|
121
|
+
state=state,
|
|
122
|
+
config=config,
|
|
123
|
+
render_card=render_card,
|
|
124
|
+
ids=ids,
|
|
125
|
+
urls=urls,
|
|
126
|
+
),
|
|
127
|
+
|
|
128
|
+
# Footer
|
|
129
|
+
Div(
|
|
130
|
+
render_progress_indicator(
|
|
131
|
+
state.focused_index, len(card_items), ids, label=progress_label
|
|
132
|
+
),
|
|
133
|
+
cls=combine_classes(flex_display, justify.center, m.t(2))
|
|
134
|
+
),
|
|
135
|
+
|
|
136
|
+
id=container_id,
|
|
137
|
+
),
|
|
138
|
+
|
|
139
|
+
# Keyboard system
|
|
140
|
+
kb_system.script,
|
|
141
|
+
kb_system.hidden_inputs,
|
|
142
|
+
kb_system.action_buttons,
|
|
143
|
+
|
|
144
|
+
# Hidden buttons for JS-callback-triggered actions
|
|
145
|
+
render_card_stack_action_buttons(btn_ids, urls, ids),
|
|
146
|
+
|
|
147
|
+
# Card stack JS
|
|
148
|
+
js_script,
|
|
149
|
+
|
|
150
|
+
cls=combine_classes(container, max_w._6xl, m.x.auto, p(4))
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
return page_content
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
cjm_fasthtml_card_stack/__init__.py,sha256=sXLh7g3KC4QCFxcZGBTpG2scR7hmmBsMjq6LqRptkRg,22
|
|
2
|
-
cjm_fasthtml_card_stack/_modidx.py,sha256=jYNj6LPbD5I8yDghD3Lx9XWsDnWqc_oNCESguSF8blA,25105
|
|
3
|
-
cjm_fasthtml_card_stack-0.0.1.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
|
|
4
|
-
cjm_fasthtml_card_stack-0.0.1.dist-info/METADATA,sha256=PDmhCLd0lgo4dGhsEojEvH6TV0bguLQDC9YnRA3Zwzg,36798
|
|
5
|
-
cjm_fasthtml_card_stack-0.0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
6
|
-
cjm_fasthtml_card_stack-0.0.1.dist-info/entry_points.txt,sha256=qTw6qaijkEUH1AcPQhpTqJ8TPiUSMnpn0Cvg4hXoX90,68
|
|
7
|
-
cjm_fasthtml_card_stack-0.0.1.dist-info/top_level.txt,sha256=y6h84kPxytZIWTD4ITK2Gsi40KivBsEfSe8131fIoR4,24
|
|
8
|
-
cjm_fasthtml_card_stack-0.0.1.dist-info/RECORD,,
|
|
File without changes
|
{cjm_fasthtml_card_stack-0.0.1.dist-info → cjm_fasthtml_card_stack-0.0.3.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{cjm_fasthtml_card_stack-0.0.1.dist-info → cjm_fasthtml_card_stack-0.0.3.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|