textLineComponent.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import * as React from "react";
  2. interface ITextLineComponentProps {
  3. label: string;
  4. value: string;
  5. color?: string;
  6. underline?: boolean;
  7. onLink?: () => void;
  8. }
  9. export class TextLineComponent extends React.Component<ITextLineComponentProps> {
  10. constructor(props: ITextLineComponentProps) {
  11. super(props);
  12. }
  13. onLink() {
  14. if (!this.props.onLink) {
  15. return;
  16. }
  17. this.props.onLink();
  18. }
  19. renderContent() {
  20. if (this.props.onLink) {
  21. return (
  22. <div className="link-value" title={this.props.value} onClick={() => this.onLink()}>
  23. {this.props.value || "no name"}
  24. </div>
  25. )
  26. }
  27. return (
  28. <div className="value" title={this.props.value} style={{ color: this.props.color ? this.props.color : "" }}>
  29. {this.props.value || "no name"}
  30. </div>
  31. )
  32. }
  33. render() {
  34. return (
  35. <div className={this.props.underline ? "textLine underline" : "textLine"}>
  36. <div className="label">
  37. {this.props.label}
  38. </div>
  39. {this.renderContent()}
  40. </div>
  41. );
  42. }
  43. }