-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f2a3f8f
chore(docs): use dev build with gallery component
brandyscarney c41b22e
docs(gallery): add gallery component page
brandyscarney 287ee58
docs(gallery): add demo images
brandyscarney be549a5
docs(gallery): add basic usage example
brandyscarney 11a67e9
docs(gallery): add uniform playground
brandyscarney 55aa0c3
docs(gallery): add masonry-sequential playground
brandyscarney 05d17cf
docs(gallery): add masonry-best-fit playground
brandyscarney 1e8efd6
docs(gallery): import all layout playgrounds in guide
brandyscarney b50ae90
docs(gallery): add columns playground
brandyscarney a685b8a
docs(gallery): import columns playground in guide
brandyscarney 6bf3b63
docs(gallery): add masonry images playground
brandyscarney 95fbb1e
docs(gallery): import masonry images playground in guide
brandyscarney 0a83883
docs(gallery): add section descriptions and update intro
brandyscarney 464dc7b
docs(gallery): include default columns by breakpoint
brandyscarney 8888971
chore: use latest dev build
brandyscarney e932d1e
docs(gallery): update vue examples to vue syntax
brandyscarney bb92803
style: lint
brandyscarney 45123db
docs(gallery): add a note to playgrounds about css being for demo pur…
brandyscarney c2a85bb
docs(gallery): include code block for wrapped images
brandyscarney 5e1f734
docs(gallery): a nested img needs to inherit aspect-ratio in case of …
brandyscarney f0d4b08
chore(): update to latest dev build
brandyscarney c289e9f
docs(gallery): add playground for gap
brandyscarney 44012ff
chore(): revert dev builds and document required one
brandyscarney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| --- | ||
| 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. | ||
|
|
||
| :::tip | ||
| 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, for example: | ||
|
|
||
| ```css | ||
| figure img { | ||
| display: block; | ||
|
|
||
| object-fit: cover; | ||
| object-position: center; | ||
|
|
||
| aspect-ratio: inherit; | ||
| } | ||
| ``` | ||
| ::: | ||
|
|
||
| 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 /> | ||
|
|
||
| ## Gap | ||
|
|
||
| Gap can be configured with the `gap` property using either a single value for a fixed gap, or a breakpoint map to change gap across screen sizes. | ||
|
|
||
| If no value is provided, or if an invalid value is used, the gallery falls back to its default gap value. The default value is `16px`. | ||
|
|
||
| import Gap from '@site/static/usage/v9/gallery/gap/index.md'; | ||
|
|
||
| <Gap /> | ||
|
|
||
| ## 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 /> | ||
|
brandyscarney marked this conversation as resolved.
|
||
|
|
||
| ## Events | ||
| <Events /> | ||
|
|
||
| ## Methods | ||
| <Methods /> | ||
|
|
||
| ## CSS Shadow Parts | ||
| <Parts /> | ||
|
|
||
| ## CSS Custom Properties | ||
| <CustomProps /> | ||
|
|
||
| ## Slots | ||
| <Slots /> | ||
|
brandyscarney marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
brandyscarney marked this conversation as resolved.
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
static/usage/v9/gallery/basic/angular/example_component_html.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ```html | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Gallery</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <ion-gallery> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/01.png" alt="Image 1" /> | ||
|
brandyscarney marked this conversation as resolved.
|
||
| <img src="https://ionicframework.com/docs/img/demos/gallery/02.png" alt="Image 2" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/03.png" alt="Image 3" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/04.png" alt="Image 4" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/05.png" alt="Image 5" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/06.png" alt="Image 6" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/07.png" alt="Image 7" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/08.png" alt="Image 8" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/09.png" alt="Image 9" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/10.png" alt="Image 10" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/11.png" alt="Image 11" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/12.png" alt="Image 12" /> | ||
| </ion-gallery> | ||
| </ion-content> | ||
| ``` | ||
12 changes: 12 additions & 0 deletions
12
static/usage/v9/gallery/basic/angular/example_component_ts.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ```ts | ||
| import { Component } from '@angular/core'; | ||
| import { IonContent, IonGallery, IonHeader, IonTitle, IonToolbar } from '@ionic/angular/standalone'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-example', | ||
| templateUrl: 'example.component.html', | ||
| styleUrls: ['example.component.css'], | ||
| imports: [IonContent, IonGallery, IonHeader, IonTitle, IonToolbar], | ||
| }) | ||
| export class ExampleComponent {} | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Gallery</title> | ||
| <link rel="stylesheet" href="../../common.css" /> | ||
| <script src="../../common.js"></script> | ||
| <script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@8/dist/ionic/ionic.esm.js"></script> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@8/css/ionic.bundle.css" /> | ||
|
|
||
| <style> | ||
| /* Content padding + home indicator height */ | ||
| .ios { | ||
| --ion-safe-area-bottom: 36px; | ||
| } | ||
|
|
||
| ion-content::part(scroll) { | ||
| padding-bottom: var(--ion-safe-area-bottom, 0); | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <ion-app> | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Gallery</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <ion-gallery> | ||
| <img src="/docs/img/demos/gallery/01.png" alt="Image 1" /> | ||
| <img src="/docs/img/demos/gallery/02.png" alt="Image 2" /> | ||
| <img src="/docs/img/demos/gallery/03.png" alt="Image 3" /> | ||
| <img src="/docs/img/demos/gallery/04.png" alt="Image 4" /> | ||
| <img src="/docs/img/demos/gallery/05.png" alt="Image 5" /> | ||
| <img src="/docs/img/demos/gallery/06.png" alt="Image 6" /> | ||
| <img src="/docs/img/demos/gallery/07.png" alt="Image 7" /> | ||
| <img src="/docs/img/demos/gallery/08.png" alt="Image 8" /> | ||
| <img src="/docs/img/demos/gallery/09.png" alt="Image 9" /> | ||
| <img src="/docs/img/demos/gallery/10.png" alt="Image 10" /> | ||
| <img src="/docs/img/demos/gallery/11.png" alt="Image 11" /> | ||
| <img src="/docs/img/demos/gallery/12.png" alt="Image 12" /> | ||
| </ion-gallery> | ||
| </ion-content> | ||
| </ion-app> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ```html | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Gallery</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <ion-gallery> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/01.png" alt="Image 1" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/02.png" alt="Image 2" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/03.png" alt="Image 3" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/04.png" alt="Image 4" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/05.png" alt="Image 5" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/06.png" alt="Image 6" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/07.png" alt="Image 7" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/08.png" alt="Image 8" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/09.png" alt="Image 9" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/10.png" alt="Image 10" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/11.png" alt="Image 11" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/12.png" alt="Image 12" /> | ||
| </ion-gallery> | ||
| </ion-content> | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ```tsx | ||
| import React from 'react'; | ||
| import { IonContent, IonGallery, IonHeader, IonTitle, IonToolbar } from '@ionic/react'; | ||
|
|
||
| function Example() { | ||
| return ( | ||
| <> | ||
| <IonHeader> | ||
| <IonToolbar> | ||
| <IonTitle>Gallery</IonTitle> | ||
| </IonToolbar> | ||
| </IonHeader> | ||
| <IonContent className="ion-padding"> | ||
| <IonGallery> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/01.png" alt="Image 1" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/02.png" alt="Image 2" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/03.png" alt="Image 3" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/04.png" alt="Image 4" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/05.png" alt="Image 5" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/06.png" alt="Image 6" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/07.png" alt="Image 7" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/08.png" alt="Image 8" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/09.png" alt="Image 9" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/10.png" alt="Image 10" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/11.png" alt="Image 11" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/12.png" alt="Image 12" /> | ||
| </IonGallery> | ||
| </IonContent> | ||
| </> | ||
| ); | ||
| } | ||
| export default Example; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| ```vue | ||
| <template> | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Gallery</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <ion-gallery> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/01.png" alt="Image 1" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/02.png" alt="Image 2" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/03.png" alt="Image 3" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/04.png" alt="Image 4" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/05.png" alt="Image 5" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/06.png" alt="Image 6" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/07.png" alt="Image 7" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/08.png" alt="Image 8" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/09.png" alt="Image 9" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/10.png" alt="Image 10" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/11.png" alt="Image 11" /> | ||
| <img src="https://ionicframework.com/docs/img/demos/gallery/12.png" alt="Image 12" /> | ||
| </ion-gallery> | ||
| </ion-content> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { IonContent, IonGallery, IonHeader, IonTitle, IonToolbar } from '@ionic/vue'; | ||
| </script> | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.