You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.4 KiB

  1. // Package imports
  2. import React from 'react';
  3. import PropTypes from 'prop-types';
  4. import classNames from 'classnames';
  5. // Stylesheet imports
  6. import './style';
  7. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  8. export default class LocalSettingsPage extends React.PureComponent {
  9. static propTypes = {
  10. active: PropTypes.bool,
  11. className: PropTypes.string,
  12. href: PropTypes.string,
  13. icon: PropTypes.string,
  14. index: PropTypes.number.isRequired,
  15. onNavigate: PropTypes.func,
  16. title: PropTypes.string,
  17. };
  18. handleClick = (e) => {
  19. const { index, onNavigate } = this.props;
  20. if (onNavigate) {
  21. onNavigate(index);
  22. e.preventDefault();
  23. }
  24. }
  25. render () {
  26. const { handleClick } = this;
  27. const {
  28. active,
  29. className,
  30. href,
  31. icon,
  32. onNavigate,
  33. title,
  34. } = this.props;
  35. const finalClassName = classNames('glitch', 'local-settings__navigation__item', {
  36. active,
  37. }, className);
  38. const iconElem = icon ? <i className={`fa fa-fw fa-${icon}`} /> : null;
  39. if (href) return (
  40. <a
  41. href={href}
  42. className={finalClassName}
  43. >
  44. {iconElem} {title}
  45. </a>
  46. );
  47. else if (onNavigate) return (
  48. <a
  49. onClick={handleClick}
  50. role='button'
  51. tabIndex='0'
  52. className={finalClassName}
  53. >
  54. {iconElem} {title}
  55. </a>
  56. );
  57. else return null;
  58. }
  59. }