Skip to content

Commit

Permalink
Merge branch 'midnight_blue-header' of https://github.com/aleeexgreee…
Browse files Browse the repository at this point in the history
…n/ckan into aleeexgreeen-midnight_blue-header
  • Loading branch information
amercader committed Nov 27, 2024
2 parents c19e090 + 6e23833 commit f72e375
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
11 changes: 7 additions & 4 deletions ckan/lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,15 @@ def get_flashed_messages(**kwargs: Any):


@core_helper
def page_is_active(menu_item: str) -> bool:
def page_is_active(
menu_item: str, active_blueprints: Optional[list[str]] = None) -> bool:
'''Returns whether the current link is the active page or not'''
controller, action = menu_item.split('.')
blueprint, endpoint = menu_item.split('.')

item = {
'action': action,
'controller': controller
'controller': blueprint,
'action': endpoint,
'highlight_controllers': active_blueprints,
}
return _link_active(item)

Expand Down
6 changes: 5 additions & 1 deletion ckan/public-midnight-blue/base/css/main-rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -14223,10 +14223,14 @@ td.diff_header {
}
.masthead .main-navbar ul {
justify-content: center;
gap: 24px;
flex-wrap: wrap;
padding: 10px 0;
}
@media (min-width: 768px) {
.masthead .main-navbar ul {
gap: 24px;
}
}
.masthead .main-navbar ul li {
margin-right: 2px;
}
Expand Down
6 changes: 5 additions & 1 deletion ckan/public-midnight-blue/base/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -14223,10 +14223,14 @@ td.diff_header {
}
.masthead .main-navbar ul {
justify-content: center;
gap: 24px;
flex-wrap: wrap;
padding: 10px 0;
}
@media (min-width: 768px) {
.masthead .main-navbar ul {
gap: 24px;
}
}
.masthead .main-navbar ul li {
margin-right: 2px;
}
Expand Down
4 changes: 3 additions & 1 deletion ckan/public-midnight-blue/base/scss/_masthead.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ $notificationsBg: #C9403A;
.main-navbar {
ul {
justify-content: center;
gap: 24px;
flex-wrap: wrap;
padding: 10px 0;
@include media-breakpoint-up(md){
gap: 24px
}
li {
margin-right: 2px;
a {
Expand Down
8 changes: 4 additions & 4 deletions ckan/templates-midnight-blue/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@
{% set org_type = h.default_group_type('organization') %}
{% set group_type = h.default_group_type('group') %}

{{ nav.link(dataset_type ~ '.search', h.humanize_entity_type('package', dataset_type, 'main nav') or _('Datasets')) }}
{{ nav.link(org_type ~ '.index', h.humanize_entity_type('organization', org_type, 'main nav') or _('Organizations')) }}
{{ nav.link(group_type ~ '.index', h.humanize_entity_type('group', group_type, 'main nav') or _('Groups')) }}
{{ nav.link(dataset_type ~ '.search', h.humanize_entity_type('package', dataset_type, 'main nav') or _('Datasets'), active_blueprints=[dataset_type, dataset_type + '_resource']) }}
{{ nav.link(org_type ~ '.index', h.humanize_entity_type('organization', org_type, 'main nav') or _('Organizations'), active_blueprints=[org_type]) }}
{{ nav.link(group_type ~ '.index', h.humanize_entity_type('group', group_type, 'main nav') or _('Groups'), active_blueprints=[group_type]) }}
{{ nav.link('home.about', _('About')) }}
{% endblock %}
</ul>
Expand All @@ -115,4 +115,4 @@
</nav>
</div>
</header>
{% endblock %}
{% endblock %}
19 changes: 11 additions & 8 deletions ckan/templates-midnight-blue/macros/nav_link.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
{#
Builds links for navigation

nav_item - the name of the defined nav item defined in config/routing as the named route of the same name
title - text used for the link
icon - icon name used for link

Example:

{% import 'macros/nav_link.html' as nav %}
{{ nav.link('home.about', _('About')") }}

#}
{% macro link(nav_item, title, icon="") %}
{% set active_page = h.page_is_active(nav_item) %}
{% macro link(nav_item, title, active_blueprints=[], icon="", url="") %}

{% set active_page = h.page_is_active(nav_item, active_blueprints=active_blueprints) %}

{% set url = url if url else h.url_for(nav_item, id) %}

<li {% if active_page %}class="active"{% endif %}>
<a {% if active_page %}aria-current="page"{% endif %} href="{{ h.url_for(nav_item) }}">
<a {% if active_page %}aria-current="page"{% endif %} href="{{ url }}">
{% if icon %}
<i class="fa fa-{{ icon }}"></i>
{% endif %}
{{ title }}
</a>
</li>
{% endmacro %}
{% endmacro %}

0 comments on commit f72e375

Please sign in to comment.