-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from monsieurbiz/feature/logo-collection-ui-ele…
…ment feat(ui-element): Add LogosUiElement
- Loading branch information
Showing
6 changed files
with
134 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz's SyliusUiElementsPlugin for Sylius. | ||
* (c) Monsieur Biz <[email protected]> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MonsieurBiz\SyliusUiElementsPlugin\Form\Type\UiElement; | ||
|
||
use MonsieurBiz\SyliusRichEditorPlugin\Attribute\AsUiElement; | ||
use MonsieurBiz\SyliusRichEditorPlugin\Attribute\TemplatesUiElement; | ||
use MonsieurBiz\SyliusUiElementsPlugin\Form\Type\ImageType; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
#[AsUiElement( | ||
code: 'monsieurbiz_ui_elements.logos_ui_element', | ||
icon: 'images', | ||
title: 'monsieurbiz_ui_elements.ui_element.logos_ui_element.title', | ||
description: 'monsieurbiz_ui_elements.ui_element.logos_ui_element.description', | ||
templates: new TemplatesUiElement( | ||
adminRender: '@MonsieurBizSyliusUiElementsPlugin/Admin/UiElement/logos_ui_element.html.twig', | ||
frontRender: '@MonsieurBizSyliusUiElementsPlugin/Front/UiElement/logos_ui_element.html.twig', | ||
), | ||
tags: [], | ||
)] | ||
class LogosUiElementType extends AbstractType | ||
{ | ||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add('title', TextType::class, [ | ||
'label' => 'monsieurbiz_ui_elements.common.fields.title', | ||
'required' => false, | ||
]) | ||
->add('logos', CollectionType::class, [ | ||
'label' => 'monsieurbiz_ui_elements.common.fields.logos', | ||
'entry_type' => ImageType::class, | ||
'entry_options' => [ | ||
'with_link' => false, | ||
'with_alignment' => false, | ||
], | ||
'allow_add' => true, | ||
'allow_delete' => true, | ||
'constraints' => [new Assert\Valid()], | ||
'attr' => [ | ||
'class' => 'ui segment secondary collection--flex', | ||
], | ||
]) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Resources/views/Admin/UiElement/logos_ui_element.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{# | ||
UI Element template | ||
type: logos_ui_element | ||
element fields: | ||
- title | ||
- logos | ||
- image | ||
- alt | ||
- title | ||
#} | ||
|
||
<div class="ui"> | ||
{% if element.title|default('') is not empty %} | ||
<div class="ui"> | ||
<span class="ui huge header">{{ element.title }}</span> | ||
</div> | ||
{% endif %} | ||
<div class="ui grid"> | ||
{% for logo in element.logos %} | ||
<div class="four wide column"> | ||
<img src="{{ logo.image|imagine_filter('sylius_medium') }}" alt="{{ logo.alt|default('') }}" title="{{ logo.title|default('') }}" width="180"> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> |
25 changes: 25 additions & 0 deletions
25
src/Resources/views/Shop/UiElement/logos_ui_element.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{# | ||
UI Element template | ||
type: logos_ui_element | ||
element fields: | ||
- title | ||
- logos | ||
- image | ||
- alt | ||
- title | ||
#} | ||
|
||
<div class="ui"> | ||
{% if element.title|default('') is not empty %} | ||
<div class="ui"> | ||
<span class="ui huge header">{{ element.title }}</span> | ||
</div> | ||
{% endif %} | ||
<div class="ui grid"> | ||
{% for logo in element.logos %} | ||
<div class="four wide column"> | ||
<img src="{{ logo.image|imagine_filter('sylius_medium') }}" alt="{{ logo.alt|default('') }}" title="{{ logo.title|default('') }}" width="180"> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> |