Skip to content

Commit

Permalink
fixup! Add tree-related types
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlin committed Nov 8, 2024
1 parent 3f1cf35 commit 3e23f85
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 61 deletions.
3 changes: 1 addition & 2 deletions src/components/tree/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { connect, MapStateToProps } from "react-redux";
import UnconnectedTree from "./tree";
import { RootState } from "../../store";
import { TreeComponentStateProps } from "./tree";
import { TreeComponentOwnProps } from "./tree";
import { TreeComponentOwnProps, TreeComponentStateProps } from "./types";

const mapStateToProps: MapStateToProps<TreeComponentStateProps, TreeComponentOwnProps, RootState> = (
state: RootState,
Expand Down
2 changes: 1 addition & 1 deletion src/components/tree/reactD3Interface/change.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { calculateStrokeColors, getBrighterColor } from "../../../util/colorHelpers";
import { ChangeParams, PhyloTreeType } from "../phyloTree/types";
import { TreeComponentProps, TreeComponentState } from "../tree";
import { TreeComponentProps, TreeComponentState } from "../types";

export const changePhyloTreeViaPropsComparison = (
mainTree: boolean,
Expand Down
3 changes: 2 additions & 1 deletion src/components/tree/reactD3Interface/initialRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { calculateStrokeColors, getBrighterColor } from "../../../util/colorHelp
import * as callbacks from "./callbacks";
import { makeTipLabelFunc } from "../phyloTree/labels";
import { PhyloTreeType } from "../phyloTree/types";
import { TreeComponent, TreeComponentProps } from "../tree";
import { TreeComponent } from "../tree";
import { TreeComponentProps } from "../types";

export const renderTree = (
that: TreeComponent,
Expand Down
60 changes: 3 additions & 57 deletions src/components/tree/tree.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from "react";
import { withTranslation, WithTranslation } from "react-i18next";
import { withTranslation } from "react-i18next";
import { FaSearchMinus } from "react-icons/fa";
import { Root, updateVisibleTipsAndBranchThicknesses } from "../../actions/tree";
import { ColorScale, Layout, PerformanceFlags, ScatterVariables, SelectedNode, TemporalConfidence } from "../../reducers/controls";
import { TreeState, TreeTooState } from "../../reducers/tree/types";
import { AppDispatch } from "../../store";
import { SelectedNode } from "../../reducers/controls";
import Card from "../framework/card";
import Legend from "./legend/legend";
import PhyloTree from "./phyloTree/phyloTree";
import { Distance, PhyloNode, PhyloTreeType } from "./phyloTree/types";
import { getParentBeyondPolytomy } from "./phyloTree/helpers";
import HoverInfoPanel from "./infoPanels/hover";
import NodeClickedPanel from "./infoPanels/click";
Expand All @@ -21,63 +18,12 @@ import { attemptUntangle } from "../../util/globals";
import ErrorBoundary from "../../util/errorBoundary";
import { untangleTreeToo } from "./tangle/untangling";
import { sortByGeneOrder } from "../../util/treeMiscHelpers";
import { TreeComponentProps, TreeComponentState } from "./types";

export const spaceBetweenTrees = 100;
export const lhsTreeId = "LEFT";
const rhsTreeId = "RIGHT";

export interface TreeComponentOwnProps {
dispatch: AppDispatch
height: number
width: number
}

export interface TreeComponentProps extends WithTranslation, TreeComponentStateProps, TreeComponentOwnProps {}

// This is duplicated from RootState, but good to be explicit about what's
// expected here.
export interface TreeComponentStateProps {
animationPlayPauseButton: "Play" | "Pause"
canRenderBranchLabels: boolean
colorBy: string
colorByConfidence: boolean
colorings: unknown
colorScale: ColorScale
dateMaxNumeric: number
dateMinNumeric: number
distanceMeasure: Distance
explodeAttr: string
filters: Record<string, Array<{ value: string, active: boolean }>>
focus: boolean
genomeMap: unknown
layout: Layout
narrativeMode: boolean
panelsToDisplay: string[]
performanceFlags: PerformanceFlags
quickdraw: boolean
scatterVariables: ScatterVariables
selectedBranchLabel: string
selectedNode: SelectedNode | null
showAllBranchLabels: boolean
showOnlyPanels: boolean
showTangle: boolean
showTreeToo: boolean
temporalConfidence: TemporalConfidence
tipLabelKey: string | symbol
tree: TreeState
treeToo: TreeTooState
}

export interface TreeComponentState {
hoveredNode: {
node: PhyloNode
isBranch: boolean
} | null
tree: PhyloTreeType | null
treeToo: PhyloTreeType | null
geneSortFn?: (a: number, b: number) => number | (() => 0)
}

export class TreeComponent extends React.Component<TreeComponentProps, TreeComponentState> {

domRefs: {
Expand Down
57 changes: 57 additions & 0 deletions src/components/tree/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { WithTranslation } from "react-i18next"
import { ColorScale, Layout, PerformanceFlags, ScatterVariables, SelectedNode, TemporalConfidence } from "../../reducers/controls";
import { TreeState, TreeTooState } from "../../reducers/tree/types";
import { AppDispatch } from "../../store";
import { Distance, PhyloNode, PhyloTreeType } from "./phyloTree/types";

export interface TreeComponentOwnProps {
dispatch: AppDispatch
height: number
width: number
}

export interface TreeComponentProps extends WithTranslation, TreeComponentStateProps, TreeComponentOwnProps {}

// This is duplicated from RootState, but good to be explicit about what's
// expected here.
export interface TreeComponentStateProps {
animationPlayPauseButton: "Play" | "Pause"
canRenderBranchLabels: boolean
colorBy: string
colorByConfidence: boolean
colorings: unknown
colorScale: ColorScale
dateMaxNumeric: number
dateMinNumeric: number
distanceMeasure: Distance
explodeAttr: string
filters: Record<string, Array<{ value: string, active: boolean }>>
focus: boolean
genomeMap: unknown
layout: Layout
narrativeMode: boolean
panelsToDisplay: string[]
performanceFlags: PerformanceFlags
quickdraw: boolean
scatterVariables: ScatterVariables
selectedBranchLabel: string
selectedNode: SelectedNode | null
showAllBranchLabels: boolean
showOnlyPanels: boolean
showTangle: boolean
showTreeToo: boolean
temporalConfidence: TemporalConfidence
tipLabelKey: string | symbol
tree: TreeState
treeToo: TreeTooState
}

export interface TreeComponentState {
hoveredNode: {
node: PhyloNode
isBranch: boolean
} | null
tree: PhyloTreeType | null
treeToo: PhyloTreeType | null
geneSortFn?: (a: number, b: number) => number | (() => 0)
}

0 comments on commit 3e23f85

Please sign in to comment.