- Jauge now renders a real <progress class="progress"> instead of a hand-built pair of absolutely-positioned divs. The bas/haut color interpolation still works, set via Bulma's own --bulma-progress-value-background-color CSS custom property rather than fighting the class. - Onglets' tab strip is now genuine Bulma tabs markup (tabs > ul > li, is-active on the li) instead of custom forgeTabBar/forgeTabBtn classes; forgeShowTab (duplicated in screen_edit.html and play.html) now toggles is-active to match. - Champ texte/email/mot de passe get class="input", Zone de texte gets class="textarea", Case à cocher/Bouton radio's existing <label> wrapper gets class="checkbox"/"radio" (Bulma's own convention — the structure already matched, just needed the class), Liste déroulante is wrapped in Bulma's required <div class="select"> (a bare class on the <select> itself has zero effect in Bulma), Tableau gets class="table is-bordered is-fullwidth" with the per-cell inline borders removed so Bulma's own table styling applies. - Removed the now-dead .forgeTabBar/.forgeTabBtn CSS. Updated tests/test_jauge.py and tests/test_onglets_widget.py assertions to match the new markup (value="X" attribute instead of width:X% inline style, --bulma-progress-value-background-color instead of background-color, forgeShowTab(this) marker instead of the removed forgeTabBtn class) — same behavior, different rendering mechanism. Full suite green (89 passed), verified end to end against the real "test" project via the actual /play route.
62 lines
2.8 KiB
Python
62 lines
2.8 KiB
Python
import html as html_lib
|
|
|
|
from .visible_attrs import _visible_attrs
|
|
from .style_string import _style_string
|
|
from .parent_flex_direction import _parent_flex_direction
|
|
from .auto_id import _auto_id
|
|
from .attr_string import _attr_string
|
|
|
|
|
|
def _render_onglets(el, meta, slug, children_map=None, ctx=None, parent_flex_direction=None):
|
|
"""Élément à onglets : chaque onglet est un vrai conteneur posé comme
|
|
enfant (voir screens/elements/add_tab.py) — ça réutilise tel quel tout
|
|
ce qui existe déjà pour un conteneur normal (ajouter du contenu dedans
|
|
via "Ajouter DANS ce conteneur", le renommer pour changer le libellé
|
|
affiché sur l'onglet, le supprimer via la poubelle standard) plutôt que
|
|
d'inventer un stockage séparé pour les onglets. Un seul panneau visible
|
|
à la fois, basculé par un petit script embarqué qui marche aussi bien
|
|
dans l'éditeur qu'en jeu (voir forgeShowTab dans screen_edit.html et
|
|
play.html)."""
|
|
from .render_element_html import render_element_html
|
|
|
|
tabs = (children_map or {}).get(el["id"], [])
|
|
attrs = _visible_attrs(el, meta, ctx)
|
|
style = _style_string(el, " display:flex; flex-direction:column;", parent_flex_direction)
|
|
group_id = _auto_id(el)
|
|
|
|
if not tabs:
|
|
return (
|
|
f'<div {_attr_string(attrs, style)}>'
|
|
f'<em style="opacity:.6;">Onglets — ajoute au moins un onglet dans ses réglages.</em></div>'
|
|
)
|
|
|
|
flex_dir = _parent_flex_direction(el)
|
|
bar_items = []
|
|
panels = []
|
|
for i, tab in enumerate(tabs):
|
|
label = tab.get("name") or f"Onglet {i + 1}"
|
|
active = i == 0
|
|
tab_html = render_element_html(tab, slug, children_map, ctx, parent_flex_direction=flex_dir)
|
|
target_id = f"tabpanel-{tab['id']}"
|
|
# <li> Bulma natif ("tabs" > "ul" > "li", "is-active" sur le <li> —
|
|
# pas le <a> — pour l'onglet en cours) : le <li> porte le clic ET les
|
|
# data-attributes ciblés par forgeShowTab (voir screen_edit.html /
|
|
# play.html), le <a> imbriqué n'est là que pour le rendu visuel Bulma.
|
|
bar_items.append(
|
|
f'<li class="{"is-active" if active else ""}" '
|
|
f'data-tab-btn="{group_id}" data-tab-target="{target_id}" '
|
|
f'onclick="forgeShowTab(this)"><a>{html_lib.escape(str(label))}</a></li>'
|
|
)
|
|
hidden_style = "" if active else ' style="display:none;"'
|
|
panels.append(
|
|
f'<div class="forgeTabPanel" id="{target_id}" data-tab-group="{group_id}"{hidden_style}>'
|
|
f'{tab_html}</div>'
|
|
)
|
|
|
|
return (
|
|
f'<div {_attr_string(attrs, style)}>'
|
|
f'<div class="tabs"><ul>{"".join(bar_items)}</ul></div>'
|
|
f'<div class="forgeTabPanels" style="flex:1 1 auto; min-height:0;">{"".join(panels)}</div>'
|
|
f"</div>"
|
|
)
|