linkButtonComponent.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import * as React from "react";
  2. import { IconProp } from '@fortawesome/fontawesome-svg-core';
  3. import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
  4. interface ILinkButtonComponentProps {
  5. label: string;
  6. buttonLabel: string;
  7. url?: string;
  8. onClick: () => void;
  9. icon?: IconProp;
  10. onIconClick?: () => void;
  11. }
  12. export class LinkButtonComponent extends React.Component<ILinkButtonComponentProps> {
  13. constructor(props: ILinkButtonComponentProps) {
  14. super(props);
  15. }
  16. onLink() {
  17. if (this.props.url) {
  18. window.open(this.props.url, '_blank');
  19. }
  20. }
  21. render() {
  22. return (
  23. <div className={"linkButtonLine"}>
  24. <div className="link" title={this.props.label} onClick={() => this.onLink()}>
  25. {this.props.label}
  26. </div>
  27. <div className="link-button">
  28. <button onClick={() => this.props.onClick()}>{this.props.buttonLabel}</button>
  29. </div>
  30. {
  31. this.props.icon &&
  32. <div className="link-icon hoverIcon" onClick={() => {
  33. if (this.props.onIconClick) {
  34. this.props.onIconClick();
  35. }
  36. }}>
  37. <FontAwesomeIcon icon={this.props.icon} />
  38. </div>
  39. }
  40. </div>
  41. );
  42. }
  43. }