From 97fe2c82f513a9d95471b1dc112fcbd8f9138188 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Mon, 9 Jan 2023 09:41:30 +0000 Subject: [PATCH] set size of icon in action menus only via css, fixes #1953 Closes #1953 Merge request studip/studip!1295 --- lib/classes/ActionMenu.php | 4 +--- .../assets/stylesheets/scss/actionmenu.scss | 4 ++-- templates/shared/action-menu-single.php | 17 +++++++++++++++-- templates/shared/action-menu.php | 17 +++++++++++++++-- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lib/classes/ActionMenu.php b/lib/classes/ActionMenu.php index 511c995416e..15ea1ea83e5 100644 --- a/lib/classes/ActionMenu.php +++ b/lib/classes/ActionMenu.php @@ -112,7 +112,6 @@ class ActionMenu 'icon' => $url->icon, 'label' => $url->label, 'attributes' => $url->attributes, - 'index' => $index ]; } else { $action = [ @@ -121,10 +120,9 @@ class ActionMenu 'icon' => $icon, 'label' => $label, 'attributes' => $attributes, - 'index' => $index ]; } - $index = $index ?: md5($action['link'].json_encode($action['attributes'])); + $index = $index ?: md5($action['link'] . json_encode($action['attributes'])); $action['index'] = $index; //now insert it possibly at the desired position: $before_key = null; diff --git a/resources/assets/stylesheets/scss/actionmenu.scss b/resources/assets/stylesheets/scss/actionmenu.scss index 2f54b05c6d7..588f50c0391 100644 --- a/resources/assets/stylesheets/scss/actionmenu.scss +++ b/resources/assets/stylesheets/scss/actionmenu.scss @@ -48,8 +48,8 @@ $action-menu-shadow: 1px 1px 1px $dark-gray-color-60; cursor: pointer; display: block; padding: 0; - width: 20px; - height: 20px; + width: $action-menu-icon-size; + height: $action-menu-icon-size; // Create animated icon that changes to close icon on activation/hover span { diff --git a/templates/shared/action-menu-single.php b/templates/shared/action-menu-single.php index 7b49f313fb7..05c74962b25 100644 --- a/templates/shared/action-menu-single.php +++ b/templates/shared/action-menu-single.php @@ -1,15 +1,28 @@ +<?php +/** + * @var array<array{ + * type: string, + * label: string, + * link?: string, + * name?: string, + * object?: MultiPersonSearch, + * icon: Icon, + * attributes: array + * }> $actions + */ +?> <? foreach ($actions as $action): ?> <? if ($action['type'] === 'link'): ?> <a href="<?= htmlReady($action['link']) ?>" <?= arrayToHtmlAttributes($action['attributes'] + ['title' => $action['label']]) ?>> <? if ($action['icon']): ?> - <?= $action['icon'] ?> + <?= $action['icon']->asImg(false) ?> <? else: ?> <?= htmlReady($action['label']) ?> <? endif ?> </a> <? elseif ($action['type'] === 'button'): ?> <? if ($action['icon']): ?> - <?= $action['icon']->asInput($action['attributes'] + ['name' => $action['name'], 'title' => $action['label']]) ?> + <?= $action['icon']->asInput(false, $action['attributes'] + ['name' => $action['name'], 'title' => $action['label']]) ?> <? else: ?> <button name="<?= htmlReady($action['name']) ?>" <?= arrayToHtmlAttributes($action['attributes']) ?>> <?= htmlReady($action['label']) ?> diff --git a/templates/shared/action-menu.php b/templates/shared/action-menu.php index 1b3fb066fa5..938aa2c5420 100644 --- a/templates/shared/action-menu.php +++ b/templates/shared/action-menu.php @@ -1,3 +1,16 @@ +<?php +/** + * @var array<array{ + * type: string, + * label: string, + * link?: string, + * name?: string, + * object?: MultiPersonSearch, + * icon: Icon, + * attributes: array + * }> $actions + */ +?> <? // class "action-menu" will be set from API ?> <nav <?= arrayToHtmlAttributes($attributes) ?> aria-role="presentation"> <button class="action-menu-icon" aria-role="button" aria-expanded="false" title="<?= htmlReady($action_menu_title) ?>"> @@ -15,7 +28,7 @@ <? if ($action['type'] === 'link'): ?> <a href="<?= htmlReady($action['link']) ?>" <?= arrayToHtmlAttributes($action['attributes']) ?>> <? if ($action['icon']): ?> - <?= $action['icon'] ?> + <?= $action['icon']->asImg(false) ?> <? else: ?> <span class="action-menu-no-icon"></span> <? endif ?> @@ -24,7 +37,7 @@ <? elseif ($action['type'] === 'button'): ?> <? if ($action['icon']): ?> <label class="undecorated"> - <?= $action['icon']->asInput($action['attributes'] + ['name' => $action['name'], 'title' => $action['label']]) ?> + <?= $action['icon']->asInput(false, $action['attributes'] + ['name' => $action['name'], 'title' => $action['label']]) ?> <?= htmlReady($action['label']) ?> </label> <? else: ?> -- GitLab