Skip to content

Commit

Permalink
Improve dropdown alignment and nav menu button style.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Jan 11, 2024
1 parent aa5824c commit 89014c8
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 17 deletions.
2 changes: 1 addition & 1 deletion themes/bootprint3/css/compiled.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/bootstrap3/css/compiled.css

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions themes/bootstrap3/less/bootstrap.less
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ label { cursor: pointer; }
}
.nav .dropdown-toggle {
padding-right: 8px;
height: inherit;
border-radius: 0;

.icon {
margin-left: 4px;
Expand Down Expand Up @@ -139,8 +141,13 @@ button.dropdown-toggle {
color: inherit;
background-color: transparent;
}
.dropdown label {
padding-right: 0.2rem;
.dropdown-container {
label {
padding-right: 0.5rem;
}
.dropdown {
display: inline-block;
}
}

// Normalize highlighting
Expand Down
3 changes: 3 additions & 0 deletions themes/bootstrap3/less/components/search.less
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ header .container.navbar { margin-bottom: 0; }
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.search-controls .dropdown-menu {
min-width: 80px;
}

@media (min-width: 768px) {
.search-header {
Expand Down
11 changes: 9 additions & 2 deletions themes/bootstrap3/scss/bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ label { cursor: pointer; }
}
.nav .dropdown-toggle {
padding-right: 8px;
height: inherit;
border-radius: 0;

.icon {
margin-left: 4px;
Expand Down Expand Up @@ -139,8 +141,13 @@ button.dropdown-toggle {
color: inherit;
background-color: transparent;
}
.dropdown label {
padding-right: 0.2rem;
.dropdown-container {
label {
padding-right: 0.5rem;
}
.dropdown {
display: inline-block;
}
}

// Normalize highlighting
Expand Down
3 changes: 3 additions & 0 deletions themes/bootstrap3/scss/components/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ header .container.navbar { margin-bottom: 0; }
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.search-controls .dropdown-menu {
min-width: 80px;
}

@media (min-width: 768px) {
.search-header {
Expand Down
29 changes: 20 additions & 9 deletions themes/bootstrap3/templates/_ui/components/menu-button.phtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php
$wrapperTag = $this->wrapperTag ?? 'div';
$showSelectedValue = $this->showSelectedValue ?? false;
$wrapperClass = 'dropdown'; // Bootstrap class

if ($this->wrapperClass ?? false) {
$wrapperClass = $this->wrapperClass . ' dropdown'; // Bootstrap class
}

// defaults
$toggleAttrs = [
Expand All @@ -31,7 +26,7 @@
$selected = $this->defaultSelectedValue ?? '';
?>
<?php ob_start(); ?>
<ul class="dropdown-menu">
<ul class="dropdown-menu dropdown-menu-right">
<?php foreach ($this->menuItems as $current): ?>
<?php
if ($current['selected'] ?? false) {
Expand All @@ -57,9 +52,6 @@
$label = empty($this->toggleLabel) ? '' : $this->transEsc($this->toggleLabel);
$buttonText = $showSelectedValue ? $selected : $label;
?>
<?php if ($showSelectedValue && '' !== $label): ?>
<label for="<?=$this->escapeHtmlAttr($toggleAttrs['id'])?>"><?=$this->escapeHtml($label)?></label>
<?php endif; ?>
<?=
$this->makeTag(
$toggleTag,
Expand All @@ -71,4 +63,23 @@
<?php $menuContents = ob_get_contents(); ?>
<?php ob_end_clean(); ?>

<?php if ($showSelectedValue && '' !== $label): ?>
<?php
// We need an inner wrapper to keep the label out of the dropdown and from
// affecting dropdown position
$menuContents = '<label for="'. $this->escapeHtmlAttr($toggleAttrs['id']) . '">'
. $this->escapeHtml($label)
. '</label>'
. $this->makeTag(
'div',
$menuContents,
'dropdown',
['escapeContent' => false]
);
$wrapperClass = trim(($this->wrapperClass ?? '') . ' dropdown-container');
?>
<?php else: ?>
<?php $wrapperClass = trim(($this->wrapperClass ?? '') . ' dropdown'); ?>
<?php endif; ?>

<?=$this->makeTag($wrapperTag, $menuContents, $wrapperClass, ['escapeContent' => false]) ?>
2 changes: 1 addition & 1 deletion themes/local_theme_example/css/compiled.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/sandal/css/compiled.css

Large diffs are not rendered by default.

0 comments on commit 89014c8

Please sign in to comment.