From 3b6ad20486ed30609c13f0c18a2779c239c4680c Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 10 Jan 2021 22:02:27 +0000 Subject: [PATCH] Move padding from list items to links So that the padding takes up the full space within the tab, move the padding to the link element. This requires adding a preprocess function to the theme file and removing the classes from the local task template. References #341 --- web/themes/custom/opdavies/opdavies.theme | 7 +++++++ .../opdavies/templates/menu/menu-local-task.html.twig | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/web/themes/custom/opdavies/opdavies.theme b/web/themes/custom/opdavies/opdavies.theme index a58c767..57e2126 100644 --- a/web/themes/custom/opdavies/opdavies.theme +++ b/web/themes/custom/opdavies/opdavies.theme @@ -25,3 +25,10 @@ function opdavies_preprocess_page(array &$variables): void { $variables['#attached']['library'][] = 'opdavies/twitter'; } } + +/** + * Implements hook_preprocess_HOOK(). + */ +function opdavies_preprocess_menu_local_task(array &$variables): void { + $variables['link']['#options']['attributes']['class'][] = 'block px-5 py-2'; +} diff --git a/web/themes/custom/opdavies/templates/menu/menu-local-task.html.twig b/web/themes/custom/opdavies/templates/menu/menu-local-task.html.twig index 8916986..11d1f0c 100644 --- a/web/themes/custom/opdavies/templates/menu/menu-local-task.html.twig +++ b/web/themes/custom/opdavies/templates/menu/menu-local-task.html.twig @@ -15,7 +15,7 @@ */ #} {% set linkClasses = [ - 'mt-3 ml-3 px-4 py-2 block border border-gray-200', + 'mt-3 ml-3 border border-gray-200', is_active ? 'underline bg-gray-100' : 'bg-white', ] %}