From 93391809070e85b17aeb8b8dc9419c01962b4067 Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Mon, 4 Nov 2024 11:03:22 +0100 Subject: [PATCH] feat(separator): Add style property on Separator UiElement --- src/Form/Type/UiElement/SeparatorType.php | 15 +++++++++++++++ src/Resources/translations/messages.en.yml | 6 ++++++ src/Resources/translations/messages.es.yml | 6 ++++++ src/Resources/translations/messages.fr.yml | 6 ++++++ src/Resources/translations/messages.hr.yml | 6 ++++++ src/Resources/translations/messages.nl.yml | 6 ++++++ src/Resources/translations/messages.pl.yaml | 6 ++++++ .../views/Admin/UiElement/separator.html.twig | 4 ++++ .../views/Shop/UiElement/separator.html.twig | 8 +++++++- 9 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/Form/Type/UiElement/SeparatorType.php b/src/Form/Type/UiElement/SeparatorType.php index e3c6632b..65ec80d0 100644 --- a/src/Form/Type/UiElement/SeparatorType.php +++ b/src/Form/Type/UiElement/SeparatorType.php @@ -15,12 +15,19 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; class SeparatorType extends AbstractType { + public const SOLID_STYLE = 'solid'; + + public const DASHED_STYLE = 'dashed'; + + public const DOTTED_STYLE = 'dotted'; + /** * @inheritdoc */ @@ -31,6 +38,14 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.separator.field.hidden', 'required' => false, ]) + ->add('style', ChoiceType::class, [ + 'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.separator.field.style.label', + 'choices' => [ + 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.separator.field.style.choices.solid' => self::SOLID_STYLE, + 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.separator.field.style.choices.dashed' => self::DASHED_STYLE, + 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.separator.field.style.choices.dotted' => self::DOTTED_STYLE, + ], + ]) ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { /** @var array $data */ $data = $event->getData(); diff --git a/src/Resources/translations/messages.en.yml b/src/Resources/translations/messages.en.yml index a71e472a..b863c0eb 100644 --- a/src/Resources/translations/messages.en.yml +++ b/src/Resources/translations/messages.en.yml @@ -73,6 +73,12 @@ monsieurbiz_richeditor_plugin: description: 'A separator element. The separator can be a hidden one.' field: hidden: 'Hidden separator' + style: + label: 'Style' + choices: + solid: 'Solid' + dashed: 'Dashed' + dotted: 'Dotted' monsieurbiz.button: title: 'Button Element' short_description: 'A button with a text and a link.' diff --git a/src/Resources/translations/messages.es.yml b/src/Resources/translations/messages.es.yml index 529000dd..c504a776 100644 --- a/src/Resources/translations/messages.es.yml +++ b/src/Resources/translations/messages.es.yml @@ -73,6 +73,12 @@ monsieurbiz_richeditor_plugin: description: 'Un elemento separador. El separador puede ser uno oculto.' field: hidden: 'Separador oculto' + style: + label: 'Estilo' + choices: + solid: 'Sólido' + dashed: 'Punteado' + dotted: 'Punteado' monsieurbiz.button: title: 'Elemento de botón' short_description: 'Un botón con un texto y un enlace.' diff --git a/src/Resources/translations/messages.fr.yml b/src/Resources/translations/messages.fr.yml index d8531027..6197ac29 100644 --- a/src/Resources/translations/messages.fr.yml +++ b/src/Resources/translations/messages.fr.yml @@ -73,6 +73,12 @@ monsieurbiz_richeditor_plugin: description: 'Une lame permettant de faire séparateur. Le séparateur peut être caché.' field: hidden: 'Séparateur caché' + style: + label: 'Style' + choices: + solid: 'Solide' + dashed: 'Pointillé' + dotted: 'Pointé' monsieurbiz.button: title: 'Lame Bouton' short_description: 'Un bouton avec un texte et un lien.' diff --git a/src/Resources/translations/messages.hr.yml b/src/Resources/translations/messages.hr.yml index a5ccdbbb..137f42e2 100644 --- a/src/Resources/translations/messages.hr.yml +++ b/src/Resources/translations/messages.hr.yml @@ -73,6 +73,12 @@ monsieurbiz_richeditor_plugin: description: 'Vidljivi ili nevidljivi element koji se nalazi između dva druga elementa i tako ih razdvaja.' field: hidden: 'Skriveni razdjelnik' + style: + label: 'Stil' + choices: + solid: 'Solidan' + dashed: 'Isprekidan' + dotted: 'Točkast' monsieurbiz.button: title: 'Gumb' short_description: 'Gumb s tekstom i linkom.' diff --git a/src/Resources/translations/messages.nl.yml b/src/Resources/translations/messages.nl.yml index 02548075..66be87f3 100644 --- a/src/Resources/translations/messages.nl.yml +++ b/src/Resources/translations/messages.nl.yml @@ -55,6 +55,12 @@ monsieurbiz_richeditor_plugin: description: 'Een scheidingselement dat optioneel verborgen kan zijn.' field: hidden: 'Verborgen scheidingselement' + style: + label: 'Stijl' + choices: + solid: 'Solide' + dashed: 'Gestippeld' + dotted: 'Gepunt' monsieurbiz.button: title: 'Knop' short_description: 'Een knop met tekst en een link.' diff --git a/src/Resources/translations/messages.pl.yaml b/src/Resources/translations/messages.pl.yaml index eb2dd89c..12554dd8 100644 --- a/src/Resources/translations/messages.pl.yaml +++ b/src/Resources/translations/messages.pl.yaml @@ -73,6 +73,12 @@ monsieurbiz_richeditor_plugin: description: 'Element separatora. Separator może być ukryty.' field: hidden: 'Ukryty separator' + style: + label: 'Styl' + choices: + solid: 'Solidny' + dashed: 'Kreskowany' + dotted: 'Kropkowany' monsieurbiz.button: title: 'Element przycisku' short_description: 'Przycisk z tekstem i linkiem.' diff --git a/src/Resources/views/Admin/UiElement/separator.html.twig b/src/Resources/views/Admin/UiElement/separator.html.twig index 4ed5eb73..90a89a4f 100644 --- a/src/Resources/views/Admin/UiElement/separator.html.twig +++ b/src/Resources/views/Admin/UiElement/separator.html.twig @@ -3,5 +3,9 @@ type: separator element fields : hidden + style #}
+{% if element.style is defined and element is not empty %} +
{{ ('monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.separator.field.style.choices.' ~ element.style)|trans }}
+{% endif %} diff --git a/src/Resources/views/Shop/UiElement/separator.html.twig b/src/Resources/views/Shop/UiElement/separator.html.twig index 21c8fb86..162b3d9e 100644 --- a/src/Resources/views/Shop/UiElement/separator.html.twig +++ b/src/Resources/views/Shop/UiElement/separator.html.twig @@ -3,5 +3,11 @@ type: separator element fields : hidden + style #} -
+{% set borderStyleMap = { + (constant('MonsieurBiz\\SyliusRichEditorPlugin\\Form\\Type\\UiElement\\SeparatorType::SOLID_STYLE')): 'border-top: 1px solid; border-bottom: none;', + (constant('MonsieurBiz\\SyliusRichEditorPlugin\\Form\\Type\\UiElement\\SeparatorType::DOTTED_STYLE')): 'border-top: 1px dotted; border-bottom: none;', + (constant('MonsieurBiz\\SyliusRichEditorPlugin\\Form\\Type\\UiElement\\SeparatorType::DASHED_STYLE')): 'border-top: 1px dashed; border-bottom: none;', +} %} +