add blocks
This commit is contained in:
parent
48ca5a96e6
commit
857fcd9897
47
src/core/BuilderBlock/Block/Bootstrap/AlertBlock.php
Normal file
47
src/core/BuilderBlock/Block/Bootstrap/AlertBlock.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Core\BuilderBlock\Block\Bootstrap;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
#[AutoconfigureTag('builder_block.widget')]
|
||||
class AlertBlock extends BootstrapBlock
|
||||
{
|
||||
public function __construct(protected TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$options = [];
|
||||
|
||||
foreach ([
|
||||
'Primary' => 'primary',
|
||||
'Secondary' => 'secondary',
|
||||
'Info' => 'info',
|
||||
'Success' => 'success',
|
||||
'Danger' => 'danger',
|
||||
'Warning' => 'warning',
|
||||
'Light' => 'light',
|
||||
'Dark' => 'dark',
|
||||
] as $k => $v) {
|
||||
$options[] = [
|
||||
'text' => $this->translator->trans($k),
|
||||
'value' => $v,
|
||||
];
|
||||
}
|
||||
|
||||
$this
|
||||
->setName('bsAlert')
|
||||
->setLabel('Alert')
|
||||
->setOrder(4)
|
||||
->setIsContainer(true)
|
||||
->setIcon('<i class="fas fa-exclamation-circle"></i>')
|
||||
->setTemplate('@Core/builder_block/bootstrap/alert.html.twig')
|
||||
->addSetting(name: 'level', label: 'Level', type: 'select', extraOptions: ['options' => $options])
|
||||
;
|
||||
}
|
||||
}
|
26
src/core/BuilderBlock/Block/Editor/TextareaBlock.php
Normal file
26
src/core/BuilderBlock/Block/Editor/TextareaBlock.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Core\BuilderBlock\Block\Editor;
|
||||
|
||||
use App\Core\BuilderBlock\BuilderBlock;
|
||||
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||
|
||||
#[AutoconfigureTag('builder_block.widget')]
|
||||
class TextareaBlock extends EditorBlock
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('textarea')
|
||||
->setLabel('Text')
|
||||
->setIsContainer(false)
|
||||
->setIcon('<i class="fas fa-pencil-alt"></i>')
|
||||
->setTemplate('@Core/builder_block/editor/textarea.html.twig')
|
||||
->addSetting(name: 'nl2br', label: 'Insert line breaks', type: 'checkbox', default: true)
|
||||
->addSetting(name: 'allowHtml', label: 'Allow HTML', type: 'checkbox', default: false)
|
||||
->addSetting(name: 'value', type: 'textarea')
|
||||
;
|
||||
}
|
||||
}
|
|
@ -229,3 +229,6 @@
|
|||
"Medium": "Moyen"
|
||||
"Large": "Large"
|
||||
"Extra large": "Très large"
|
||||
"Level": "Niveau"
|
||||
"Insert line breaks": "Ajouter les retours chariot"
|
||||
'Allow HTML': "Autoriser l'HTML"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<div class="alert {% if settings.level|default(null) %}alert-{{ settings.level }}{% endif %}" id="{{ id }}">
|
||||
{% for item in children %}
|
||||
{{ item|block_to_html }}
|
||||
{% endfor %}
|
||||
</div>
|
|
@ -0,0 +1,13 @@
|
|||
{%- if settings.nl2br|default(null) -%}
|
||||
{% if settings.allowHtml|default(null) %}
|
||||
{{- settings.value|default(null)|raw|nl2br -}}
|
||||
{%- else -%}
|
||||
{{- settings.value|default(null)|nl2br -}}
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
{% if settings.allowHtml|default(null) %}
|
||||
{{- settings.value|default(null)|raw -}}
|
||||
{%- else -%}
|
||||
{{- settings.value|default(null) -}}
|
||||
{%- endif -%}
|
||||
{% endif %}
|
Loading…
Reference in a new issue