colouring-montreal/app/src/frontend/building/data-components/data-title.tsx

55 lines
1.5 KiB
TypeScript
Raw Normal View History

2019-08-14 16:54:31 -04:00
import React from 'react';
import Tooltip from '../../components/tooltip';
import { CopyProps } from '../data-containers/category-view-props';
2019-08-14 16:54:31 -04:00
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-10-15 10:44:22 -04:00
interface DataTitleCopyableProps {
title: string;
tooltip?: string;
2019-10-15 10:44:22 -04:00
slug: string;
disabled?: boolean;
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 (
<div className="data-title">
2019-08-14 16:54:31 -04:00
{ props.tooltip? <Tooltip text={ props.tooltip } /> : null }
{ (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
}
<label htmlFor={props.slug}>
{ props.title }
</label>
</div>
2019-08-14 16:54:31 -04:00
);
}
export default DataTitle;
export { DataTitleCopyable }