UNPKG

1.15 kBJavaScriptView Raw
1import React from 'react';
2import OverflowExpander from './OverflowExpander';
3import * as Constants from './constants';
4import PropTypes from 'prop-types';
5
6let HORZ_PADDING = 5;
7if (Constants.CELL_EXPANDER_SAMELINE) {
8 HORZ_PADDING = 5;
9}
10
11export const UrlCell = (props) => {
12 let content = props.cellData.text || props.cellData.main;
13 content = typeof content === 'object' ? JSON.stringify(content) : content;
14
15 return (
16 <div
17 className="url-cell"
18 style={{
19 float: 'left',
20 padding: `0 ${HORZ_PADDING}px`,
21 }}
22 >
23 <a
24 className="url-cell-content"
25 disabled
26 href={props.disabled ? 'javascript:void(0);' : props.cellData.main}
27 title={props.cellData.title || props.cellData.text || props.cellData.main}
28 target={'_blank'}
29 style={{
30 display: 'inline-block',
31 }}
32 >
33 <OverflowExpander availableWidth={props.width - HORZ_PADDING * 2}>{content}</OverflowExpander>
34 </a>
35 </div>
36 );
37};
38
39UrlCell.propTypes = {
40 cellData: PropTypes.object.isRequired,
41 width: PropTypes.number.isRequired,
42 disabled: PropTypes.bool.isRequired,
43};