Hi,
I created a Kirbytag for a progressbar but i have a little bit a problem with the attributes.
the Kirbytag should looks like (progressbar: value: 1235 max: 5615 unit: EUR class: blue).
My Problem now is that I have to declare the value-attribute directly after (progressbar:1235 …)
Is there a way to have a empty kirbytagname?
My Code
Kirby::plugin('kdjfs/progressbar', [
'tags' => [
'progressbar' => [
'attr' => [
'value',
'max',
'unit',
'class'
],
'html' => function($tag) {
$value = (int)str_replace('.', '', $tag->value);
$max = (int)str_replace('.', '', $tag->max);
if(is_numeric($value) && is_numeric($max)) {
$valuePercent = (100 * $value) / $max;
}
return
'<div class="progressbar-container">
<div class="progress">
<progress id="progressBar" role="progressbar" class="progress-bar w-100 ' . $tag->class . '" max="100" aria-valuemax="100" value="' . $valuePercent . '" aria-valuenow="' . $valuePercent . '" aria-valuemin="0" ></progress>
</div>
<ul class="progressbar__values d-flex justify-content-between pl-0">
<li class="progressbar__value-item mb-0">' . number_format($value, 0, ',', '.') . ' ' . $tag->unit . '</li>
<li class="progressbar__value-item">' . number_format($max, 0, ',', '.') . ' ' . $tag->unit . '</li>
</ul>
</div>';
}
]
]
]);