ux
ux copied to clipboard
Use ComponentAttributes everywhere in project
Hi,
It would be great to be able to use ComponentAttributes everywhere in project but ComponentAttributes is marked as @internal
For instance:
<?php
namespace App\Twig;
use Symfony\UX\TwigComponent\ComponentAttributes;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class AriaExtension extends AbstractExtension
{
public function getFunctions(): array
{
return [
new TwigFunction('aria_dialog', [$this, 'ariaDialog']),
];
}
public function ariaDialog()
{
$attributes = [
'data-controller' => 'dialog',
'role' => 'dialog',
'aria-modal' => 'true',
];
return new ComponentAttributes($attributes);
}
}
If there is an external use-case for something marked as internal, I'm fine with removing @internal.
An example use case is generating HTML attributes like the Twig extension, above. But it is not a component.
Yep, looks legit to me!
Maybe we could rename ComponentAttributes to HtmlAttributes?
I'd be fine with this as well. @weaverryan, any objections?
Hi @weaverryan, Do you have any objections?
It's often better to start a PR if the change is scoped like this one. Easier to judge the impact, and PRs often get more attention than issues :)
Yes, PR please! No objections from me, including the name change.