Skip to content

Commit

Permalink
Merge pull request #166 from OpenChemistry/sample-molecules
Browse files Browse the repository at this point in the history
Include Wikipedia link for molecules if one is provided
  • Loading branch information
bnmajor authored Jan 8, 2020
2 parents 14e65a8 + d4040a0 commit 42bedc7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/components/molecule.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { Component } from 'react';

import PropTypes from 'prop-types';

import { withStyles, Grid, Card, Typography } from '@material-ui/core';
import { withStyles, Grid, Card, Typography, Link } from '@material-ui/core';

import { has } from 'lodash-es';
import { has, isNil } from 'lodash-es';

import PageHead from './page-head';
import PageBody from './page-body';
Expand Down Expand Up @@ -75,6 +75,12 @@ class Molecule extends Component {
}
}

formatLink = (props) => {
return <Link target="_blank" rel="noopener" href={props.wikipediaUrl}>
{!isNil(props.name) ? props.name : 'Wikipedia Page'}
</Link>
}

render = () => {
const {molecule, calculations, onCalculationClick, creator, onCreatorClick, classes} = this.props;

Expand All @@ -95,6 +101,12 @@ class Molecule extends Component {
if (has(molecule, 'smiles')) {
moleculeProperties.push({label: 'SMILES', value: molecule.smiles});
}
if (has(molecule, 'wikipediaUrl')) {
moleculeProperties.push({
label: 'Wikipedia',
value: this.formatLink(molecule)
});
}

const moleculeSection = {
label: 'Molecule Properties',
Expand Down

0 comments on commit 42bedc7

Please sign in to comment.