Responsive option with parent container

Created on 27 August 2024, 4 months ago

I have the toc module enabled on a test client site - https://www.gordillo.legal - and am seeing some potential improvements.

The parent container selector works great for desktop, allowing a natural grouping of a sidebar. But on mobile widths it ends up being too long.

Would it be possible to add the following:

  • Default (mobile) ToC container selector
  • Mobile breakpoint
    • Pixels
    • REM
  • Wide ToC container selector

This would allow the grouping at larger widths and just having the ToC at narrower device widths.

Also, unrelated, but is there an SEO reason to have the "Table of Contents" label - just curious. I've tested hiding it with CSS, and am currently thinking I'll also hide that for mobile, but show for tablet/desktop.

✨ Feature request
Status

Closed: won't fix

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States w01f

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @w01f
  • Status changed to Closed: won't fix 4 months ago
  • πŸ‡«πŸ‡·France mably

    This particular case should be handled in your site theme. 2 sizes in definitely not enough, some people will need to be able to handle 3 or more different size levels... This definitely belongs to your theme CSS files.

    The ToC title configuration option can be left empty or hidden in CSS as you did, I'm not a SEO expert so won't be able to give a more precise answer.

  • πŸ‡ΊπŸ‡ΈUnited States w01f

    I disagree here - I think 2 sizes for basically choosing to group ToC with sibling elements on a larger screen that has more real estate, or limit to just the floating ToC on limited size mobile, would be sufficient for 95+% cases.

    But we can rig something very simple up to unset the siblings on mobile for our case I think.

  • πŸ‡«πŸ‡·France mably

    Could you explain what can't be done in CSS exactly?

  • πŸ‡ΊπŸ‡ΈUnited States w01f

    Currently the parent container works exceptionally well on desktop.

    In the Gordillo.Legal example, it allows the ToC and social media links to float together.

    The real estate issue only happens on mobile devices. The ToC floats correctly and helpfully at the top (as long as the blog doesn't have too many headers, but I don't know a solution for that case). But the sibling elements also float which becomes obstructive.

    If we could tweak the js target, that would solve this issue:
    1. Target only ToC by default.
    2. If parent container is defined, target that.
    3. If parent container breakpoint is defined, switch from ToC to parent container at that point.

  • πŸ‡«πŸ‡·France mably

    Added an MR to this issue that allows you to override the default way to get the toc container.

    You can check the code here: https://git.drupalcode.org/project/toc_js/-/merge_requests/21/diffs

    It should allows you to do whatever you want to select the right container you are interested in.

Production build 0.71.5 2024