Skip to content

Commit ec6f532

Browse files
Tobi1kenobicarcruz
andauthored
[UI] Add chip to show genomic location in gene tooltip (#829)
Co-authored-by: Carlos Cruz <[email protected]>
1 parent cca96c3 commit ec6f532

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

packages/ui/src/components/OtAsyncTooltip/OtAsyncTooltip.tsx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,26 @@ function AsyncTooltipLoadingView(): ReactElement {
119119
);
120120
}
121121

122+
type TooltipData = {
123+
id?: string;
124+
name?: string;
125+
description?: string | string[];
126+
mostSevereConsequence?: { label?: string };
127+
publicationFirstAuthor?: string;
128+
publicationDate?: string;
129+
publicationJournal?: string;
130+
genomicLocation?: { chromosome?: string; start?: number };
131+
};
132+
122133
function AsyncTooltipDataView({
123134
entity,
124135
data,
125136
}: {
126137
entity: string;
127-
data: Record<string, unknown>;
138+
data: TooltipData;
128139
}): ReactElement {
129-
const showSubText = !!data?.mostSevereConsequence?.label || data?.publicationFirstAuthor;
140+
const showSubText = !!(data?.mostSevereConsequence?.label || data?.publicationFirstAuthor);
141+
const showChromosome = entity === "target" && data?.genomicLocation?.chromosome;
130142

131143
function getSubtext() {
132144
let finalSubText;
@@ -140,9 +152,9 @@ function AsyncTooltipDataView({
140152
if (publicationData)
141153
finalSubText = (
142154
<StudyPublication
143-
publicationDate={data?.publicationDate}
144-
publicationFirstAuthor={data?.publicationFirstAuthor}
145-
publicationJournal={data?.publicationJournal}
155+
publicationDate={data?.publicationDate || ""}
156+
publicationFirstAuthor={data?.publicationFirstAuthor || ""}
157+
publicationJournal={data?.publicationJournal || ""}
146158
/>
147159
);
148160

@@ -171,7 +183,7 @@ function AsyncTooltipDataView({
171183
<Box sx={{ p: 1, color: theme => theme.palette.primary.main }}>
172184
<FontAwesomeIcon size="2x" icon={getEntityIcon(entity)}></FontAwesomeIcon>
173185
</Box>
174-
<Box sx={{ pt: 0.4 }}>
186+
<Box sx={{ pt: 0.4, flex: 1 }}>
175187
<Box
176188
sx={{
177189
typography: "subtitle2",
@@ -181,12 +193,20 @@ function AsyncTooltipDataView({
181193
}}
182194
>
183195
{getLabel()}
184-
</Box>{" "}
196+
</Box>
185197
<Box sx={{ typography: "body2", color: theme => theme.palette.grey[800] }}>
186-
{getEntityDescription(entity, data)}
198+
{getEntityDescription(entity, data as Record<string, unknown>)}
187199
</Box>
188200
</Box>
189201
</Box>
202+
{showChromosome && data.genomicLocation?.chromosome && (
203+
<>
204+
<Divider />
205+
<Box sx={{ typography: "caption", color: theme => theme.palette.grey[900], pt: 1, pl: 1 }}>
206+
{`Chromosome: ${data.genomicLocation.chromosome}${data.genomicLocation.start ? `:${data.genomicLocation.start.toLocaleString()}` : ''}`}
207+
</Box>
208+
</>
209+
)}
190210
{showSubText && (
191211
<>
192212
<Divider />

packages/ui/src/components/OtAsyncTooltip/queries/TargetTooltipQuery.gql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ query TargetTooltipQuery($ensgId: String!) {
33
id
44
name: approvedName
55
description: functionDescriptions
6+
genomicLocation {
7+
chromosome
8+
start
9+
}
610
}
711
}

0 commit comments

Comments
 (0)