Skip to content

Commit

Permalink
feat: add displayConfig in Hub Catalog, update GalleryDisplayConfigSc…
Browse files Browse the repository at this point in the history
…hema

affects: @esri/hub-common

ISSUES CLOSED: 11582
  • Loading branch information
vivzhang committed Nov 22, 2024
1 parent 1baa3c9 commit 5d5cd00
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/common/src/content/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ const getMetadataUpdatedDateInfo = (item: IItem, metadata?: any) => {
};

// public API
// AGO has a util for determining display name and item type icons
// that we can use for reference
// https://devtopia.esri.com/WebGIS/arcgis-app-components/blob/master/src/components/arcgis-item-type/utils.ts
/**
* Compute the content type calcite-icon based on the content type
* @param content type
Expand Down
29 changes: 28 additions & 1 deletion packages/common/src/core/schemas/shared/CatalogSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,34 @@ export const GalleryDisplayConfigSchema: IConfigurationSchema = {
type: "object",
properties: {
hidden: { type: "boolean", default: false },
// TODO: fill in properties
layout: {
type: "string",
enum: ["list", "grid", "table", "map"],
default: "list",
},
cardTitleTag: {
type: "string",
enum: ["h1", "h2", "h3", "h4", "h5", "h6"],
default: "h3",
},
showThumbnail: {
oneOf: [{ type: "string" }, { type: "boolean" }],
enum: [true, false, "grid"],
default: true,
},
corners: { type: "string", enum: ["square", "round"], default: "square" },
shadow: {
type: "string",
enum: ["none", "low", "medium", "heavy"],
default: "none",
},
showLinkButton: { type: "boolean", default: false },
linkButtonStyle: {
type: "string",
enum: ["outline", "outline-filled"],
default: "outline-filled",
},
linkButtonText: { type: "string" },
},
};

Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/search/Catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
IQuery,
IFilter,
IHubCollection,
IGalleryDisplayConfig,
} from "./types";
import { upgradeCatalogSchema } from "./upgradeCatalogSchema";

Expand Down Expand Up @@ -128,6 +129,10 @@ export class Catalog implements IHubCatalog {
return Object.keys(this.scopes) as unknown as EntityType[];
}

get displayConfig(): IGalleryDisplayConfig {
return this._catalog.displayConfig;
}

/**
* Get the scope's query for a particular entity type
* @param type
Expand Down
13 changes: 13 additions & 0 deletions packages/common/src/search/types/IHubCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export interface IHubCatalog {
scopes: string;
collections: string;
};

/**
* Optional display configuration to control a catalog's appearance in the UI
*/
displayConfig?: IGalleryDisplayConfig;
}

export interface ICatalogScope extends Partial<Record<EntityType, IQuery>> {}
Expand Down Expand Up @@ -185,4 +190,12 @@ export interface IGalleryDisplayConfig {
* If this is true on a collection's display config, that collection will not be shown in the gallery.
*/
hidden?: boolean;
layout?: "list" | "grid" | "map";
cardTitleTag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
showThumbnail: boolean;
corners: "square" | "round";
shadow: "none" | "light" | "medium" | "heavy";
showLinkButton: boolean;
linkButtonStyle: "solid" | "outline" | "outline-fill" | "transparent";
linkButtonText: string;
}

0 comments on commit 5d5cd00

Please sign in to comment.