Add label attribute

This commit is contained in:
brabli
2025-02-26 10:41:07 +00:00
parent ebc73e1b24
commit 2a7230298e
2 changed files with 6 additions and 2 deletions

View File

@@ -1,3 +1,7 @@
<div {{ attributes }} class="{{ this.finalClasses }}"> <div {{ attributes }} class="{{ this.finalClasses }}">
{% if block('content') is not empty %}
{% block content %}{% endblock %} {% block content %}{% endblock %}
{% else %}
{{- this.label -}}
{% endif %}
</div> </div>

View File

@@ -26,7 +26,7 @@ final class Badge
* @param ?string $colour specify the colour of an objectless badge * @param ?string $colour specify the colour of an objectless badge
* @param bool $outline if the badge should be rendered as an outline * @param bool $outline if the badge should be rendered as an outline
*/ */
public function mount(?BadgeableInterface $obj = null, ?string $class = null, ?string $colour = null, bool $outline = false): void public function mount(?BadgeableInterface $obj = null, ?string $class = null, ?string $colour = null, ?string $label = null, bool $outline = false): void
{ {
if (!$obj && !$colour) { if (!$obj && !$colour) {
throw new \RuntimeException(sprintf('You must specify either a colour an instance of "%s".', BadgeableInterface::class)); throw new \RuntimeException(sprintf('You must specify either a colour an instance of "%s".', BadgeableInterface::class));