Skip to content
Snippets Groups Projects
Commit b1447801 authored by jurgenhaas's avatar jurgenhaas
Browse files

Add patches to gin and gin_toolbar

parent a2ef369a
No related branches found
No related tags found
1 merge request!198Merging develop into main
Pipeline #1214347 passed with warnings
......@@ -139,10 +139,13 @@
},
"drupal/gin": {
"#3355054 Default value for empty actions": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3355054.diff",
"#3439988 Sidebar and smalll desktop": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3439988.diff"
"#3439988 Sidebar and smalll desktop": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3439988.diff",
"#3441940 Support navigation": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3441940.diff",
"#3387653 Dark mode": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3387653.diff?v=3"
},
"drupal/gin_toolbar": {
"#3319445 Permission check": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/gin_toolbar-permissions.patch"
"#3319445 Permission check": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/gin_toolbar-permissions.patch",
"#3442173 Support navigation": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3442173.diff"
},
"drupal/glossify": {
"#3360633 HTML entities": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3360633.diff"
......
......@@ -137,10 +137,13 @@
},
"drupal/gin": {
"#3355054 Default value for empty actions": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3355054.diff",
"#3439988 Sidebar and smalll desktop": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3439988.diff"
"#3439988 Sidebar and smalll desktop": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3439988.diff",
"#3441940 Support navigation": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3441940.diff",
"#3387653 Dark mode": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3387653.diff?v=3"
},
"drupal/gin_toolbar": {
"#3319445 Permission check": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/gin_toolbar-permissions.patch"
"#3319445 Permission check": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/gin_toolbar-permissions.patch",
"#3442173 Support navigation": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3442173.diff"
},
"drupal/glossify": {
"#3360633 HTML entities": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3360633.diff"
......
......@@ -3,11 +3,11 @@ index 9871b15ec228d11ab443a3f86504ab1b573cde45..0bee63ffd6cc1b23e61071064cf35aba
--- a/dist/js/init.js
+++ b/dist/js/init.js
@@ -5,7 +5,7 @@
if (localStorage.getItem("GinDarkMode") && (localStorage.setItem("Drupal.gin.darkmode", localStorage.getItem("GinDarkMode")),
localStorage.removeItem("GinDarkMode")), localStorage.getItem("GinSidebarOpen") && (localStorage.setItem("Drupal.gin.toolbarExpanded", localStorage.getItem("GinSidebarOpen")),
if (localStorage.getItem("GinDarkMode") && (localStorage.setItem("Drupal.gin.darkmode", localStorage.getItem("GinDarkMode")),
localStorage.removeItem("GinDarkMode")), localStorage.getItem("GinSidebarOpen") && (localStorage.setItem("Drupal.gin.toolbarExpanded", localStorage.getItem("GinSidebarOpen")),
localStorage.removeItem("GinSidebarOpen")), ginInitDarkmode(), window.addEventListener("DOMContentLoaded", (() => {
- localStorage.getItem("Drupal.gin.darkmode") || (localStorage.setItem("Drupal.gin.darkmode", drupalSettings.gin.darkmode),
+ localStorage.getItem("Drupal.gin.darkmode") && (drupalSettings.gin.darkmode == localStorage.getItem("Drupal.gin.darkmode") || drupalSettings.gin.show_user_theme_settings) || (localStorage.setItem("Drupal.gin.darkmode", drupalSettings.gin.darkmode),
- localStorage.getItem("Drupal.gin.darkmode") || (localStorage.setItem("Drupal.gin.darkmode", drupalSettings.gin.darkmode),
+ localStorage.getItem("Drupal.gin.darkmode") && (drupalSettings.gin.darkmode == localStorage.getItem("Drupal.gin.darkmode") || drupalSettings.gin.show_user_theme_settings) || (localStorage.setItem("Drupal.gin.darkmode", drupalSettings.gin.darkmode),
ginInitDarkmode());
})), localStorage.getItem("Drupal.gin.toolbarExpanded")) {
const style = document.createElement("style"), className = "gin-toolbar-inline-styles";
......@@ -20,7 +20,7 @@ index 38dee471f4b6a0ab22e9a4b466919fe42567cbc2..ef61dbbb483609e7d3dade8a7d72ed87
$page['#attached']['drupalSettings']['gin']['highcontrastmode_class'] = 'gin--high-contrast-mode';
$page['#attached']['drupalSettings']['gin']['toolbar_variant'] = $settings->get('classic_toolbar');
+ $page['#attached']['drupalSettings']['gin']['show_user_theme_settings'] = $settings->get('show_user_theme_settings');
// Expose stylesheets to JS.
$basethemeurl = '/' . \Drupal::service('extension.list.theme')->getPath('gin');
diff --git a/js/init.js b/js/init.js
......@@ -28,9 +28,9 @@ index 10412e892c0cd0c48ca95bb651eac6c42350c637..860de79c61bd0601dc284519fe42624f
--- a/js/init.js
+++ b/js/init.js
@@ -32,9 +32,12 @@ function ginInitDarkmode() {
ginInitDarkmode();
-// GinDarkMode is not set yet.
+// GinDarkMode is not set yet or config changes detected.
window.addEventListener('DOMContentLoaded', () => {
......
This diff is collapsed.
diff --git a/gin_toolbar.module b/gin_toolbar.module
index 3fb44b40c1c3c977775637bad7d9fda8beeb90c3..fafd09fbdb0d2175e925b45e62922d8a4de7a0fc 100644
--- a/gin_toolbar.module
+++ b/gin_toolbar.module
@@ -43,10 +43,17 @@ function gin_toolbar_preprocess_html(&$variables) {
return;
}
+ // Check if Navigation module is active.
+ if (_gin_toolbar_module_is_active('navigation')) {
+ $variables['attributes']['class'][] = 'gin--core-navigation';
+ return;
+ }
+
// Check for new Drupal navigation.
if ($toolbar === 'new') {
/** @var \Drupal\gin\GinNavigaton $navigation */
$navigation = \Drupal::classResolver(GinNavigation::class);
+
// Get new navigation.
$variables['page_top']['navigation'] = $navigation->getNavigationStructure();
// Get active trail.
@@ -60,6 +67,29 @@ function gin_toolbar_preprocess_html(&$variables) {
}
}
+/**
+ * Implements hook_page_top().
+ */
+function gin_toolbar_page_top(array &$page_top) {
+ // Check if Navigation module is active.
+ if (!_gin_toolbar_module_is_active('navigation')) {
+ return;
+ }
+
+ $page_top['gin_secondary_toolbar'] = [
+ '#type' => 'toolbar',
+ '#access' => \Drupal::currentUser()->hasPermission('access toolbar'),
+ '#cache' => [
+ 'keys' => ['toolbar_secondary'],
+ 'contexts' => ['user.permissions'],
+ ],
+ '#attributes' => [
+ 'id' => 'toolbar-administration-secondary',
+ ],
+ ];
+ unset($page_top['toolbar']);
+}
+
/**
* Implements hook_preprocess_HOOK() for page_attachments.
*/
@@ -69,34 +99,12 @@ function gin_toolbar_page_attachments_alter(&$page) {
return;
}
- // Get theme settings.
- /** @var \Drupal\gin\GinSettings $settings */
- $settings = \Drupal::classResolver(GinSettings::class);
- $toolbar = $settings->get('classic_toolbar');
-
// Attach the base library.
$page['#attached']['library'][] = 'gin/gin_base';
// Attach accent overrides CSS.
$page['#attached']['library'][] = 'gin/gin_accent';
- if ($toolbar === 'classic') {
- // Attach the classic toolbar styles.
- $page['#attached']['library'][] = 'gin/gin_classic_toolbar';
- }
- elseif ($toolbar === 'horizontal') {
- // Attach the horizontal toolbar styles.
- $page['#attached']['library'][] = 'gin/gin_horizontal_toolbar';
- }
- elseif ($toolbar === 'new') {
- // Attach the new drupal navigation styles.
- $page['#attached']['library'][] = 'gin/navigation';
- }
- else {
- // Attach toolbar styles.
- $page['#attached']['library'][] = 'gin/gin_toolbar';
- }
-
// Attach the init script.
$page['#attached']['library'][] = 'gin/gin_init';
@@ -105,6 +113,10 @@ function gin_toolbar_page_attachments_alter(&$page) {
$page['#attached']['library'][] = 'gin/gin_custom_css';
}
+ // Get theme settings.
+ /** @var \Drupal\gin\GinSettings $settings */
+ $settings = \Drupal::classResolver(GinSettings::class);
+
// Expose settings to JS.
$page['#attached']['drupalSettings']['gin']['darkmode'] = $settings->get('enable_darkmode');
$page['#attached']['drupalSettings']['gin']['darkmode_class'] = 'gin--dark-mode';
@@ -115,6 +127,35 @@ function gin_toolbar_page_attachments_alter(&$page) {
$page['#attached']['drupalSettings']['gin']['highcontrastmode'] = $settings->get('high_contrast_mode');
$page['#attached']['drupalSettings']['gin']['highcontrastmode_class'] = 'gin--high-contrast-mode';
$page['#attached']['drupalSettings']['gin']['toolbar_variant'] = $settings->get('classic_toolbar');
+
+ // Check if Navigation module is active.
+ if (_gin_toolbar_module_is_active('navigation')) {
+ // Attach the new drupal navigation styles.
+ $page['#attached']['library'][] = 'gin/core_navigation';
+ return;
+ }
+
+ switch ($settings->get('classic_toolbar')) {
+ case 'classic':
+ // Attach the classic toolbar styles.
+ $page['#attached']['library'][] = 'gin/gin_classic_toolbar';
+ break;
+
+ case 'horizontal':
+ // Attach the horizontal toolbar styles.
+ $page['#attached']['library'][] = 'gin/gin_horizontal_toolbar';
+ break;
+
+ case 'new':
+ // Attach the experimental drupal navigation styles.
+ $page['#attached']['library'][] = 'gin/navigation';
+ break;
+
+ default:
+ // Attach toolbar styles.
+ $page['#attached']['library'][] = 'gin/gin_toolbar';
+ break;
+ }
}
/**
@@ -157,12 +198,16 @@ function gin_toolbar_library_info_alter(&$libraries, $extension) {
}
/**
- * Toolbar alter().
+ * Registry alter().
*/
function gin_toolbar_theme_registry_alter(&$theme_registry) {
$templates_path = \Drupal::service('extension.list.module')->getPath('gin_toolbar') . '/templates';
+
$theme_registry['toolbar']['path'] = $templates_path;
+ $theme_registry['toolbar__gin']['path'] = $templates_path;
$theme_registry['menu__toolbar']['path'] = $templates_path;
+ $theme_registry['navigation']['path'] = $templates_path;
+ $theme_registry['navigation__gin']['path'] = $templates_path;
}
/**
@@ -189,8 +234,9 @@ function gin_toolbar_preprocess_toolbar(&$variables) {
$settings = \Drupal::classResolver(GinSettings::class);
$variables['toolbar_variant'] = $settings->get('classic_toolbar');
$variables['secondary_toolbar_frontend'] = $settings->get('secondary_toolbar_frontend');
+ $variables['core_navigation'] = _gin_toolbar_module_is_active('navigation');
- if ($variables['toolbar_variant'] !== 'classic') {
+ if ($variables['toolbar_variant'] !== 'classic' || $variables['core_navigation']) {
// Move Admin Toolbar Search to start.
$toolbar_search = array_search('administration_search', array_keys($variables['tabs']));
if (is_numeric($toolbar_search)) {
@@ -201,6 +247,18 @@ function gin_toolbar_preprocess_toolbar(&$variables) {
}
}
}
+
+ // Move user tab to end.
+ $toolbar_user = array_search('user', array_keys($variables['tabs']));
+ if (is_numeric($toolbar_user)) {
+ foreach ($variables['tabs'] as $key => $item) {
+ if ($key === 'user') {
+ $user_tab = $variables['tabs'][$key];
+ unset($variables['tabs'][$key]);
+ $variables['tabs'][$key] = $user_tab;
+ }
+ }
+ }
}
// Expose Route name.
@@ -272,7 +330,7 @@ function gin_toolbar_preprocess_navigation(&$variables) {
/** @var \Drupal\gin\GinSettings $settings */
$settings = \Drupal::classResolver(GinSettings::class);
$logo_default = $settings->getDefault('logo.use_default');
- $variables['icon_default'] = $logo_default;
+ $variables['icon_path'] = !$logo_default ? $settings->getDefault('logo.path') : '';
$variables['toolbar_variant'] = $settings->get('classic_toolbar');
$variables['secondary_toolbar_frontend'] = $settings->get('secondary_toolbar_frontend');
@@ -377,54 +435,66 @@ function gin_toolbar_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function gin_toolbar_theme() {
- // Check if help is enabled.
- $help_enabled = FALSE;
- $module_handler = \Drupal::service('module_handler');
- if ($module_handler->moduleExists('help')) {
- $help_enabled = TRUE;
+ // Check if Navigation module is active.
+ if (_gin_toolbar_module_is_active('navigation')) {
+ $items['navigation'] = [
+ 'template' => 'navigation',
+ 'preprocess functions' => ['gin_toolbar_preprocess_navigation'],
+ 'variables' => [
+ 'icon_path' => NULL,
+ 'path' => \Drupal::service('extension.list.theme')->getPath('gin'),
+ ],
+ ];
+ }
+ else {
+ $items['navigation'] = [
+ 'template' => 'navigation--gin',
+ 'preprocess functions' => ['gin_toolbar_preprocess_navigation'],
+ 'variables' => [
+ 'icon_path' => NULL,
+ 'path' => \Drupal::service('extension.list.theme')->getPath('gin'),
+ 'menu_middle' => [],
+ 'menu_top' => [],
+ 'menu_bottom' => [],
+ ],
+ ];
+
+ $items['menu_region__top'] = [
+ 'variables' => [
+ 'links' => [],
+ 'title' => NULL,
+ 'menu_name' => NULL,
+ ],
+ ];
+
+ $items['menu_region__middle'] = [
+ 'base hook' => 'menu',
+ 'variables' => [
+ 'menu_name' => NULL,
+ 'items' => [],
+ 'attributes' => [],
+ 'title' => NULL,
+ ],
+ ];
+
+ // Check if help is enabled.
+ $help_enabled = _gin_toolbar_module_is_active('help');
+
+ $items['menu_region__bottom'] = [
+ 'variables' => [
+ 'help_enabled' => $help_enabled,
+ 'items' => [],
+ 'title' => NULL,
+ 'menu_name' => NULL,
+ 'path' => \Drupal::service('extension.list.theme')->getPath('gin'),
+ ],
+ ];
+
+ $items['container__administration_menu'] = [
+ 'base hook' => 'container',
+ 'render element' => 'container',
+ ];
}
-
- $items['navigation'] = [
- 'variables' => [
- 'path' => \Drupal::service('extension.list.theme')->getPath('gin'),
- 'menu_middle' => [],
- 'menu_top' => [],
- 'menu_bottom' => [],
- ],
- ];
-
- $items['menu_region__top'] = [
- 'variables' => [
- 'links' => [],
- 'title' => NULL,
- 'menu_name' => NULL,
- ],
- ];
-
- $items['menu_region__middle'] = [
- 'base hook' => 'menu',
- 'variables' => [
- 'menu_name' => NULL,
- 'items' => [],
- 'attributes' => [],
- 'title' => NULL,
- ],
- ];
-
- $items['menu_region__bottom'] = [
- 'variables' => [
- 'help_enabled' => $help_enabled,
- 'items' => [],
- 'title' => NULL,
- 'menu_name' => NULL,
- 'path' => \Drupal::service('extension.list.theme')->getPath('gin'),
- ],
- ];
-
- $items['container__administration_menu'] = [
- 'base hook' => 'container',
- 'render element' => 'container',
- ];
return $items;
}
@@ -432,7 +502,7 @@ function gin_toolbar_theme() {
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
-function gin_toolbar_theme_suggestions_container_alter(&$suggestions, $variables) {
+function gin_toolbar_theme_suggestions_container_alter(&$suggestions, array $variables) {
if (isset($variables['element']['administration_menu'])) {
$suggestions[] = 'container__administration_menu';
}
@@ -487,3 +557,19 @@ function _gin_toolbar_gin_is_active() {
return $theme_activated;
}
+
+/**
+ * Helper function for check if a module is active.
+ */
+function _gin_toolbar_module_is_active($module) {
+ $module_handler = \Drupal::service('module_handler');
+
+ // Check if Navigation module is active.
+ $check_module = $module_handler->moduleExists($module);
+
+ if ($check_module) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/templates/navigation--gin.html.twig b/templates/navigation--gin.html.twig
new file mode 100644
index 0000000000000000000000000000000000000000..43cc4e99ebfeb3b43b9bd6eeab48235dc24fa75f
--- /dev/null
+++ b/templates/navigation--gin.html.twig
@@ -0,0 +1,7 @@
+{#
+/**
+ * @file
+ * Include navigation--gin.html.twig template from Gin.
+ */
+#}
+{% include '@gin/navigation--gin.html.twig' ignore missing %}
diff --git a/templates/toolbar--gin.html.twig b/templates/toolbar--gin.html.twig
new file mode 100644
index 0000000000000000000000000000000000000000..d5a660aea1b48bc93033701ef49a9c8e97e99a4d
--- /dev/null
+++ b/templates/toolbar--gin.html.twig
@@ -0,0 +1,9 @@
+{#
+/**
+ * @file
+ * Include toolbar--gin.html.twig template from Gin.
+ */
+#}
+{% if toolbar_variant != 'new' and not core_navigation %}
+ {% include '@gin/navigation/toolbar--gin.html.twig' ignore missing %}
+{% endif %}
diff --git a/templates/toolbar.html.twig b/templates/toolbar.html.twig
index f050f4d1c354fef8a9726c8164d0ae45579b1cc5..3e99e34e024786af0ed902bea73e77d0a9e27de4 100644
--- a/templates/toolbar.html.twig
+++ b/templates/toolbar.html.twig
@@ -4,8 +4,11 @@
* Include toolbar.html.twig template from Gin.
*/
#}
-{% include '@gin/navigation/toolbar--gin.html.twig' ignore missing %}
-{% if secondary_toolbar_frontend and toolbar_variant != 'classic' %}
+{% if not core_navigation %}
+ {% include '@gin/navigation/toolbar--gin.html.twig' ignore missing %}
+{% endif %}
+
+{% if secondary_toolbar_frontend and (toolbar_variant != 'classic' or core_navigation) %}
<div class="gin-secondary-toolbar gin-secondary-toolbar--frontend"{{ toolbar_variant == 'vertical' or toolbar_variant == 'new' ? ' data-offset-top' : '' }}>
<div class="gin-secondary-toolbar__layout-container">
<div class="gin-breadcrumb-wrapper">
......@@ -143,10 +143,13 @@
},
"drupal/gin": {
"#3355054 Default value for empty actions": "https://git.drupalcode.org/project/gin/-/merge_requests/246.diff",
"#3439988 Sidebar and smalll desktop": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3439988.diff"
"#3439988 Sidebar and smalll desktop": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3439988.diff",
"#3441940 Support navigation": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3441940.diff",
"#3387653 Dark mode": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3387653.diff?v=3"
},
"drupal/gin_toolbar": {
"#3319445 Permission check": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/gin_toolbar-permissions.patch"
"#3319445 Permission check": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/gin_toolbar-permissions.patch",
"#3442173 Support navigation": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3442173.diff"
},
"drupal/glossify": {
"#3338553 PHP 8.1": "https://git.drupalcode.org/project/glossify/-/merge_requests/10.diff",
......
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