Expose every Bulma variant as a choosable option, not just a curated few
Adds a shared bulma_variants.py (color/size option lists) and expands BULMA_*_CONTROLS in bulma_controls.py to cover each component's full modifier set: Bouton (colour incl. white/light/dark/black/text, light-shade toggle, size, rounded, outlined, inverted, static, loading, fullwidth), Titre (Bulma size is-1..is-6 independent of heading level, is-spaced), Jauge (size), Tableau (bordered/fullwidth/striped/hoverable/narrow, now toggleable instead of hardcoded), Onglets (alignment, boxed/toggle/toggle-rounded style, size, fullwidth), and every form field — champ_texte/email/mot_de_passe, zone_texte, liste_deroulante (colour, size, rounded, static). render_select.py/render_onglets.py/render_jauge.py now redirect the merged "class" from _visible_attrs to the actual Bulma sub-element (the .select wrapper, the .tabs div, the <progress> tag) instead of the outer positioning wrapper, since that's what needs to carry the modifier classes. Also fixed a real latent bug found while wiring this up: a checkbox control with default=True (e.g. Tableau's "Première ligne = en-tête") was never actually applied on a freshly created element — default_style_and_attributes unconditionally skipped ALL checkbox types at creation, so the panel showed it checked while the element itself had nothing set. Now a checkbox's default=True is frozen at creation like any other meaningful default; default=False (the common case) is unaffected. Verified end to end: every widget's variant controls save and render the right class tokens (spot-checked titre/tableau/onglets/champ_texte/liste_deroulante/jauge), full suite green (89 passed).
This commit is contained in:
@@ -138,8 +138,10 @@ def _render_jauge(el, meta, slug, children_map=None, ctx=None, parent_flex_direc
|
||||
# donnée" — sinon la jauge resterait figée sur sa valeur de départ après
|
||||
# un changement, exactement comme il fallait déjà repérer "repeaterItem"
|
||||
# pour les Répéteurs (voir 1.1/1.2).
|
||||
extra_classes = " ".join(v for k, v in attrs.items() if k.startswith("_class_") and v)
|
||||
bar_class = html_lib.escape((f"progress jaugeBar {extra_classes}").strip())
|
||||
bar = (
|
||||
f'<progress class="progress jaugeBar" value="{percent}" max="100" '
|
||||
f'<progress class="{bar_class}" value="{percent}" max="100" '
|
||||
f'style="--bulma-progress-value-background-color:{fill_color}; --bulma-progress-bar-background-color:#1c2130; '
|
||||
f'margin:0; border-radius:6px; transition:background-color .3s ease;">{percent}%</progress>'
|
||||
)
|
||||
|
||||
@@ -21,6 +21,10 @@ def _render_onglets(el, meta, slug, children_map=None, ctx=None, parent_flex_dir
|
||||
|
||||
tabs = (children_map or {}).get(el["id"], [])
|
||||
attrs = _visible_attrs(el, meta, ctx)
|
||||
# Les variantes Bulma (alignement/style/taille... voir BULMA_TABS_CONTROLS)
|
||||
# calculées par _visible_attrs atterrissent dans "class" — c'est le
|
||||
# <div class="tabs"> qui doit les porter, pas ce wrapper de positionnement.
|
||||
tabs_extra_classes = attrs.pop("class", "")
|
||||
style = _style_string(el, " display:flex; flex-direction:column;", parent_flex_direction)
|
||||
group_id = _auto_id(el)
|
||||
|
||||
@@ -53,9 +57,10 @@ def _render_onglets(el, meta, slug, children_map=None, ctx=None, parent_flex_dir
|
||||
f'{tab_html}</div>'
|
||||
)
|
||||
|
||||
tabs_class = html_lib.escape(("tabs " + tabs_extra_classes).strip())
|
||||
return (
|
||||
f'<div {_attr_string(attrs, style)}>'
|
||||
f'<div class="tabs"><ul>{"".join(bar_items)}</ul></div>'
|
||||
f'<div class="{tabs_class}"><ul>{"".join(bar_items)}</ul></div>'
|
||||
f'<div class="forgeTabPanels" style="flex:1 1 auto; min-height:0;">{"".join(panels)}</div>'
|
||||
f"</div>"
|
||||
)
|
||||
|
||||
@@ -15,6 +15,11 @@ def _render_select(el, meta, slug=None, children_map=None, ctx=None, parent_flex
|
||||
# l'élément (comme tous les autres widgets), le <select> reste à
|
||||
# l'intérieur avec ses propres attributs de formulaire (name, required).
|
||||
outer_attrs = _visible_attrs(el, meta, ctx)
|
||||
# Les variantes Bulma (couleur/taille/arrondi... voir BULMA_FIELD_CONTROLS)
|
||||
# calculées par _visible_attrs atterrissent normalement dans "class" —
|
||||
# ici c'est le <div class="select"> qui doit les porter, pas le <select>
|
||||
# ni le wrapper de positionnement, donc on les redirige à la main.
|
||||
bulma_classes = outer_attrs.get("class", "")
|
||||
select_attrs = {k: v for k, v in outer_attrs.items() if k not in ("id", "class", "data-element-id", "data-anim-target")}
|
||||
wrapper_attrs = {k: v for k, v in outer_attrs.items() if k in ("id", "data-element-id", "data-anim-target")}
|
||||
style = _style_string(el, " display:flex;", parent_flex_direction)
|
||||
@@ -22,4 +27,5 @@ def _render_select(el, meta, slug=None, children_map=None, ctx=None, parent_flex
|
||||
options = [o.strip() for o in content.split("\n") if o.strip()]
|
||||
opts_html = "".join(f'<option value="{html_lib.escape(o)}">{html_lib.escape(o)}</option>' for o in options)
|
||||
select_html = f'<select {_attr_string(select_attrs, "")}>{opts_html}</select>'
|
||||
return f'<div {_attr_string(wrapper_attrs, style)}><div class="select is-fullwidth">{select_html}</div></div>'
|
||||
select_wrap_class = html_lib.escape(("select is-fullwidth " + bulma_classes).strip())
|
||||
return f'<div {_attr_string(wrapper_attrs, style)}><div class="{select_wrap_class}">{select_html}</div></div>'
|
||||
|
||||
Reference in New Issue
Block a user