/* Copyright 2025 The Forgejo Authors. All rights reserved. * SPDX-License-Identifier: GPL-3.0-or-later */ /* This is an implementation of a dropdown menu based on details HTML tag. * It is inspired by https://picocss.com/docs/dropdown. * * NoJS mode could be improved by forcing the same [name] onto all dropdowns, so * that the browser will automatically close all but the one that was just opened * using keyboard. But the code doing that will not be as clean. * * Note: when implementing this dropdown, please use `dropdown` as the 1st class, * so it is possible to search for all dropdowns with `details class="dropdown` */ :root details.dropdown { --dropdown-box-shadow: 0 6px 18px var(--color-shadow); --dropdown-item-min-height: 34px; --dropdown-padding-inline: 0.75rem; } @media (pointer: coarse) { :root details.dropdown { --dropdown-item-min-height: 40px; --dropdown-padding-inline: 1rem; } } details.dropdown { position: relative; } /* Opener */ details.dropdown > summary { /* Optional flex+gap in case summary contains multiple elements */ display: flex; gap: 0.25rem; align-items: center; justify-content: center; /* Main visual properties */ border-radius: var(--border-radius); padding: 0.5rem; /* Unset unwanted default properties */ user-select: none; list-style-type: none; /* Display a border around opener */ &.border { border: 1px solid var(--color-light-border); } /* Increase inline padding - for openers with text, like filter menus */ &.options { padding-inline: 0.75rem; } } /* NoJS mode: create a virtual fullscreen area which closes the dropdown when clicked on */ .no-js details.dropdown[open] > summary::before { z-index: 1; position: fixed; width: 100vw; height: 100vh; inset: 0; background: 0 0; content: ""; cursor: default; } details.dropdown > summary:hover, details.dropdown > .content > ul > li > :is(a, button):hover { background: var(--color-hover); } details.dropdown[open] > summary, details.dropdown > .content > ul > li:focus-within > :is(a, button) { background: var(--color-active); } details.dropdown > .content { z-index: 99; position: absolute; min-width: max-content; border-radius: var(--border-radius); background: var(--color-body); box-shadow: var(--dropdown-box-shadow); border: 1px solid var(--color-secondary); margin-top: 0.5rem; /* ToDo: upstream to base.css, remove from normalize.css */ hr { height: 1px; margin-block: 0.25rem; background-color: var(--color-secondary); } } details.dropdown > .content > ul { /* Suppress default styling of