Move secondary tasks collapsible theme overrides to farm_ui_theme.

This commit is contained in:
Michael Stenta 2023-05-18 12:59:34 -04:00
parent e971c13910
commit 3cd5de573b
8 changed files with 31 additions and 39 deletions

View File

@ -1,5 +1,5 @@
name: farmOS UI Menu
description: Provides farmOS toolbar menu overrides.
description: Provides farmOS menu and toolbar overrides.
type: module
package: farmOS UI
core_version_requirement: ^9

View File

@ -1,4 +0,0 @@
menu_local_task:
css:
theme:
css/menu-local-task.css: { }

View File

@ -72,36 +72,3 @@ function farm_ui_menu_local_tasks_alter(&$local_tasks) {
unset($local_tasks[$task_id]);
}
}
/**
* Implements hook_theme().
*/
function farm_ui_menu_theme($existing, $type, $theme, $path) {
return [
'menu_local_tasks__farm' => [
'base hook' => 'menu_local_tasks',
],
'menu_local_task__secondary' => [
'base hook' => 'menu_local_task',
],
];
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function farm_ui_menu_theme_suggestions_menu_local_task(array $variables) {
// Add suggestions for primary and secondary task levels.
$suggestions = [];
if (isset($variables['element']['#level'])) {
$suggestions[] = 'menu_local_task__' . $variables['element']['#level'];
}
return $suggestions;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function farm_ui_menu_theme_suggestions_menu_local_tasks(array $variables) {
return ['menu_local_tasks__farm'];
}

View File

@ -24,6 +24,10 @@ map:
css/map.css: { }
dependencies:
- farm_map/farm_map
menu_local_task:
css:
theme:
css/menu-local-task.css: { }
quick:
css:
theme:

View File

@ -16,12 +16,37 @@ function farm_ui_theme_theme($existing, $type, $theme, $path) {
'html__asset__map_popup' => [
'base hook' => 'html',
],
'menu_local_tasks__farm' => [
'base hook' => 'menu_local_tasks',
],
'menu_local_task__secondary' => [
'base hook' => 'menu_local_task',
],
'page__asset__map_popup' => [
'base hook' => 'page',
],
];
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function farm_ui_theme_theme_suggestions_menu_local_task(array $variables) {
// Add suggestions for primary and secondary task levels.
$suggestions = [];
if (isset($variables['element']['#level'])) {
$suggestions[] = 'menu_local_task__' . $variables['element']['#level'];
}
return $suggestions;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function farm_ui_theme_theme_suggestions_menu_local_tasks(array $variables) {
return ['menu_local_tasks__farm'];
}
/**
* Implements hook_element_info_alter().
*/

View File

@ -18,7 +18,7 @@
* @see template_preprocess_menu_local_task()
*/
#}
{{ attach_library('farm_ui_menu/menu_local_task') }}
{{ attach_library('farm_ui_theme/menu_local_task') }}
{%
set classes = [
'tabs__tab',