Skip to content
Snippets Groups Projects
Commit 9e3cfdbe authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

add SeparatorElement for sidebar widgets, re #3235

Merge request !2204
parent 31bbc46d
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,16 @@ class ListWidget extends SidebarWidget
$this->classes = array_diff($this->css_class, [$css_class]);
}
/**
* Adds a separator to the widget
*
* @param array $attributes Optional additional attributes
*/
public function addSeparator($attributes = [])
{
$this->addElement(new SeparatorElement($attributes));
}
/**
*
*/
......@@ -46,4 +56,4 @@ class ListWidget extends SidebarWidget
return parent::render($variables);
}
}
\ No newline at end of file
}
<?php
class SeparatorElement extends WidgetElement
{
public $attributes = [];
/**
* create a separator element
*
* @param array $attributes HTML-attributes in an associative array.
*/
public function __construct($attributes = [])
{
parent::__construct();
$this->attributes = $attributes;
}
/**
* Renders the element.
*
* @return string
*/
public function render()
{
return sprintf('<hr %s>', arrayToHtmlAttributes($this->attributes));
}
}
......@@ -124,6 +124,12 @@ ul.widget-list {
word-wrap: break-word;
}
hr {
border-style: none;
border-top: thin solid var(--content-color-40);
margin: 4px 0px 4px -20px;
}
button {
@extend .as-link;
text-align: left;
......
......@@ -2,6 +2,7 @@
<?= CSRFProtection::tokenTag() ?>
<ul class="<?= implode(' ', $css_classes) ?>" aria-label="<?= htmlReady($title) ?>">
<? foreach ($elements as $index => $element): ?>
<? $icon = null ?>
<? if ($element instanceof LinkElement): ?>
<? $icon = $element->icon ?? null ?>
<? if ($icon && $element->isDisabled()): ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment