Skip to main content

upp-grid

A configurable grid layout component that displays items in either GRID or LIST view mode. It persists its view mode and thumbnail size through the application's configService, so user preferences survive navigation. Supports an empty-state slot and works together with upp-grid-item to propagate view mode changes to child components (e.g., upp-thumb).

When to Use

  • You need a catalog or product listing that can switch between grid and list layouts.
  • You want view mode preferences to persist across sessions via configuration.
  • You need an empty-state placeholder when there are no items to display.
  • You are building a responsive item browser with adjustable thumbnail sizes.

Demo

Source Code

<h2>upp-grid</h2>
<p class="demo-description">Product catalog using <code>upp-grid</code> with view mode, scale, and empty state.</p>

<div class="demo-controls">
<ion-button size="small" (click)="toggleViewMode()">
<ion-icon [name]="viewMode === 'GRID' ? 'grid-outline' : 'list-outline'" slot="start"></ion-icon>
{{ viewMode }}
</ion-button>
<ion-button size="small" (click)="toggleSize()">
<ion-icon [name]="gridSize === 'SMALL' ? 'expand-outline' : 'contract-outline'" slot="start"></ion-icon>
{{ gridSize }}
</ion-button>
<ion-button size="small" [color]="showItems ? 'medium' : 'success'" (click)="toggleItems()">
<ion-icon [name]="showItems ? 'eye-off-outline' : 'eye-outline'" slot="start"></ion-icon>
{{ showItems ? 'Hide Products' : 'Show Products' }}
</ion-button>
</div>

<div class="demo-section demo-section--scrollable">
<div class="grid-container">
<upp-grid name="DEMO_CATALOG" [size]="gridSize">
<upp-grid-empty>
<div class="empty-state">
<ion-icon name="storefront-outline" class="empty-icon"></ion-icon>
<p>No products found</p>
</div>
</upp-grid-empty>

<ng-container *ngIf="showItems">
<upp-grid-item *ngFor="let p of products">
<upp-thumb
[title]="p.name"
[color]="p.color"
[icon]="p.icon"
[detail]="p.price"
[foot]="p.stock">
</upp-thumb>
</upp-grid-item>
</ng-container>
</upp-grid>
</div>
</div>

API Reference

upp-grid

Selector: upp-grid

TypeNameDefaultDescription
@Input()name: string | nullnullConfiguration name. Required to load and persist view mode and thumbnail size via configService.
@Input()size: 'SMALL' | 'LARGE''SMALL'Card size. SMALL renders square cards, LARGE renders rectangular cards.

Computed properties:

PropertyTypeDescription
ViewMode'GRID' | 'LIST'Current view mode, read from configuration.
ScaleModenumberScaling factor derived from thumbsize configuration value (value / 10).
IsEmptybooleantrue when no upp-grid-item children are present.

UppGridConfiguration (enum)

Keys used in the configuration object:

KeyDescriptionDefault
viewmodeDisplay mode: 'GRID' or 'LIST'.'GRID'
thumbsizeThumbnail size factor (integer, where 10 = 100% scale).10

upp-grid-item

Selector: upp-grid-item

Wraps each item inside the grid. Propagates the parent grid's view mode to any child components that extend ViewModeDirective (such as upp-thumb).

upp-grid-empty

Selector: upp-grid-empty

Content projection slot displayed when the grid has no items. Place any custom empty-state markup inside this component.