[ABANDONED] React/Redux front end for the Flexor social network.
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.

82 lines
3.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. // navigation-menu.tsx
  2. // Copyright (C) 2020 Dwayne Harris
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (at your option) any later version.
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU General Public License for more details.
  11. // You should have received a copy of the GNU General Public License
  12. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. import React, { FC } from 'react'
  14. import { Link } from 'react-router-dom'
  15. import { useSelector, useDispatch } from 'react-redux'
  16. import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
  17. import { faStream, faPaperPlane, faSun, faMoon } from '@fortawesome/free-solid-svg-icons'
  18. import { useTheme } from '../hooks'
  19. import { setColorScheme } from '../actions/theme'
  20. import { getColorScheme } from '../selectors/theme'
  21. import { ColorScheme } from '../types'
  22. const NavigationMenu: FC = () => {
  23. const theme = useTheme()
  24. const scheme = useSelector(getColorScheme)
  25. const dispatch = useDispatch()
  26. const switchColorSchemeItem = () => {
  27. switch (scheme) {
  28. case ColorScheme.Light:
  29. return (
  30. <a style={{ color: theme.primary, cursor: 'pointer' }} onClick={() => dispatch(setColorScheme(ColorScheme.Dark))}>
  31. <span className="icon" style={{ color: theme.primary }}>
  32. <FontAwesomeIcon icon={faMoon} />
  33. </span>
  34. &nbsp;
  35. <span>Dark Mode</span>
  36. </a>
  37. )
  38. case ColorScheme.Dark:
  39. return (
  40. <a style={{ color: theme.primary, cursor: 'pointer' }} onClick={() => dispatch(setColorScheme(ColorScheme.Light))}>
  41. <span className="icon" style={{ color: theme.primary }}>
  42. <FontAwesomeIcon icon={faSun} />
  43. </span>
  44. &nbsp;
  45. <span>Light Mode</span>
  46. </a>
  47. )
  48. }
  49. }
  50. return (
  51. <nav>
  52. <div>
  53. <span className="icon" style={{ color: theme.primary }}>
  54. <FontAwesomeIcon icon={faStream} />
  55. </span>
  56. &nbsp;
  57. <Link style={{ color: theme.primary }} to="/">Timeline</Link>
  58. </div>
  59. <div>
  60. <span className="icon" style={{ color: theme.primary }}>
  61. <FontAwesomeIcon icon={faPaperPlane} />
  62. </span>
  63. &nbsp;
  64. <Link style={{ color: theme.primary }} to="/apps">Apps</Link>
  65. </div>
  66. <div>
  67. {switchColorSchemeItem()}
  68. </div>
  69. </nav>
  70. )
  71. }
  72. export default NavigationMenu