feat(gallery): add new required gallery-item component for child items#31195
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| div { | ||
| ion-gallery-item { | ||
| color: #fff; | ||
| height: 150px; |
There was a problem hiding this comment.
I moved this to be on the items themselves because I can't apply them to all items or the ones containing img will also get an explicit height.
| @@ -58,7 +58,7 @@ configs({ directions: ['ltr'], modes: ['md'] }).forEach(({ config, screenshot, t | |||
| await expect(gallery).toHaveScreenshot(screenshot(`gallery-${layout}${orderSuffix}-divs-same-height`)); | |||
There was a problem hiding this comment.
I didn't change the name of this to replace divs with items so you could see there are not diffs on these but I can update them after it's been reviewed if desired.
ShaneK
left a comment
There was a problem hiding this comment.
This is looking really cool! I just had some change requests and some nits, but I'm loving the way it's looking!
ShaneK
left a comment
There was a problem hiding this comment.
Awesome work! Looks good to me 🚀
thetaPC
left a comment
There was a problem hiding this comment.
LGTM, left suggestions but not blockers
|
|
||
| import { sharedGalleryStyles } from '../utils'; | ||
|
|
||
| const LAYOUT_OPTIONS = ['uniform', 'masonry']; |
There was a problem hiding this comment.
We might want to create const like we've been doing in the Modular Ionic so we can pass them to tests and the component itself. Doesn't have to happen now, but it'll have to during the migration.
| const LAYOUT_OPTIONS = ['uniform', 'masonry']; | |
| export const ION_GALLERY_LAYOUT_OPTIONS = ['uniform', 'masonry']as const; | |
| export type IonGalleryLayout = (typeof ION_GALLERY_LAYOUT_OPTIONS)[number]; |
There was a problem hiding this comment.
I'd rather just do that during the migration if that's okay since we will need to create the interfaces file and everything.

Issue number: internal
What is the current behavior?
The Gallery component queries all direct children and uses them to build both the uniform and masonry layouts. This causes issues when a wrapper element exists between the gallery and the gallery items. For example:
In this scenario, the gallery treats the wrapper as a single item and does not correctly lay out the images contained within it.
What is the new behavior?
Several approaches were considered:
ion-gallery-itemcomponent that encapsulates all item-related styling and can contain arbitrary content (img, div, etc.).We ultimately chose option 3 and introduced a new
ion-gallery-itemcomponent. Theion-gallerycomponent now queries forion-gallery-itemelements instead of relying on direct children.As such, this PR does the following:
ion-gallery-itemcomponent.ion-galleryto query forion-gallery-itemelements.ion-gallery-item.Does this introduce a breaking change?
Other information
Dev build:
8.8.9-dev.11781201980.1b6e8398Previews: