import { DefaultTooltip } from 'cbioportal-frontend-commons'; import { generateHgvsgByMutation, Mutation } from 'cbioportal-utils'; import { observer } from 'mobx-react'; import * as React from 'react'; import { defaultSortMethod } from 'cbioportal-utils'; import hgvsgStyles from './hgvsg.module.scss'; type HgvsgProps = { mutation: Mutation; constructHref?: (hgvsg: string) => string; constructLink?: ( hgvsg: string, content: JSX.Element, href?: string ) => JSX.Element; mainContent?: (hgvsg?: string) => JSX.Element; tooltipContent?: (hgvsg?: string) => JSX.Element; disableTooltip?: boolean; }; export function hgvsgSortMethod(a: string, b: string) { return defaultSortMethod(a, b); } @observer export default class Hgvsg extends React.Component { public static defaultProps: Partial = { constructLink: (hgvsg: string, content: JSX.Element, href?: string) => ( {content} ), mainContent: (hgvsg?: string) => ( <> {hgvsg}  ), tooltipContent: () => ( <> Genome Nexus
), }; get hgvsg() { return generateHgvsgByMutation(this.props.mutation); } public render() { const constructLink = this.props.constructLink!; const mainContent = this.props.mainContent!; const tooltipContent = this.props.tooltipContent!; if (!this.hgvsg) { return ; } else { const href = this.props.constructHref ? this.props.constructHref(this.hgvsg) : undefined; const content = ( {constructLink(this.hgvsg, mainContent(this.hgvsg), href)} ); return this.props.disableTooltip ? ( content ) : ( {this.hgvsg}
Click to see this variant on   {constructLink( this.hgvsg, tooltipContent(this.hgvsg) )}
} > {content} ); } } }