Skip to content

homepage: allow closing/restoring the banner and license boxes - #1576

Open
samyk wants to merge 3 commits into
Part-DB:masterfrom
samyk:homepage-dismiss
Open

samyk wants to merge 3 commits into
Part-DB:masterfrom
samyk:homepage-dismiss

Conversation

@samyk

@samyk samyk commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

The banner (instance name and version) and the license box take up the top of the homepage on every visit, which is useful once and then mostly pushes the rest down.

Both boxes now have a close button (x, top right). A closed box stays closed across reloads and Turbo navigations. While anything is hidden, the user dropdown in the navbar shows a "Restore hidden homepage boxes" entry that brings everything back with one click, without a reload.

How it works:

  • The list of closed boxes is kept in a cookie (dismissed_boxes, per browser, path=/, one year, SameSite=Lax, refreshed on page load while non-empty). A cookie rather than localStorage so that Twig can render a closed box with the hidden attribute already in the HTML: nothing flashes up before the JavaScript runs.
  • templates/components/dismissible.macro.html.twig makes any box closable: {{ dismissible.attributes('unique_id') }} on the element and {{ dismissible.close_button() }} inside it. Only the banner and the license box are wired up here.
  • Two small Stimulus controllers (the box, and the restore entry) and a shared helper for the cookie.
  • The close buttons use Bootstrap's btn-close (white variant on the license header) with title and aria-label; no custom CSS.

Two new translation strings (homepage.dismiss_box, homepage.restore_boxes).

Notes for review:

  • The state is per browser, not per user. If you would rather have localStorage (like the darkmode and sidebar settings) or a user preference, I can change it; the cookie was chosen only for the no-flash rendering.
  • Safari caps script-set cookies at 7 days, so there the boxes come back after a week without a visit.
  • The spacer below a hidden box stays, leaving a slightly larger gap.

samyk added 2 commits October 3, 2026 14:11
The banner (instance name and version) and the license information take up
most of the homepage, but are rarely of interest after the first visit. Both
now have a close button, and the user dropdown in the navbar gets an entry
"Restore hidden homepage boxes" (only shown while something is hidden),
which brings them back.

The closed boxes are remembered per browser in a cookie rather than in the
local storage, so that the server can already render them hidden. That way
they do not flash up on page load before the javascript has run. The
mechanism is generic: any box can be made closable with the macros in
components/dismissible.macro.html.twig and a unique id.
@jbtronics

Copy link
Copy Markdown
Member

Hmm, i am wondering how necessary this feature is. You can simply disable the banner and license infos completly via the system settings. I guess nobody would ever reopen the license info panel again, after he closed it.

For the banner it might be more useful to make it dismissable, and it probably does not hurt to have this feature and it might be useful for other occasions to have the infrastructure for dismissable panels existing.

@samyk

samyk commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

I hear you. Just a personal preference on UX, I like when settings/modifications are easy to control inline directly at the location that stimulates the desire (eg seeing the large boxes and wanting them to go away in this case). Part-DB is awesome but I'm still learning it and walking through every setting from the various settings areas takes time and also requires users to even know it's possible in the first place (to be fair I haven't spent a ton of time on all of those pages as there are so many great features and tweaks that are possible).

I will probably continue to add more inline support for things, and totally understand if that's not desired, but ideally I will try to have things adjust existing backend settings so they're always re-adjustable with the same architecture. I'm just a sucker for reducing clicks. :)

@jbtronics

Copy link
Copy Markdown
Member

I tried it out, and i think its fine to let users hide these panels for themselves.

But i do not really find the restore button in the navbar dropdown really intuitive. I think it would be better directly somewhere on the homepage.

For some more universal applicability, it would be good, to maybe add some site wide prefix, or something and then restore everything with that prefix when the restore button is clicked.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants