textLineComponent.tsx 1.2 KB

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