ThreeStrandedButton.jsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. const ThreeStrandedButton = (props) => {
  5. const { t } = props;
  6. function threeStrandedButtonClickedHandler(viewType) {
  7. if (props.onThreeStrandedButtonClicked != null) {
  8. props.onThreeStrandedButtonClicked(viewType);
  9. }
  10. }
  11. return (
  12. <div className="btn-group grw-three-stranded-button" role="group " aria-label="three-stranded-button">
  13. <button
  14. type="button"
  15. className="btn btn-outline-primary view-button"
  16. onClick={() => { threeStrandedButtonClickedHandler('view') }}
  17. >
  18. <i className="icon-control-play icon-fw" />
  19. { t('view') }
  20. </button>
  21. <button
  22. type="button"
  23. className="btn btn-outline-primary edit-button"
  24. onClick={() => { threeStrandedButtonClickedHandler('edit') }}
  25. >
  26. <i className="icon-note icon-fw" />
  27. { t('Edit') }
  28. </button>
  29. <button
  30. type="button"
  31. className="btn btn-outline-primary hackmd-button"
  32. onClick={() => { threeStrandedButtonClickedHandler('hackmd') }}
  33. >
  34. <i className="fa fa-fw fa-file-text-o" />
  35. { t('hackmd.hack_md') }
  36. </button>
  37. </div>
  38. );
  39. };
  40. ThreeStrandedButton.propTypes = {
  41. t: PropTypes.func.isRequired, // i18next
  42. onThreeStrandedButtonClicked: PropTypes.func,
  43. };
  44. export default withTranslation()(ThreeStrandedButton);