From 3009e36cd2ba5f23bd80a1a5da55d398bd87c10c Mon Sep 17 00:00:00 2001 From: Mikael Meulle <mickael@meulle.com> Date: Wed, 11 Sep 2024 00:12:23 +0200 Subject: [PATCH] more niceness --- src/Element/ComponentPropsForm.php | 12 +++--------- src/Element/ComponentSlotsForm.php | 11 +++-------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/Element/ComponentPropsForm.php b/src/Element/ComponentPropsForm.php index 3a43701a7..e980d752c 100644 --- a/src/Element/ComponentPropsForm.php +++ b/src/Element/ComponentPropsForm.php @@ -74,18 +74,14 @@ class ComponentPropsForm extends ComponentFormBase { return $element; } $configuration = $element['#default_value']['props'] ?? []; - $is_first_prop = TRUE; $prop_heading = new FormattableMarkup("<p><strong>@title</strong></p>", ["@title" => t("Props")]); + $element[] = [ + '#markup' => $prop_heading, + ]; foreach ($props as $prop_id => $prop) { if ($prop_id === 'variant') { continue; } - if ($is_first_prop) { - $element[] = [ - '#markup' => $prop_heading, - ]; - $is_first_prop = FALSE; - } $prop_type = $prop['ui_patterns']['type_definition']; $element[$prop_id] = [ '#type' => 'component_prop_form', @@ -95,8 +91,6 @@ class ComponentPropsForm extends ComponentFormBase { '#tag_filter' => $element['#tag_filter'], '#component_id' => $component->getPluginId(), '#prop_id' => $prop_id, - '#prefix' => "<div class='component-form-prop'>", - '#suffix' => "</div>", '#wrap' => TRUE, ]; } diff --git a/src/Element/ComponentSlotsForm.php b/src/Element/ComponentSlotsForm.php index 605083b29..b405123e1 100644 --- a/src/Element/ComponentSlotsForm.php +++ b/src/Element/ComponentSlotsForm.php @@ -72,15 +72,11 @@ class ComponentSlotsForm extends ComponentFormBase { } $contexts = $element['#source_contexts'] ?? []; $configuration = $element['#default_value']['slots'] ?? []; - $is_first_slot = TRUE; $slot_heading = new FormattableMarkup("<p><strong>@title</strong></p>", ["@title" => t("Slots")]); + $element[] = [ + '#markup' => $slot_heading, + ]; foreach ($component->metadata->slots as $slot_id => $slot) { - if ($is_first_slot) { - $element[] = [ - '#markup' => $slot_heading, - ]; - $is_first_slot = FALSE; - } $element[$slot_id] = [ '#title' => $slot['title'] ?? '', '#type' => 'component_slot_form', @@ -92,7 +88,6 @@ class ComponentSlotsForm extends ComponentFormBase { '#prefix' => "<div class='component-form-slot'>", '#suffix' => "</div>", ]; - } return $element; } -- GitLab