Stop zeroing out padding/margin/border-width on native-Bulma widgets
Every widget gets padding/margin/border-width reset to 0 inline at creation (needed for a free-positioning canvas, otherwise every <h1>/<ul>/<p> would carry the browser's default spacing) — but for a widget that carries an external class like Bulma's button/box (see fixed_attrs in registry.py), inline style always wins over the class, so this reset silently stripped Bulma's own padding and border, making them look nothing like the real components. Bouton/Conteneur/Titre now skip this reset for those three properties, letting Bulma's own box model show through until a value is actually customized. Also cleaned the frozen 0px values out of existing elements in the two live project databases (projects/test, projects/test-2) — only removed values that exactly matched the old frozen default, any genuinely customized non-zero padding/margin/border-width was left untouched.
This commit is contained in:
@@ -18,6 +18,18 @@ _PER_SIDE_KEYS = {
|
||||
"border-top-width", "border-right-width", "border-bottom-width", "border-left-width",
|
||||
}
|
||||
|
||||
# Réglages "tous les côtés" dont la valeur par défaut est 0 (donc PAS filtrée
|
||||
# par "default in (None, '')" ci-dessous) : figés à la création pour tout
|
||||
# widget "nu" (reset volontaire, indispensable sur un canevas en positionnement
|
||||
# libre — sans lui, chaque <h1>/<ul>/<p> arriverait avec les marges/paddings
|
||||
# par défaut du navigateur). Mais pour un widget qui porte déjà une classe
|
||||
# externe (ex. Bulma "button"/"box" — voir fixed_attrs dans registry.py), ce
|
||||
# reset à 0 écraserait en permanence le padding/la bordure propres à cette
|
||||
# classe (un bouton Bulma sans padding ne ressemble plus à un bouton) : on ne
|
||||
# les fige donc PAS pour ces widgets-là, exactement comme les couleurs sont
|
||||
# déjà exclues plus bas pour ne jamais imposer une valeur non demandée.
|
||||
_ZERO_DEFAULT_RESET_KEYS = {"padding", "margin", "border-width"}
|
||||
|
||||
|
||||
def default_style_and_attributes(widget_key):
|
||||
"""Calcule le style/attributs de DÉPART d'un élément fraîchement posé sur
|
||||
@@ -33,6 +45,7 @@ def default_style_and_attributes(widget_key):
|
||||
demandée. Voir save_element_controls.py pour la même règle appliquée
|
||||
aux modifications ultérieures via le panneau de propriétés."""
|
||||
meta = widget_meta(widget_key)
|
||||
is_native_class_widget = bool(meta.get("fixed_attrs", {}).get("class"))
|
||||
attributes, style = {}, {}
|
||||
for control in meta.get("controls", []):
|
||||
ctype = control["type"]
|
||||
@@ -43,6 +56,8 @@ def default_style_and_attributes(widget_key):
|
||||
# type de réglage (voir size_override_controls.py) — jamais une
|
||||
# vraie valeur par défaut à figer à la création.
|
||||
continue
|
||||
if is_native_class_widget and control["key"] in _ZERO_DEFAULT_RESET_KEYS:
|
||||
continue
|
||||
target = control.get("target")
|
||||
if not target or target == "content":
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user