Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the new navigation concept for Newshub #808

Merged
merged 5 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion assets/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
import {isTouchDevice} from 'utils';
import {isTouchDevice, gettext} from 'utils';
import 'primereact/resources/primereact.min.css';

if (isTouchDevice()) {
document.documentElement.classList.add('no-touch');
}

const element = document.getElementById('nav');
const pinButton = document.getElementById('pin-btn');

if (pinButton != null) {
pinButton.addEventListener('click', () => {
handleNavToggle();
});
}

if (sessionStorage.getItem('navigation-pinned')) {
handleNavToggle();
}

function handleNavToggle() {
if (element == null || pinButton == null) {
return null;
}

if (element.classList.contains('nav-block--pinned')) {
sessionStorage.removeItem('navigation-pinned');
element.classList.remove('nav-block--pinned');
pinButton.setAttribute('title', gettext('Expand'));
} else {
sessionStorage.setItem('navigation-pinned', 'true');
element.classList.add('nav-block--pinned');
pinButton.setAttribute('title', gettext('Collapse'));
}
}
3 changes: 2 additions & 1 deletion assets/styles/sidenav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
min-width: var(--sidenav-size);
transition: all var(--sidenav-transition);
overflow-y: auto;
overflow-x: hidden;

.sidenav__item-icon {
--icon-block-radius: var(--sidenav-item-radius);
Expand Down Expand Up @@ -352,4 +353,4 @@
}

}
}
}
8 changes: 7 additions & 1 deletion newsroom/templates/base_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ <h3 class="a11y-only">{{ gettext('Main Navigation Bar') }}</h3>

<div class="contentWrap {% block custom_content_style %}{% endblock %}">
{% if session.get('name') %}
<nav class="{`nav-block ${isNavExpanded ? 'nav-block--pinned' : ''}`}">
<nav id="nav" class="nav-block">
<h3 class="a11y-only">{{ gettext('Side Navigation') }}</h3>
<ul class="sidenav">

<li className='d-phone-none'>
<button id="pin-btn" class='nav-block__pin-button' title="{{ gettext('Expand') }}">
<i class="icon--arrow-end" role='presentation'></i>
</button>
</li>

{% block default_navs %}
{% for group in range(0, 10) %}
{% for nav in sidenavs(request.blueprint)|selectattr("group", "equalto", group) %}
Expand Down
4 changes: 2 additions & 2 deletions newsroom/templates/sidenav_icon.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% if nav.url %}target="_blank"{% endif %}
>
{% if nav.badge %}
<span id="{{ nav.badge }}" class="sidenav-icons__badge"></span>
<span id="{{ nav.badge }}" class="sidenav__badge"></span>
{% endif %}

<span class="sidenav__item-icon">
Expand All @@ -20,4 +20,4 @@
</span>
<span class="sidenav__item-title">{{ gettext(nav.name) }}</span>
</a>
</li>
</li>
Loading