diff --git a/src/assets/javascripts/application.js b/src/assets/javascripts/application.js index 207c79be..d91c52a1 100644 --- a/src/assets/javascripts/application.js +++ b/src/assets/javascripts/application.js @@ -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); @@ -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'); diff --git a/src/assets/javascripts/controllers/zindex_inverser_controller.js b/src/assets/javascripts/controllers/zindex_inverser_controller.js new file mode 100644 index 00000000..4cd3242a --- /dev/null +++ b/src/assets/javascripts/controllers/zindex_inverser_controller.js @@ -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; + }); + } +} diff --git a/src/assets/stylesheets/custom/groups.css b/src/assets/stylesheets/custom/groups.css index 3f8a4bb2..44cd62b7 100644 --- a/src/assets/stylesheets/custom/groups.css +++ b/src/assets/stylesheets/custom/groups.css @@ -4,6 +4,7 @@ .group__header { position: sticky; + z-index: 1; top: 0; display: flex; @@ -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); } diff --git a/src/views/news/index.phtml b/src/views/news/index.phtml index 6c830998..e47693a3 100644 --- a/src/views/news/index.phtml +++ b/src/views/news/index.phtml @@ -13,193 +13,195 @@ empty()): ?> - datesGroups() as $date_group): ?> -
-
-

- date, 'dd MMMM') ?> - - isToday()): ?> - - isYesterday()): ?> - - -

- -
- - -
- -
- links as $link): ?> - include('links/_link.phtml', [ - 'link' => $link, - 'from' => \Minz\Url::for('news'), - 'display_edit' => true, - 'display_repair' => true, - 'display_source' => true, - 'display_read_later' => true, - 'display_mark_as_read' => true, - 'display_never' => true, - 'storing_must_mark_as_read' => true, - ]); ?> - -
- - sourceGroups() as $source_group): ?> -
-
-

- title) ?> - - - ⋅ links), count($source_group->links)) ?> - -

- - + + +
+ links as $link): ?> + include('links/_link.phtml', [ + 'link' => $link, + 'from' => \Minz\Url::for('news'), + 'display_edit' => true, + 'display_repair' => true, + 'display_source' => true, + 'display_read_later' => true, + 'display_mark_as_read' => true, + 'display_never' => true, + 'storing_must_mark_as_read' => true, + ]); ?> + +
-
- links as $link): ?> - include('links/_link.phtml', [ - 'link' => $link, - 'from' => \Minz\Url::for('news'), - 'display_edit' => true, - 'display_repair' => true, - 'display_source' => true, - 'display_read_later' => true, - 'display_mark_as_read' => true, - 'display_never' => true, - 'storing_must_mark_as_read' => true, - ]); ?> - + sourceGroups() as $source_group): ?> +
+
+

+ title) ?> + + + ⋅ links), count($source_group->links)) ?> + +

+ + +
+ +
+ links as $link): ?> + include('links/_link.phtml', [ + 'link' => $link, + 'from' => \Minz\Url::for('news'), + 'display_edit' => true, + 'display_repair' => true, + 'display_source' => true, + 'display_read_later' => true, + 'display_mark_as_read' => true, + 'display_never' => true, + 'storing_must_mark_as_read' => true, + ]); ?> + +
-
- -
- + + + +