Skip to content

Commit

Permalink
feat(separator): Add style property on Separator UiElement
Browse files Browse the repository at this point in the history
  • Loading branch information
welcoMattic committed Nov 4, 2024
1 parent 836a40d commit 9339180
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/Form/Type/UiElement/SeparatorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/translations/messages.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/translations/messages.hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/translations/messages.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/translations/messages.pl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
4 changes: 4 additions & 0 deletions src/Resources/views/Admin/UiElement/separator.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
type: separator
element fields :
hidden
style
#}
<div class="ui {% if element is not empty and element.hidden is not empty %}hidden{% endif %} divider"></div>
{% if element.style is defined and element is not empty %}
<div class="ui label">{{ ('monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.separator.field.style.choices.' ~ element.style)|trans }}</div>
{% endif %}
8 changes: 7 additions & 1 deletion src/Resources/views/Shop/UiElement/separator.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@
type: separator
element fields :
hidden
style
#}
<div class="ui {% if element.hidden is not empty %}hidden{% endif %} divider"></div>
{% 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;',
} %}
<div class="ui {% if element.hidden is not empty %}hidden{% endif %} divider" {% if element.style is defined and element.style is not empty %}style="{{ borderStyleMap[element.style] }}"{% endif %}></div>

0 comments on commit 9339180

Please sign in to comment.