2019-08-14 16:54:31 -04:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import Tooltip from '../../components/tooltip';
|
|
|
|
|
2019-10-15 10:44:22 -04:00
|
|
|
|
|
|
|
interface DataTitleProps {
|
|
|
|
title: string;
|
|
|
|
tooltip: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const DataTitle: React.FunctionComponent<DataTitleProps> = (props) => {
|
2019-08-14 16:54:31 -04:00
|
|
|
return (
|
|
|
|
<dt>
|
|
|
|
{ props.title }
|
|
|
|
{ props.tooltip? <Tooltip text={ props.tooltip } /> : null }
|
|
|
|
</dt>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
DataTitle.propTypes = {
|
|
|
|
title: PropTypes.string,
|
|
|
|
tooltip: PropTypes.string
|
|
|
|
}
|
|
|
|
|
2019-10-15 10:44:22 -04:00
|
|
|
|
|
|
|
interface DataTitleCopyableProps {
|
|
|
|
title: string;
|
|
|
|
tooltip: string;
|
|
|
|
slug: string;
|
|
|
|
disabled?: boolean;
|
2019-10-15 14:16:48 -04:00
|
|
|
copy?: any; // TODO: type should be CopyProps, but that clashes with propTypes in some obscure way
|
2019-10-15 10:44:22 -04:00
|
|
|
}
|
|
|
|
|
2019-10-17 12:07:34 -04:00
|
|
|
const DataTitleCopyable: React.FunctionComponent<DataTitleCopyableProps> = (props) => {
|
2019-08-14 16:54:31 -04:00
|
|
|
return (
|
2019-08-23 12:35:17 -04:00
|
|
|
<div className="data-title">
|
2019-08-14 16:54:31 -04:00
|
|
|
{ props.tooltip? <Tooltip text={ props.tooltip } /> : null }
|
2019-08-23 12:35:17 -04:00
|
|
|
{ (props.copy && props.copy.copying && props.slug && !props.disabled)?
|
2019-08-14 16:54:31 -04:00
|
|
|
<div className="icon-buttons">
|
|
|
|
<label className="icon-button copy">
|
|
|
|
Copy
|
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
checked={props.copy.copyingKey(props.slug)}
|
|
|
|
onChange={() => props.copy.toggleCopyAttribute(props.slug)}/>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
: null
|
|
|
|
}
|
2019-08-23 12:35:17 -04:00
|
|
|
<label htmlFor={props.slug}>
|
|
|
|
{ props.title }
|
|
|
|
</label>
|
|
|
|
</div>
|
2019-08-14 16:54:31 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
DataTitleCopyable.propTypes = {
|
|
|
|
title: PropTypes.string,
|
|
|
|
tooltip: PropTypes.string,
|
|
|
|
slug: PropTypes.string,
|
|
|
|
disabled: PropTypes.bool,
|
|
|
|
copy: PropTypes.shape({
|
|
|
|
copying: PropTypes.bool,
|
|
|
|
copyingKey: PropTypes.func,
|
2019-10-15 10:44:22 -04:00
|
|
|
toggleCopyAttribute: PropTypes.func,
|
|
|
|
toggleCopying: PropTypes.func
|
2019-08-14 16:54:31 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DataTitle;
|
|
|
|
export { DataTitleCopyable }
|