Last active
December 27, 2023 08:10
-
-
Save RobinDev/ea24869b9a9e571bda95370330cda2ab to your computer and use it in GitHub Desktop.
Example League/Plates Fork
This file contains hidden or 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
<?php | |
namespace App\Template\Partial; // src/Template/Partial/TooltipTpl.php | |
use League\Plates\Template\Template; | |
use League\Plates\Template\TemplateClassInterface; | |
use App\Plates\AbstractTemplate; | |
use App\Plates\TemplateExtension; | |
use function Symfony\Component\String\u; | |
class TooltipTpl extends AbstractTemplate implements TemplateClassInterface | |
{ | |
public function display( | |
Template $t, | |
string|int|float $text = '', | |
string $tooltipText = '', | |
string $extraClass = 'text-sky-600 focus:text-gray-400', | |
string $tooltipextraClass = '', | |
?string $extraAttributes = '', | |
): void | |
{ | |
?> | |
<button | |
class="focus:outline-none inline-block <?= $extraClass ?>" | |
x-tooltip="{ | |
content: '', | |
allowHTML: true, | |
interactive: true, | |
theme: 'light', | |
appendTo: document.body | |
}" | |
x-tooltip.raw="<?= u('<span class="max-h-[50vh] overflow-y-auto block '.$tooltipextraClass.'">'.$tooltipText.'</span>')->replace('"', '"') ?>" | |
<?= $extraAttributes ?>> | |
<?= $text ?> | |
<?php if ('' === $text) { ?> | |
<span class="rounded-full border-gray-300 border text-gray-300 inline-block ml-2 hover:bg-white w-[22px] text-sm text-center">?</span> | |
<?php } ?> | |
</button> | |
<?php | |
} | |
/** | |
* Autogenerated constructor. | |
*/ | |
public function __construct(public string|int|float $text = '', public string $tooltipText = '', public string $extraClass = 'text-sky-600 focus:text-gray-400', public string $tooltipextraClass = '', public ?string $extraAttributes = '') | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment