Skip to content

Commit

Permalink
chore(widget): rename file and add type hint)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewedstrom committed Nov 24, 2023
1 parent 0607fd1 commit 411c15f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/widget/src/detail-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function renderDetailsView(
allNodes: DisplayObject[],
updateSelectedNode: (node: DisplayObject) => void,
closeDetailsView: () => void,
) {
): HTMLTemplateResult {
const opts = TYPE_DISPLAY_OPTIONS[selectedNode.type];
const backgroundColor = opts.detailViewBackgroundColor || opts.backgroundColor;
const textColor = opts.detailViewTextColor || opts.textColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export interface DisplayObjectMetadata {
actors?: string;
}

// DisplayObjects are the widget's internal representation of a node from the graph view.
// They roughly correspond to a ThingT in the Docmap spec, but with only the fields that we want to display.
export interface DisplayObject extends DisplayObjectMetadata {
nodeId: string; // Used internally to construct graph relationships, never rendered
type: string;
}

// The following 3 statements allow us to use FieldsToDisplay both as a type and as something we can
// check against at runtime. We could also use io-ts for this, but that felt like overkill since this
// is the only place in the widget where we do something like this.
Expand All @@ -32,13 +39,6 @@ export function isDisplayObjectMetadataField(key: string): key is DisplayObjectM
return key in DisplayObjectMetadataPrototype;
}

// DisplayObjects are the widget's internal representation of a node from the graph view.
// They roughly correspond to a ThingT in the Docmap spec, but with only the fields that we want to display.
export interface DisplayObject extends DisplayObjectMetadata {
nodeId: string; // Used internally to construct graph relationships, never rendered
type: string;
}

// Returns a new DisplayObject which has no fields set to the value undefined,
// meaning the new Display Object can be merged with another DisplayObject via destructuring.
//
Expand Down

0 comments on commit 411c15f

Please sign in to comment.