treeItemLabelComponent.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import * as React from "react";
  2. import { IconDefinition } from "@fortawesome/free-solid-svg-icons";
  3. import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
  4. interface ITreeItemLabelComponentProps {
  5. label: string,
  6. onClick?: () => void,
  7. icon: IconDefinition,
  8. color: string
  9. }
  10. export class TreeItemLabelComponent extends React.Component<ITreeItemLabelComponentProps> {
  11. constructor(props: ITreeItemLabelComponentProps) {
  12. super(props);
  13. }
  14. onClick() {
  15. if (!this.props.onClick) {
  16. return;
  17. }
  18. this.props.onClick()
  19. }
  20. render() {
  21. return (
  22. <div className="title" onClick={() => this.onClick()}>
  23. <div className="titleIcon">
  24. <FontAwesomeIcon icon={this.props.icon} color={this.props.color} />
  25. </div>
  26. <div className="titleText">
  27. {this.props.label || "no name"}
  28. </div>
  29. </div>
  30. )
  31. }
  32. }