<?php

namespace apexl\Io\modules\display\components;

use apexl\Io\modules\component\Collections\ComponentCollection;
use apexl\Io\modules\component\Collections\ComponentPropertyCollection;
use apexl\Io\modules\component\Component\Component;
use apexl\Io\modules\component\Factories\ComponentPropertyFactory;
use Arrayy\Type\StringCollection;

readonly class LinkTile extends Component
{
    public function __construct(
        ComponentPropertyFactory $propertyFactory,
        ComponentPropertyCollection $props,
        ComponentCollection $components,
        StringCollection $classes,
        ?string $componentId = null
    ) {
        parent::__construct($propertyFactory, $props, $components, $classes, $componentId);
        // setColWidth() is part of the io-component 3.1.7 compatibility shim
        // (slated for reversal) and doesn't exist on the strict base — it's
        // just addClass('col-{size}-{cols}') under the hood, so call that
        // directly to keep the same behaviour under both signatures.
        $this->addClass('col-sm-3');
        $this->addClass('col-md-2');
        $this->addRoute('/');
        $this->addText('');
        $this->addIcon('link');
    }

    public function addRoute($route)
    {
        $this->setProperty('route', $route);
        return $this;
    }

    public function addText($text)
    {
        $this->setProperty('text', $text);
        return $this;
    }

    public function addIcon($icon)
    {
        $this->setProperty('icon', $icon);
        return $this;
    }

    public function isExternal($external = true)
    {
        $this->setProperty('external', $external);
        return $this;
    }

    public function addTarget($target)
    {
        $this->setProperty('target', $target);
        return $this;
    }
}
