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

fix: Fix group headers positionning #722

Merged
merged 1 commit into from
Oct 31, 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: 2 additions & 0 deletions src/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ModalOpenerController from './controllers/modal_opener_controller.js';
import NewsRefresherController from './controllers/news_refresher_controller.js';
import PopupController from './controllers/popup_controller.js';
import TextEditorController from './controllers/text_editor_controller.js';
import ZindexInverserController from './controllers/zindex_inverser_controller.js';

window.jsConfiguration = JSON.parse(document.getElementById('javascript-configuration').innerHTML);

Expand All @@ -37,6 +38,7 @@ application.register('modal-opener', ModalOpenerController);
application.register('news-refresher', NewsRefresherController);
application.register('popup', PopupController);
application.register('text-editor', TextEditorController);
application.register('zindex-inverser', ZindexInverserController);

function adaptLayoutContentBorderRadius () {
const layoutContentNode = document.querySelector('.layout__content');
Expand Down
15 changes: 15 additions & 0 deletions src/assets/javascripts/controllers/zindex_inverser_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Controller } from '@hotwired/stimulus';

export default class extends Controller {
static get targets () {
return ['item'];
}

connect () {
const baseZindex = 10;
const zindexMax = this.itemTargets.length;
this.itemTargets.forEach((item, index) => {
item.style.zIndex = baseZindex + zindexMax - index;
});
}
}
50 changes: 1 addition & 49 deletions src/assets/stylesheets/custom/groups.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

.group__header {
position: sticky;
z-index: 1;
top: 0;

display: flex;
Expand All @@ -16,55 +17,6 @@
box-shadow: 0 2px 2px var(--color-white);
}

/**
* This is a hack to create a descending z-index priority over the
* group__headers. This is because if a group__header has a popup menu in it,
* the stacking context (created because of the sticky property) makes it
* appear below the next group__header. This is the case in the news for
* instance.
* The hack only works for 10 elements, but hopefully, this should be enough
* most of the time.
*/
.group:nth-child(1) .group__header {
z-index: 20;
}

.group:nth-child(2) .group__header {
z-index: 19;
}

.group:nth-child(3) .group__header {
z-index: 18;
}

.group:nth-child(4) .group__header {
z-index: 17;
}

.group:nth-child(5) .group__header {
z-index: 16;
}

.group:nth-child(6) .group__header {
z-index: 15;
}

.group:nth-child(7) .group__header {
z-index: 14;
}

.group:nth-child(8) .group__header {
z-index: 13;
}

.group:nth-child(9) .group__header {
z-index: 12;
}

.group:nth-child(10) .group__header {
z-index: 11;
}

.group__icon {
margin-right: var(--space-smaller);
}
Expand Down
Loading
Loading