diff --git a/lib/classes/sidebar/ListWidget.php b/lib/classes/sidebar/ListWidget.php index ed37e4cd6946e194a05cf7ea6e3a0c4e1be18e24..e6edce21db778e7359c8c006089c5805911c9312 100644 --- a/lib/classes/sidebar/ListWidget.php +++ b/lib/classes/sidebar/ListWidget.php @@ -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 +} diff --git a/lib/classes/sidebar/SeparatorElement.php b/lib/classes/sidebar/SeparatorElement.php new file mode 100644 index 0000000000000000000000000000000000000000..4cfb1ffb33511478bbff1eb6131880d406a96da2 --- /dev/null +++ b/lib/classes/sidebar/SeparatorElement.php @@ -0,0 +1,28 @@ +<?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)); + } +} diff --git a/resources/assets/stylesheets/scss/sidebar.scss b/resources/assets/stylesheets/scss/sidebar.scss index 9a556a474ec0b4613fdd2af350ce61369e17321e..fd885af8a9cbb52d4657d19eef4afcf055d731f5 100644 --- a/resources/assets/stylesheets/scss/sidebar.scss +++ b/resources/assets/stylesheets/scss/sidebar.scss @@ -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; diff --git a/templates/sidebar/list-widget.php b/templates/sidebar/list-widget.php index e9af862500b59f5c819c78d79cb083e0b4f3b64a..5c94a0ed149262307b83d5a34db053f471e5aa56 100644 --- a/templates/sidebar/list-widget.php +++ b/templates/sidebar/list-widget.php @@ -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()): ?>