Skip to content

Commit

Permalink
if a HeaderCard is being shown, then update the page title and descri…
Browse files Browse the repository at this point in the history
…ption using that information
  • Loading branch information
jay-hodgson committed Feb 17, 2020
1 parent e3df830 commit f1e9ce8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<link
rel="stylesheet"
Expand Down
29 changes: 7 additions & 22 deletions src/demo/containers/playground/CardContainerLogicDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import CardContainerLogic, {
CardConfiguration,
} from '../../../lib/containers/CardContainerLogic'
import { SynapseConstants } from '../../../lib'
import { GenericCardSchema } from '../../../lib/containers/GenericCard'
import brainSvg from './icons/brain.svg'
import circleSvg from './icons/circle.svg'
import mouseSvg from './icons/mouse.svg'
Expand All @@ -29,26 +28,7 @@ export default class CardContainerLogicDemo extends React.Component<{}, State> {
'MODEL-AD': mouseSvg,
'Resilience-AD': resilienceadSvg,
}
const genericCardSchemaHeader: GenericCardSchema = {
type: SynapseConstants.DATASET,
title: 'portalDisplayName',
subTitle: 'centerName',
description: 'summary',
secondaryLabels: [
'Title',
'overallDesign',
'PubMed',
'Theme',
'studies',
'tumorType',
'experimentalStrategy',
'species',
'externalLink',
'centerName',
'consortium',
'grantType',
],
}

const genericCardSchema: CardConfiguration = {
type: SynapseConstants.GENERIC_CARD,
genericCardSchema: {
Expand Down Expand Up @@ -94,7 +74,12 @@ export default class CardContainerLogicDemo extends React.Component<{}, State> {
sql={'SELECT * FROM syn17024173'}
entityId={'syn17024173'}
searchParams={{ Program: 'AMP-AD' }}
genericCardSchema={genericCardSchemaHeader}
genericCardSchema={{
type: 'Program',
title: 'Full Name',
subTitle: 'Short Description',
icon: 'Program',
}}
backgroundColor={'#5960a5'}
isHeader={true}
iconOptions={iconOptions}
Expand Down
9 changes: 9 additions & 0 deletions src/lib/containers/HeaderCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ const HeaderCard: React.FunctionComponent<HeaderCardProps> = ({
secondaryLabelLimit,
isAlignToLeftNav
}) => {
// update page title and description based on header card values
if (title && document.title !== title) {
document.title = title
}
const descriptionElement:Element|null = document.querySelector('meta[name="description"]')
if (descriptionElement && (description || subTitle)) {
descriptionElement.setAttribute('content', description ? description : subTitle)
}

const style: React.CSSProperties = {
background: backgroundColor,
}
Expand Down

0 comments on commit f1e9ce8

Please sign in to comment.