-
Notifications
You must be signed in to change notification settings - Fork 3.2k
docs(gallery): add documentation for new gallery component #4484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: major-9.0
Are you sure you want to change the base?
Changes from all commits
f2a3f8f
c41b22e
287ee58
be549a5
11a67e9
55aa0c3
05d17cf
1e8efd6
b50ae90
a685b8a
6bf3b63
95fbb1e
0a83883
464dc7b
8888971
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| --- | ||
| title: "ion-gallery" | ||
| --- | ||
|
|
||
| import Props from '@ionic-internal/component-api/v9/gallery/props.md'; | ||
| import Events from '@ionic-internal/component-api/v9/gallery/events.md'; | ||
| import Methods from '@ionic-internal/component-api/v9/gallery/methods.md'; | ||
| import Parts from '@ionic-internal/component-api/v9/gallery/parts.md'; | ||
| import CustomProps from '@ionic-internal/component-api/v9/gallery/custom-props.mdx'; | ||
| import Slots from '@ionic-internal/component-api/v9/gallery/slots.md'; | ||
|
|
||
| <head> | ||
| <title>ion-gallery: Responsive Uniform and Masonry Gallery Layouts</title> | ||
| <meta | ||
| name="description" | ||
| content="The gallery arranges images, cards, and other content in responsive uniform or masonry layouts with configurable column counts and masonry ordering modes." | ||
| /> | ||
| </head> | ||
|
|
||
| import EncapsulationPill from '@components/page/api/EncapsulationPill'; | ||
|
|
||
| <EncapsulationPill type="shadow" /> | ||
|
|
||
| The gallery arranges images, cards, and other content in a responsive grid. It supports uniform and masonry layouts, configurable column counts (fixed or breakpoint-based), and multiple masonry ordering modes. | ||
|
|
||
| ## Basic Usage | ||
|
|
||
| import Basic from '@site/static/usage/v9/gallery/basic/index.md'; | ||
|
|
||
| <Basic /> | ||
|
|
||
| ## Uniform | ||
|
|
||
| Uniform is the default layout. It creates a consistent grid where items appear at the same visual size with a `1 / 1` aspect ratio. This layout is ideal when visual alignment is more important than preserving each item's natural height. | ||
|
|
||
| import Uniform from '@site/static/usage/v9/gallery/uniform/index.md'; | ||
|
|
||
| <Uniform /> | ||
|
|
||
| ## Masonry | ||
|
|
||
| Masonry preserves each item's natural height and stacks items vertically within each column, creating a staggered layout with minimal gaps. Masonry supports two ordering modes: sequential and best fit. | ||
|
|
||
| :::important | ||
| Avoid adding margin to top-level items in a masonry layout, as it can cause incorrect item placement. To add spacing, wrap the content in a child element and apply margin to that wrapper instead. | ||
| ::: | ||
|
|
||
| ### Sequential | ||
|
|
||
| Sequential is the default masonry ordering mode. Items are placed in DOM order, filling columns from left to right. | ||
|
|
||
| import MasonrySequential from '@site/static/usage/v9/gallery/masonry-sequential/index.md'; | ||
|
|
||
| <MasonrySequential /> | ||
|
|
||
| ### Best Fit | ||
|
|
||
| Best fit places each item in the column with the most available space, helping balance column heights. | ||
|
|
||
| import MasonryBestFit from '@site/static/usage/v9/gallery/masonry-best-fit/index.md'; | ||
|
|
||
| <MasonryBestFit /> | ||
|
|
||
| ### Images | ||
|
|
||
| In masonry layouts, top-level `img` elements are given default styles to ensure consistent rendering. These styles make images fill their container while preserving their aspect ratio and keeping them centered. | ||
|
|
||
| :::note | ||
| Images wrapped in other elements (for example, inside a `figure`) do not inherit these defaults. Apply the same styles to the nested `img` if you want matching behavior. | ||
| ::: | ||
|
|
||
| import Images from '@site/static/usage/v9/gallery/images/index.md'; | ||
|
|
||
| <Images /> | ||
|
|
||
| ## Columns | ||
|
|
||
| Columns can be configured with the `columns` property using either a single number for a fixed column count, or a breakpoint map to change columns across screen sizes. | ||
|
|
||
| If no value is provided, or if an invalid value is used, the gallery falls back to its default responsive column behavior. The default column counts by breakpoint are: | ||
|
|
||
| | Breakpoint | Min Width | Default Columns | | ||
| | --- | --- | ---| | ||
| | `xs` | `0` | `2` | | ||
| | `sm` | `576px` | `3` | | ||
| | `md` | `768px` | `4` | | ||
| | `lg` | `992px` | `6` | | ||
| | `xl` | `1200px` | `8` | | ||
| | `xxl` | `1400px` | `10` | | ||
|
|
||
| import Columns from '@site/static/usage/v9/gallery/columns/index.md'; | ||
|
|
||
| <Columns /> | ||
|
|
||
| ## Interfaces | ||
|
|
||
| ### GalleryBreakpointColumns | ||
|
|
||
| ```typescript | ||
| interface GalleryBreakpointColumns { | ||
| xs?: string | number; | ||
| sm?: string | number; | ||
| md?: string | number; | ||
| lg?: string | number; | ||
| xl?: string | number; | ||
| xxl?: string | number; | ||
| } | ||
| ``` | ||
|
|
||
| ## Types | ||
|
|
||
| ### GalleryColumns | ||
|
|
||
| ```typescript | ||
| type GalleryColumns = GalleryBreakpointColumns | string | number; | ||
| ``` | ||
|
|
||
| ## Properties | ||
| <Props /> | ||
|
|
||
| ## Events | ||
| <Events /> | ||
|
|
||
| ## Methods | ||
| <Methods /> | ||
|
|
||
| ## CSS Shadow Parts | ||
| <Parts /> | ||
|
|
||
| ## CSS Custom Properties | ||
| <CustomProps /> | ||
|
|
||
| ## Slots | ||
| <Slots /> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love this location of images used by the demos but other demos use this as well so I followed the existing structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to add this under "Grids" because otherwise we would need to redo the component page to either add a new image for a top-level Gallery section or to add something like "Layout" which would reorder a few of them. I can change this if we want to categorize this differently.