Skip to content

Commit

Permalink
feat: add embed types/interfaces (#1585)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannemarik committed Jul 12, 2024
1 parent c87ae73 commit 0529404
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/common/src/core/traits/IWithViewSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
IMetricDisplayConfig,
HubActionLink,
IHubMapSettings,
HubEmbed,
} from "../types";

/**
Expand Down Expand Up @@ -58,4 +59,16 @@ export interface IWithViewSettings {
* array of actions for action links
*/
heroActions?: HubActionLink[];

/**
* array of embedded content
*
* Note: for now, we are only allowing a single
* embed to be configured, but we've made this
* an array for future extensibility. If/when
* we do support configuring multiple embeds,
* we should revisit if/how this will map to a
* future layout system
*/
embeds?: HubEmbed[];
}
53 changes: 53 additions & 0 deletions packages/common/src/core/types/Embeds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Type to represent a Hub embed. This is a discrminated
* union between app, map, survey, external, etc. embeds.
*/
export type HubEmbed =
| IHubEmbedApp
| IHubEmbedMap
| IHubEmbedSurvey
| IHubEmbedExternal;

/** enum to discriminate between embed union members */
export enum EmbedKind {
app = "app",
map = "map",
feedback = "feedback",
external = "external",
}

/** base embed */
interface IHubEmbedBase {
/** unique identifier */
key: string;
/** embed height */
height?: number;
}

/** app-specific embed */
export interface IHubEmbedApp extends IHubEmbedBase {
kind: EmbedKind.app;
/** application id */
id: string;
}

/** map-specific embed */
export interface IHubEmbedMap extends IHubEmbedBase {
kind: EmbedKind.map;
/** web map/scene id */
id: string;
}

/** external embed */
export interface IHubEmbedExternal extends IHubEmbedBase {
kind: EmbedKind.external;
/** embed url */
url: string;
}

/** survey-specific embed */
export interface IHubEmbedSurvey extends IHubEmbedBase {
kind: EmbedKind.feedback;
/** survey123 id */
id: string;
}
1 change: 1 addition & 0 deletions packages/common/src/core/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ export * from "./IHubCardViewModel";
export * from "./Metrics";
export * from "./types";
export * from "./IHubUser";
export * from "./Embeds";

0 comments on commit 0529404

Please sign in to comment.