Skip to content

Commit 8a75ed3

Browse files
authored
Merge pull request #63 from herbdool/issue-60
Issue #60: fix hamburger and alignment
2 parents 0fd971f + 46b0d6f commit 8a75ed3

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

template.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,7 @@ function bootstrap5_lite_preprocess_page(&$variables) {
224224
function bootstrap5_lite_preprocess_header(&$variables) {
225225
$variables['navigation'] = '';
226226
$navbar_menu_position = theme_get_setting('bootstrap5_lite_navbar_menu_position');
227-
if ($navbar_menu_position == 'navbar-right') {
228-
$variables['navbar_menu_position'] = 'd-flex justify-content-end';
229-
}
230-
else {
231-
$variables['navbar_menu_position'] = 'd-flex justify-content-between';
232-
}
227+
$variables['navbar_menu_position'] = $navbar_menu_position;
233228

234229
if ($navbar_position = theme_get_setting('bootstrap5_lite_navbar_user_menu')) {
235230
$user_menu = menu_tree('user-menu');
@@ -263,6 +258,9 @@ function bootstrap5_lite_links__header_menu($menu) {
263258
$menu['attributes']['class'] = array('menu','nav','navbar-nav');
264259
if ($navbar_menu_position = theme_get_setting('bootstrap5_lite_navbar_menu_position')) {
265260
$menu['attributes']['class'][] = $navbar_menu_position;
261+
if ($navbar_menu_position == 'navbar-right') {
262+
$menu['attributes']['class'][] = 'ms-auto';
263+
}
266264
}
267265
foreach ($menu['links'] as $item => $link) {
268266
$menu['links'][$item]['attributes']['class'][] = 'nav-link';
@@ -295,7 +293,7 @@ function bootstrap5_lite_menu_tree__user_menu($variables) {
295293
$menu = menu_navigation_links('user-menu');
296294
$links = $menu ? theme('links__user_menu', array('links' => $menu)) : NULL;
297295
return '
298-
<div class="menu nav navbar-nav dropstart p-2">
296+
<div class="menu nav navbar-nav dropstart p-2 ms-auto">
299297
<div class="dropdown">
300298
<div data-toggle="dropdown" data-bs-toggle="dropdown"><i class="fa fa-cog"></i></div>
301299
' . $links . '

templates/header.tpl.php

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,22 @@
2121
?>
2222
<header id="navbar" role="banner" class="<?php print implode(" ",$navbar_classes_array); ?>">
2323
<div class="<?php print $container_class;?>">
24-
<div class="navbar-header">
25-
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
26-
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".navbar-collapse">
27-
<span class="sr-only">Toggle navigation</span>
28-
<span class="icon-bar"></span>
29-
<span class="icon-bar"></span>
30-
<span class="icon-bar"></span>
31-
</button>
32-
<?php if ($site_name || $logo): ?>
33-
<a class="name navbar-brand" href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>">
34-
<?php if ($logo): ?>
35-
<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
36-
<?php endif; ?>
37-
<?php if ($site_name): ?>
38-
<?php print $site_name; ?>
39-
<?php endif; ?>
40-
</a>
41-
<?php endif; ?>
42-
</div>
43-
24+
<?php if ($site_name || $logo): ?>
25+
<a class="name navbar-brand" href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>">
26+
<?php if ($logo): ?>
27+
<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
28+
<?php endif; ?>
29+
<?php if ($site_name): ?>
30+
<?php print $site_name; ?>
31+
<?php endif; ?>
32+
</a>
33+
<?php endif; ?>
34+
<button type="button" class="navbar-toggler <?php print ($navbar_menu_position == 'navbar-right') ? 'ms-auto' : ''; ?>" data-bs-toggle="collapse" data-bs-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="Toggle navigation">
35+
<span class="navbar-toggler-icon"></span>
36+
</button>
37+
4438
<?php if ($navigation or $menu): ?>
45-
<div class="navbar-collapse collapse <?php print $navbar_menu_position; ?>">
39+
<div class="navbar-collapse collapse" id="navbar-content">
4640
<?php if ($menu) print $menu; ?>
4741
<?php if ($navigation) print $navigation; ?>
4842
</div>

0 commit comments

Comments
 (0)