commandButtonComponent.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import * as React from "react";
  2. import { GlobalState } from '../globalState';
  3. interface ICommandButtonComponentProps {
  4. globalState: GlobalState;
  5. tooltip: string;
  6. shortcut?: string;
  7. icon: string;
  8. isActive: boolean;
  9. onClick: () => void;
  10. }
  11. export class CommandButtonComponent extends React.Component<ICommandButtonComponentProps> {
  12. public constructor(props: ICommandButtonComponentProps) {
  13. super(props);
  14. }
  15. public render() {
  16. return (
  17. <div className="command-button" onClick={this.props.onClick} title={this.props.tooltip + (this.props.shortcut ? "\n" + this.props.shortcut : "")}>
  18. <div className="command-button-icon">
  19. <img src={"imgs/" + this.props.icon + ".svg"} className={this.props.isActive ? "active" : ""}/>
  20. </div>
  21. <div className="command-label">
  22. {this.props.tooltip}
  23. </div>
  24. </div>
  25. );
  26. }
  27. }