File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Dynamic/ComponentType/Types/TextImage.php
<?php
namespace App\Komma\Dynamic\ComponentType\Types;
use App\Komma\Dynamic\ComponentType\ComponentTypes;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\Documents;
use App\Komma\Kms\Core\Attributes\Models\ImageProperty;
use App\Komma\Kms\Core\Attributes\Models\SelectOption;
use App\Komma\Kms\Core\Attributes\OnOff;
use App\Komma\Kms\Core\Attributes\Select;
use App\Komma\Kms\Core\Attributes\TextArea;
use App\Komma\Kms\Core\Attributes\TextField;
class TextImage extends AbstractComponentType
{
//Set an id that corresponds to the ComponentTypes enum
protected $id = ComponentTypes::TEXT_IMAGE;
//Set icon and name
protected $name = 'text-image';
protected $translatableAttributes = ['text'];
public function __construct()
{
parent::__construct();
//Set the attributes
$this->attributes->push((new OnOff())
->setLabelText('Grey Background')
->setStyleClass('is-background-option')
->mapValueFrom(Attribute::ValueFromItself, 'grey_background')
);
$this->attributes->push((new TextField('label'))
->mapValueFrom(Attribute::ValueFromItself, 'label'));
$this->attributes->push((new TextArea())
->enableTinymceEditorOnClick()
// ->enableTinymceEditor()
->setLabelText('text')
->setPlaceholderText('Ex. Lorum ipsum')
->mapValueFrom(Attribute::ValueFromItself, 'text')
);
$this->attributes->push((new Documents())
->setLabelText('image')
->onlyAllowImages()
->setSubFolder('component_uploads')
->setMaxDocuments(5)
->setImageProperties([
(new ImageProperty())->setName('original')->setCropMethod(ImageProperty::Resize)->setWidth(2000),
(new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Resize)->setWidth(900),
(new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(600),
(new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(375),
])
->setSmallDragAndDropArea()
->mapValueFrom(Attribute::ValueFromItself, 'image') //Needed to sustain Attribute integrity.
);
$this->attributes->push((new OnOff())
->setLabelText('Reverse')
->mapValueFrom(Attribute::ValueFromItself, 'reversed')
);
$this->attributes->push((new OnOff())
->setLabelText('Filled buttons')
->mapValueFrom(Attribute::ValueFromItself, 'filled_button')
);
$appButtonOptions = collect([
(new SelectOption())->setValue(0)->setContent('Hide')->setHtmlContent('Hide'),
(new SelectOption())->setValue(1)->setContent('Show without cta')->setHtmlContent('Show without cta'),
(new SelectOption())->setValue(2)->setContent('Show with cta')->setHtmlContent('Show with cta'),
]);
$this->attributes->push((new Select())
->setLabelText('Show App buttons')
->setItems($appButtonOptions->toArray())
->mapValueFrom(Attribute::ValueFromItself, 'app_buttons')
);
// $this->attributes->push((new OnOff())
// ->setLabelText("Show App buttons")
// ->mapValueFrom(Attribute::ValueFromItself, 'app_buttons')
// );
$this->addButton();
$this->addButton('Button 2');
}
}