Skip to content

Instantly share code, notes, and snippets.

@RobinDev
Last active December 27, 2023 08:10
Show Gist options
  • Save RobinDev/ea24869b9a9e571bda95370330cda2ab to your computer and use it in GitHub Desktop.
Save RobinDev/ea24869b9a9e571bda95370330cda2ab to your computer and use it in GitHub Desktop.
Example League/Plates Fork
<?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('"', '&quot;') ?>"
<?= $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