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

Styleguide: mise à jour du breadcrumb et de la navigation mobile #718

Merged
merged 24 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0f93b1b
Add link classes to base breadcrumb template
alinekeller Apr 30, 2024
8afb129
Create dropdown variant
alinekeller Apr 30, 2024
6225c1f
Add breadcrumb dropdown menus
alinekeller Apr 30, 2024
33ab348
Add "expand breadcrumb button" for small devices
alinekeller Apr 30, 2024
2df37f2
Fix styleint order
alinekeller Apr 30, 2024
4aaddf4
Remove unused breadcrumb js function
alinekeller Apr 30, 2024
937ed07
Add 'expand breadcrumb' button to tagged breadcrumb
alinekeller Apr 30, 2024
aa8ec51
Update "breadcrumb tagged"
alinekeller May 1, 2024
0c31177
Create Nav Mobile component
alinekeller May 1, 2024
8c30718
Base: remove "browse" button (nav-toggle)
alinekeller May 1, 2024
0075894
Base: replace 'nav-main' with 'nav-mobile'
alinekeller May 1, 2024
9775346
Base: move 'nav-aside' inside 'nav-mobile'
alinekeller May 1, 2024
4ec7032
Update side nav structure on Lab demo page
alinekeller May 1, 2024
a726cc7
Base: add condition to display regular or tagged breadcrumb
alinekeller May 1, 2024
a8782b7
Update page templates
alinekeller May 1, 2024
1529e32
Fix CSS order
alinekeller May 1, 2024
26c6487
Mobile nav aside fine tunning
alinekeller May 1, 2024
1143146
Fix styleint css order
alinekeller May 1, 2024
8b7aa4a
Fix dropdown item classes (study plan templates)
alinekeller May 16, 2024
f220a78
Remove breadcrumb container right fading
alinekeller May 16, 2024
c0b2778
Improve dropdown position on small devices
alinekeller May 16, 2024
16f2e09
Bring hierarchy back to mobile side nav
alinekeller May 16, 2024
8cb26bb
Fix stylelint issue
alinekeller May 16, 2024
43a4675
Format js
williambelle May 17, 2024
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
1 change: 1 addition & 0 deletions assets/components/entrypoint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
@import 'organisms/fullwidth-teaser/fullwidth-teaser';
@import 'organisms/nav-main/nav-main';
@import 'organisms/nav-aside/nav-aside';
@import 'organisms/nav-mobile/nav-mobile';
@import 'organisms/contact/contact';
@import 'organisms/footer/footer';
@import 'organisms/form/form';
Expand Down
69 changes: 69 additions & 0 deletions assets/components/molecules/breadcrumb/breadcrumb-dropdown.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<nav aria-label="breadcrumb" class="breadcrumb-wrapper">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a class="bread-link bread-home" href="#">
{% include '@atoms/icon/icon.twig' with { icon: 'icon-home' } %}
</a>
</li>
<li class="breadcrumb-item expand-links">
<button class="btn btn-expand-links" aria-expanded="false" title="Display the complete path">
<span class="dots" aria-hidden="true">…</span>
<span class="sr-only">Display the complete path</span>
</button>
</li>
<li class="breadcrumb-item">
<a class="bread-link" href="#">Schools</a>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-controls="dropdown-menu-1">
{% include '@atoms/icon/icon.twig' with { icon: 'arrow-down-circle', icon_classes:'feather' } %}
<span class="sr-only">Display same level pages – Schools</span>
</button>
<ul class="dropdown-menu" id="dropdown-menu-1">
<li class="dropdown-item"><a href="#">About</a></li>
<li class="dropdown-item"><a href="#">Education</a></li>
<li class="dropdown-item"><a href="#">Research</a></li>
<li class="dropdown-item"><a href="#">Innovation</a></li>
<li class="dropdown-item current-menu-item-parent"><a href="#">Schools</a></li>
<li class="dropdown-item"><a href="#">Campus</a></li>
</ul>
</div>
</li>
<li class="breadcrumb-item">
<a class="bread-link" href="#">School of Architecture, Civil and Environmental Engineering</a>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-controls="dropdown-menu-2">
{% include '@atoms/icon/icon.twig' with { icon: 'arrow-down-circle', icon_classes:'feather' } %}
<span class="sr-only">Display same level pages – School of Architecture, Civil and Environmental Engineering</span>
</button>
<ul class="dropdown-menu" id="dropdown-menu-2">
<li class="dropdown-item current-menu-item-parent"><a href="#">School of Architecture, Civil and Environmental Engineering</a></li>
<li class="dropdown-item"><a href="#">School of Computer and Communication Sciences</a></li>
<li class="dropdown-item"><a href="#">School of Basic Sciences</a></li>
<li class="dropdown-item"><a href="#">School of Engineering</a></li>
<li class="dropdown-item"><a href="#">School of Life Sciences</a></li>
<li class="dropdown-item"><a href="#">College of Management of Technology</a></li>
<li class="dropdown-item"><a href="#">College of Humanities</a></li>
<li class="dropdown-item"><a href="#">Sections</a></li>
</ul>
</div>
</li>
<li class="breadcrumb-item">
<a class="bread-link" href="#">Sustainability challenges</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
<span class="bread-item">FUSTIC association</span>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-controls="dropdown-menu-3">
{% include '@atoms/icon/icon.twig' with { icon: 'arrow-down-circle', icon_classes:'feather' } %}
<span class="sr-only">Display same level pages – FUSTIC association</span>
</button>
<ul class="dropdown-menu" id="dropdown-menu-3">
<li class="dropdown-item"><a href="#">ENAC Clusters</a></li>
<li class="dropdown-item"><a href="#">Interdisciplinary Centers</a></li>
<li class="dropdown-item current-menu-item-parent"><a href="#">FUSTIC association</a></li>
<li class="dropdown-item"><a href="#">Sustainability grants</a></li>
</ul>
</div>
</li>
</ol>
</nav>
63 changes: 59 additions & 4 deletions assets/components/molecules/breadcrumb/breadcrumb-tagged.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,64 @@
<a href="#" class="tag tag-primary">Innovation</a>
<a href="#" class="tag tag-primary">W3C</a>
</li>
<li class="breadcrumb-item"><a href="#">Schools</a></li>
<li class="breadcrumb-item"><a href="#">ENAC</a></li>
<li class="breadcrumb-item"><a href="#">Formations</a></li>
<li class="breadcrumb-item active" aria-current="page">Projets</li>
<li class="breadcrumb-item expand-links">
<button class="btn btn-expand-links" aria-expanded="false" title="Display the complete path">
<span class="dots" aria-hidden="true">…</span>
<span class="sr-only">Display the complete path</span>
</button>
</li>
<li class="breadcrumb-item">
<a class="bread-link" href="#">Schools</a>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-controls="dropdown-menu-1">
{% include '@atoms/icon/icon.twig' with { icon: 'arrow-down-circle', icon_classes:'feather' } %}
<span class="sr-only">Display same level pages – Schools</span>
</button>
<ul class="dropdown-menu" id="dropdown-menu-1">
<li class="dropdown-item"><a href="#">About</a></li>
<li class="dropdown-item"><a href="#">Education</a></li>
<li class="dropdown-item"><a href="#">Research</a></li>
<li class="dropdown-item"><a href="#">Innovation</a></li>
<li class="dropdown-item current-menu-item-parent"><a href="#">Schools</a></li>
<li class="dropdown-item"><a href="#">Campus</a></li>
</ul>
</div>
</li>
<li class="breadcrumb-item">
<a class="bread-link" href="#">School of Architecture, Civil and Environmental Engineering</a>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-controls="dropdown-menu-2">
{% include '@atoms/icon/icon.twig' with { icon: 'arrow-down-circle', icon_classes:'feather' } %}
<span class="sr-only">Display same level pages – School of Architecture, Civil and Environmental Engineering</span>
</button>
<ul class="dropdown-menu" id="dropdown-menu-2">
<li class="dropdown-item current-menu-item-parent"><a href="#">School of Architecture, Civil and Environmental Engineering</a></li>
<li class="dropdown-item"><a href="#">School of Computer and Communication Sciences</a></li>
<li class="dropdown-item"><a href="#">School of Basic Sciences</a></li>
<li class="dropdown-item"><a href="#">School of Engineering</a></li>
<li class="dropdown-item"><a href="#">School of Life Sciences</a></li>
<li class="dropdown-item"><a href="#">College of Management of Technology</a></li>
<li class="dropdown-item"><a href="#">College of Humanities</a></li>
<li class="dropdown-item"><a href="#">Sections</a></li>
</ul>
</div>
</li>
<li class="breadcrumb-item active" aria-current="page">
<span class="bread-item">ENAC Faculty</span>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-controls="dropdown-menu-3">
{% include '@atoms/icon/icon.twig' with { icon: 'arrow-down-circle', icon_classes:'feather' } %}
<span class="sr-only">Display same level pages – ENAC Faculty</span>
</button>
<ul class="dropdown-menu" id="dropdown-menu-3">
<li class="dropdown-item"><a href="#">News</a></li>
<li class="dropdown-item current-menu-item-parent"><a href="#">ENAC Faculty</a></li>
<li class="dropdown-item"><a href="#">Education</a></li>
<li class="dropdown-item"><a href="#">Research</a></li>
<li class="dropdown-item"><a href="#">Sustainability challenges</a></li>
<li class="dropdown-item"><a href="#">Intranet ENAC</a></li>
</ul>
</div>
</li>
</ol>
</nav>
68 changes: 22 additions & 46 deletions assets/components/molecules/breadcrumb/breadcrumb.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,27 @@
/* globals $ */

export default () => {
const breadcrumb = $('#breadcrumb-wrapper');

if ($(breadcrumb).length > 0) { // don't expect to have the breadcrumb on every case
const breadcrumbNode = breadcrumb[0];
const breadcrumbComponent = breadcrumb.find('.breadcrumb');

if ($(window).width() > 1199 &&
$(breadcrumbComponent).length > 0 && // don't expect to have the breadcrumbComponent on every case
breadcrumb.width() < breadcrumbComponent[0].scrollWidth) {
let isDown = false;
let startX;
let scrollLeft;

breadcrumb.on('mousedown', (e) => {
isDown = true;
breadcrumb.addClass('moving');
startX = e.pageX - breadcrumbNode.offsetLeft;
// eslint-disable-next-line
scrollLeft = breadcrumbNode.scrollLeft;
});

breadcrumb.on('mouseleave', () => {
isDown = false;
breadcrumb.removeClass('moving');
});

breadcrumb.on('mouseup', () => {
isDown = false;
breadcrumb.removeClass('moving');
});

breadcrumb.on('mousemove', (e) => {
if (!isDown) return; // stop the fn from running
e.preventDefault();
const x = e.pageX - breadcrumbNode.offsetLeft;
const walk = (x - startX) * 3;
breadcrumbNode.scrollLeft = scrollLeft - walk;
});

breadcrumb.mousewheel((e, delta) => {
e.preventDefault();
breadcrumbNode.scrollLeft -= delta * 40;
});

breadcrumb.find('*').on('dragstart', () => false);
const expandBreadcrumb = $('.btn-expand-links');
const breadcrumbDropToggle = $('.dropdown-toggle');

// add class 'has-expanded-links'
expandBreadcrumb.on('click', () => {
$('.breadcrumb-wrapper .breadcrumb').addClass('has-expanded-links');
});

// improve dropdown position
breadcrumbDropToggle.on('click', (e) => {
const btnPos = $(e.currentTarget).offset().left;
const documentWitdh = $(document).width();
const dropdown = $(e.currentTarget).siblings('.dropdown-menu');
const dropdownWidth = dropdown.width();
const btnOffset = documentWitdh - btnPos;

// remove class 'open-left' from all .dropdown-menu elements
$('.dropdown-menu').removeClass('open-left');
// add the class back if the dropdown is too close to the right side of the window
if (dropdownWidth > btnOffset) {
dropdown.addClass('open-left');
}
}
});
};
Loading
Loading