Skip to content
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

feat: add embed types/interfaces #1585

Merged
merged 7 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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[];
juliannemarik marked this conversation as resolved.
Show resolved Hide resolved
}
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";
Loading