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

[Platform]: Add DisplayVariantId component #441

Merged
merged 2 commits into from
Aug 28, 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
3 changes: 1 addition & 2 deletions apps/platform/src/pages/VariantPage/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { faMapPin } from "@fortawesome/free-solid-svg-icons";
import { Header as HeaderBase, XRefLinks } from "ui";
import { Header as HeaderBase, XRefLinks, DisplayVariantId } from "ui";
import { VariantPageDataType } from "./types";
import DisplayVariantId from "./DisplayVariantId";

const xrefsToDisplay = {
ensembl_variation: {
Expand Down
8 changes: 7 additions & 1 deletion packages/sections/src/variant/InSilicoPredictors/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ export function Body({ id, entity }: BodyProps) {
definition={definition}
request={request}
entity={entity}
renderDescription={() => <Description variantId={id} />}
renderDescription={({ variant }) => (
<Description
variantId={variant.variantId}
referenceAllele={variant.referenceAllele}
alternateAllele={variant.alternateAllele}
/>
)}
renderBody={({ variant }) => {
const rows = [...variant.inSilicoPredictors].sort((row1, row2) => {
return row1.method.localeCompare(row2.method);
Expand Down
16 changes: 13 additions & 3 deletions packages/sections/src/variant/InSilicoPredictors/Description.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { Link } from "ui";
import { Link, DisplayVariantId } from "ui";

type DescriptionProps = {
variantId: string;
referenceAllele: string;
alternateAllele: string;
};

function Description({ variantId }: DescriptionProps) {
function Description({ variantId, referenceAllele, alternateAllele }: DescriptionProps) {
return (
<>
Predicted functional effect of <strong>{variantId}</strong>. Source:{" "}
Predicted functional effect of{" "}
<strong>
<DisplayVariantId
variantId={variantId}
referenceAllele={referenceAllele}
alternateAllele={alternateAllele}
/>
</strong>
. Source:{" "}
<Link to="https://www.ensembl.org/info/docs/tools/vep/index.html" external>
VEP
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ query InSilicoPredictorsQuery($variantId: String!) {
score
assessmentFlag
}
referenceAllele
alternateAllele
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ export function Body({ id, entity }: BodyProps) {
definition={definition}
request={request}
entity={entity}
renderDescription={() => <Description variantId={id} />}
renderDescription={({ variant }) => (
<Description
variantId={variant.variantId}
referenceAllele={variant.referenceAllele}
alternateAllele={variant.alternateAllele}
/>
)}
renderBody={({ variant }) => {
return (
<DataTable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import { Link } from "ui";
import { Link, DisplayVariantId } from "ui";

type DescriptionProps = {
variantId: string;
referenceAllele: string;
alternateAllele: string;
};

function Description({ variantId }: DescriptionProps) {
function Description({ variantId, referenceAllele, alternateAllele }: DescriptionProps) {
return (
<>
Variant consequence prediction for <strong>{variantId}</strong>. {" "}Source:{" "}
Variant consequence prediction for{" "}
<strong>
<DisplayVariantId
variantId={variantId}
referenceAllele={referenceAllele}
alternateAllele={alternateAllele}
/>
</strong>. {" "}Source:{" "}
<Link to="https://www.ensembl.org/info/docs/tools/vep/index.html" external>
VEP
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
query VariantEffectPredictorQuery($variantId: String!) {
variant(variantId: $variantId){
variantId
transcriptConsequences {
variantConsequences {
id
Expand All @@ -22,5 +23,7 @@ query VariantEffectPredictorQuery($variantId: String!) {
siftPrediction
polyphenPrediction
}
referenceAllele
alternateAllele
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ function DisplayVariantId({
return (
<>
<Box
component="span"
onClick={handleClick}
title="Show variant ID"
sx={{
cursor: "pointer",
padding: "0 2px",
borderRadius: "8px",
padding: "0 0.06em",
borderRadius: "0.3em",
"&:hover": {
background: highlightBackground,
}
Expand Down Expand Up @@ -154,10 +155,10 @@ function DisplayVariantId({
function HighlightBox({ children }) {
return (
<Box
display="inline-block"
borderRadius={5}
mx={0.5}
px={0.5}
component="span"
borderRadius="0.3em"
mx="0.1em"
px="0.15em"
bgcolor={highlightBackground}
>
{children}
Expand Down
23 changes: 14 additions & 9 deletions packages/ui/src/components/Section/SectionItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
Grid,
LinearProgress,
Typography,
Skeleton,
} from "@mui/material";
import { Element } from "react-scroll";

import ErrorBoundary from "../ErrorBoundary";
import Chip from "../Chip";
import SectionError from "./SectionError";
Expand Down Expand Up @@ -73,14 +73,19 @@ function SectionItem({
</Grid>
}
subheader={
<Typography
className={classNames(classes.description, classes.descriptionHasData, {
[classes.descriptionError]: error,
})}
variant="body2"
>
{renderDescription(data)}
</Typography>
!loading && hasData ? (
<Typography
className={classNames(classes.description, classes.descriptionHasData, {
[classes.descriptionError]: error,
})}
variant="body2"
component="div"
>
{renderDescription(data)}
</Typography>
) : (
<Skeleton width="50vw" height="20px" />
)
}
action={tags}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export { default as ChipList } from "./components/ChipList";
export { default as TooltipStyledLabel } from "./components/TooltipStyledLabel";
export { default as DirectionOfEffectIcon } from "./components/DirectionOfEffectIcon";
export { default as DirectionOfEffectTooltip } from "./components/DirectionOfEffectTooltip";
export { default as DisplayVariantId } from "./components/DisplayVariantId";
export { default as LabelChip } from "./components/LabelChip";
export { default as BasePage } from "./components/BasePage";
export { default as NewChip } from "./components/NewChip";
Expand Down
Loading