Skip to content

Commit 6b0bd02

Browse files
committed
Info header info icon: add tooltip
1 parent d5816a0 commit 6b0bd02

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/client/components/main_layout/InfoHeader.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Typography from '@material-ui/core/Typography'
99
// import Divider from '@material-ui/core/Divider';
1010
import IconButton from '@material-ui/core/IconButton'
1111
import InfoIcon from '@material-ui/icons/InfoOutlined'
12+
import Tooltip from '@material-ui/core/Tooltip'
1213
import intl from 'react-intl-universal'
1314

1415
const useStyles = makeStyles(theme => ({
@@ -90,7 +91,12 @@ const InfoHeader = props => {
9091
let label = ''
9192
const data = props.instanceData
9293
const hasData = data !== null && Object.values(data).length >= 1
93-
if (hasData && data.prefLabel) { label = data.prefLabel.prefLabel || data.prefLabel }
94+
if (hasData && data.prefLabel) {
95+
if (Array.isArray(data.prefLabel)) {
96+
data.prefLabel = data.prefLabel[0]
97+
}
98+
label = data.prefLabel.prefLabel || data.prefLabel
99+
}
94100
return label
95101
}
96102

@@ -126,9 +132,11 @@ const InfoHeader = props => {
126132
{props.pageType === 'facetResults' && intl.get(`perspectives.${props.resultClass}.label`)}
127133
{props.pageType === 'instancePage' && intl.get(`perspectives.${props.resultClass}.instancePage.label`)}
128134
</Typography>
129-
<IconButton aria-label='open instructions' className={classes.infoIconButton} onClick={handleExpandButtonOnClick}>
130-
<InfoIcon className={classes.infoIcon} />
131-
</IconButton>
135+
<Tooltip title={intl.get('infoHeader.toggleInstructions')}>
136+
<IconButton aria-label='toggle instructions' className={classes.infoIconButton} onClick={handleExpandButtonOnClick}>
137+
<InfoIcon className={classes.infoIcon} />
138+
</IconButton>
139+
</Tooltip>
132140
</div>
133141
{props.pageType === 'instancePage' &&
134142
<Typography className={classes.label} component='h1' variant='h6'>{generateLabel()}</Typography>}

src/client/translations/sampo/localeEN.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"selectPerspective": "Select a perspective to search and browse the knowledge graph:",
1616
"mainPageImageLicence": "Images used under license from Shutterstock.com",
1717
"backendErrorText": "One of the backend services is not available at the moment. Please try again later.",
18+
"infoHeader": {
19+
"toggleInstructions": "Click to show or hide instructions"
20+
},
1821
"topBar": {
1922
"feedback": "feedback",
2023
"info": {

0 commit comments

Comments
 (0)