Skip to content

part info: fan out the part's pictures on hover, click to pick the preview - #1575

Open
samyk wants to merge 4 commits into
Part-DB:masterfrom
samyk:picture-fan
Open

samyk wants to merge 4 commits into
Part-DB:masterfrom
samyk:picture-fan

Conversation

@samyk

@samyk samyk commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

A part with several pictures only shows one at a time on its info page; finding a particular one means clicking through the carousel, and making another one the preview picture means going to the edit form.

With this, hovering the picture of a part that has more than one fans all of its pictures out to the right as thumbnails (160px, four per row, further ones wrap). Hovering a thumbnail highlights it, clicking it shows it in the main slot, and moving the mouse away from the picture and the fan collapses it again.

If the user may edit the part, the click also saves that picture as the part's preview picture, so the choice sticks and shows up in tables:

  • new route POST /{id}/set_master_picture (part_set_master_picture), denyAccessUnlessGranted('edit', $part) plus a CSRF token
  • it only accepts a picture attachment of the part itself, the same restriction as the preview picture select in the edit form
  • the save data is only rendered when the user may edit the part and the page is not a time-travel view; without it, and for pictures inherited from the footprint, category etc., a click just switches the displayed picture

Details:

  • Stimulus controller plus CSS; the collapsed pictures are stacked behind the main one and travel out with a short staggered transition (disabled under prefers-reduced-motion).
  • Limited to (hover: hover) and (pointer: fine) and (min-width: 768px): touch devices and narrow layouts keep the plain carousel, and the carousel controls stay usable by keyboard.
  • Parts with a single picture get no extra markup and behave as before.
  • For parts that have the fan, the carousel's dark hover overlay with the caption is not shown, as it made the picture one is choosing for harder to see.
  • The current preview picture is marked with a small dot in the fan.

One new translation string (part.info.picture_fan.label).

Not covered: no PHPUnit test for the new route, and a failed save is only logged to the console (the picture still switches).

samyk added 4 commits October 3, 2026 14:38
With several pictures the carousel only shows one at a time and the others
have to be paged through. Hovering the picture now fans all pictures of the
part out to its right as thumbnails (pure CSS, only on devices with a real
hover and from the md breakpoint up, so touch devices and single-picture
parts keep the plain carousel). A click on a thumbnail shows that picture in
the carousel.

If the user may edit the part, the click also saves the picture as the
part's preview picture through a new CSRF-protected POST route
(part_set_master_picture), so the choice sticks and shows up in the tables.
Like the master picture select of the edit form, only picture attachments
of the part itself are accepted; pictures inherited from the footprint,
category etc. and time travel views are view-only.
The fanned out pictures were 76px, too small to tell similar photos apart;
they are 160px now (four per row, from the 250px thumbnails). The carousel's
dark hover overlay made the picture one is choosing for harder to see, so it
is not shown for parts that have the fan.
@jbtronics

Copy link
Copy Markdown
Member

Being honest I had some hard time to understand, what this feature should do based from your text.

But i get it now and tried it out.

I think at the moment this looks more like just some reading overview of all pictures, but users wont really understand that it changes the preview image, and that happens to easily, without much feedback on what happened.

I could see this as some purely read only view to scroll through all associated images at quick glance (but then the flickering overscoll bars should be fixed).

If you want to have this as some editing feature, it should be behind some button, etc. that explains the meaning of the following action. To be honest i am not sure if that is really a useful feature, as I normally do not need to change the preview image and I prefer a clear seperation of editing and viewing a part.

Maybe something like this could be useful for selecting the preview image on the part edit page. But I have (inspired by your PR) added already some small preview images to the preview picture selector, which should make picking the right one a bit easier.

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