UNPKG

1.02 kBJavaScriptView Raw
1import React, {PureComponent} from 'react';
2import PropTypes from 'prop-types';
3
4import Link from '../link/link';
5
6import styles from './services.css';
7
8export default class ServicesLink extends PureComponent {
9 static propTypes = {
10 isActive: PropTypes.bool,
11 service: PropTypes.shape({
12 applicationName: PropTypes.string,
13 iconUrl: PropTypes.string,
14 homeUrl: PropTypes.string,
15 name: PropTypes.string
16 })
17 };
18
19 render() {
20 const {service, ...props} = this.props;
21
22 return (
23 <Link
24 target="_self"
25 href={service.homeUrl}
26 {...props}
27 >
28 {WrapText => (service.iconUrl
29 ? [
30 <span
31 key="icon"
32 className={styles.itemLogo}
33 style={{backgroundImage: `url(${service.iconUrl})`}}
34 />,
35 <div key="text">
36 <WrapText>{service.name}</WrapText>
37 </div>
38 ]
39 : <WrapText>{service.name}</WrapText>)
40 }
41 </Link>
42 );
43 }
44
45}