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

[RW-826][CD-530] Reduce CLS in Global Header #458

Merged
merged 2 commits into from
Jan 16, 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
2 changes: 1 addition & 1 deletion libraries/cd/cd-header/cd-global-header.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
gap: 8px;
}

.cd-global-header__inner .cd-ocha {
.cd-global-header__inner #cd-ocha-services-container {
order: -1;
}

Expand Down
11 changes: 6 additions & 5 deletions libraries/cd/cd-header/cd-ocha-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@

Drupal.behaviors.cdOchaServices = {
attach: function (context, settings) {
// Move the OCHA services section to the header.
this.moveToHeader('cd-ocha-services', 'cd-global-header__actions');
// Move the OCHA Services section to the header.
this.moveToHeader('cd-ocha-services', 'cd-ocha-services-container');
},

/**
* Hide and move OCHA Services to the top of the header after the target.
*/
moveToHeader: function (id, target) {
var section = document.getElementById(id);
var sibling = document.getElementById(target);
if (section && sibling) {
var container = document.getElementById(target);

if (section && container) {
// Ensure the element is hidden before moving it to avoid flickering.
this.toggleVisibility(section, true);
sibling.parentNode.insertBefore(section, sibling);
container.appendChild(section);
}
},

Expand Down
128 changes: 99 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions templates/cd/cd-header/cd-global-header.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="cd-global-header">
<div class="cd-container cd-global-header__inner">

<div id="cd-ocha-services-container"></div>
{{ page.header_top }}

</div>
Expand Down
Loading