2021-10-11 05:49:04 -04:00
|
|
|
import Markdown from 'markdown-to-jsx';
|
2019-08-14 16:54:31 -04:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import Tooltip from '../../components/tooltip';
|
2019-11-05 15:13:10 -05:00
|
|
|
import { CopyProps } from '../data-containers/category-view-props';
|
2019-08-14 16:54:31 -04:00
|
|
|
|
2020-12-27 18:51:32 -05:00
|
|
|
import './data-title.css';
|
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>
|
2019-11-07 03:13:30 -05:00
|
|
|
);
|
|
|
|
};
|
2019-08-14 16:54:31 -04:00
|
|
|
|
2019-10-15 10:44:22 -04:00
|
|
|
|
|
|
|
interface DataTitleCopyableProps {
|
|
|
|
title: string;
|
2019-11-05 15:13:10 -05:00
|
|
|
tooltip?: string;
|
2019-10-15 10:44:22 -04:00
|
|
|
slug: string;
|
2021-03-11 14:06:25 -05:00
|
|
|
slugModifier?: string | number;
|
2019-10-15 10:44:22 -04:00
|
|
|
disabled?: boolean;
|
2019-11-05 15:13:10 -05:00
|
|
|
copy?: CopyProps;
|
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">
|
2020-12-27 18:51:32 -05:00
|
|
|
<div className="data-title-text">
|
2021-03-11 14:06:25 -05:00
|
|
|
<label htmlFor={`${props.slug}${props.slugModifier ?? ''}`}>
|
2021-10-11 05:49:04 -04:00
|
|
|
<Markdown>
|
|
|
|
{ props.title }
|
|
|
|
</Markdown>
|
2020-12-27 18:51:32 -05:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div className="data-title-actions icon-buttons">
|
|
|
|
{ (props.copy && props.copy.copying && props.slug && !props.disabled)?
|
|
|
|
<label className="icon-button copy">
|
|
|
|
Copy
|
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
checked={props.copy.copyingKey(props.slug)}
|
|
|
|
onChange={() => props.copy.toggleCopyAttribute(props.slug)}/>
|
|
|
|
</label>
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
{ props.tooltip? <Tooltip text={ props.tooltip } /> : null }
|
|
|
|
</div>
|
2019-08-23 12:35:17 -04:00
|
|
|
</div>
|
2019-08-14 16:54:31 -04:00
|
|
|
);
|
2019-11-07 03:13:30 -05:00
|
|
|
};
|
2019-08-14 16:54:31 -04:00
|
|
|
|
|
|
|
export default DataTitle;
|
2019-11-07 03:13:30 -05:00
|
|
|
export { DataTitleCopyable };
|