Skip to content

Make thumbnails grid- and flexbox-compatible #905

@alexisthual

Description

@alexisthual

At the moment, sphinx-gallery generates a div for each gallery item.
These divs are float: left and have a pre-determined width, which does not render very nicely on most screen sizes or for long titles.

I suggest that for each subsection of the gallery, we add a parent div to these item divs.
This would allow users to either use css grid or flex (which we could also implement here directly).
It boils down to adding a new div before iterating through each gallery item and closing this div after:

entries_text = []
costs = []
build_target_dir = os.path.relpath(target_dir, gallery_conf['src_dir'])
iterator = sphinx_compatibility.status_iterator(
sorted_listdir,
'generating gallery for %s... ' % build_target_dir,
length=len(sorted_listdir))
for fname in iterator:
intro, title, cost = generate_file_rst(
fname, target_dir, src_dir, gallery_conf, seen_backrefs)
src_file = os.path.normpath(os.path.join(src_dir, fname))
costs.append((cost, src_file))

Also, maybe we could use sphinx-design to handle the grid for us, but this would add a new dependency.

Happy to here what you think about this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions