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

62 lines
1.8 KiB
TypeScript
Raw Normal View History

import Markdown from 'markdown-to-jsx';
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
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;
tooltip?: string;
2019-10-15 10:44:22 -04:00
slug: string;
slugModifier?: string | number;
2019-10-15 10:44:22 -04:00
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">
<div className="data-title-text">
<label htmlFor={`${props.slug}${props.slugModifier ?? ''}`}>
<Markdown>
{ props.title }
</Markdown>
</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>
</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 };