indentedTextLineComponent.tsx 1.5 KB

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