-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1668 from nextstrain/node-name
Extend usefulness of tip labels
- Loading branch information
Showing
8 changed files
with
82 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getTraitFromNode } from "../../../util/treeMiscHelpers"; | ||
import { numericToCalendar } from "../../../util/dateHelpers"; | ||
|
||
|
||
/** | ||
* Attempt to display the best name we can for a node, depending on how we are looking at a node. | ||
* The returned string will be rendered on a line of its own, so an empty string will look ok | ||
* Future enhancement: we could examine the coloring metadata (if available) and format the value accordingly | ||
*/ | ||
export function nodeDisplayName(t, node, tipLabelKey, branch) { | ||
let tipLabel = getTraitFromNode(node, tipLabelKey) | ||
if (tipLabelKey==='num_date' && tipLabel) tipLabel = numericToCalendar(tipLabel) | ||
const terminal = !node.hasChildren; | ||
|
||
if (branch) { | ||
if (terminal) { | ||
return tipLabel ? t("Branch leading to {{tipLabel}}", {tipLabel}) : t("Terminal branch") // hover + click | ||
} | ||
return t("Internal branch") // branch click only | ||
} | ||
/* TIP */ | ||
return tipLabel; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters