Monorepo containing core modules of Zeichen.
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.

37 lines
793 B

  1. import * as React from 'react'
  2. import * as PropTypes from 'prop-types'
  3. import { ArrowLeft, Search, FilePlus, FileText, FolderPlus, GitBranch, Trash2, User, Menu } from 'react-feather'
  4. const DEFINED_ICONS = {
  5. 'note': FileText,
  6. 'mind-map': GitBranch,
  7. 'user': User,
  8. 'new-folder': FolderPlus,
  9. 'new-note': FilePlus,
  10. 'bin': Trash2,
  11. 'back': ArrowLeft,
  12. 'search': Search,
  13. 'menu': Menu,
  14. }
  15. const propTypes = {
  16. name: PropTypes.oneOf(Object.keys(DEFINED_ICONS)).isRequired,
  17. }
  18. type Props = PropTypes.InferProps<typeof propTypes>
  19. const Icon: React.FC<Props> = ({
  20. name
  21. }) => {
  22. const { [name as keyof typeof DEFINED_ICONS]: Component = null } = DEFINED_ICONS
  23. if (Component !== null) {
  24. return <Component />
  25. }
  26. return null
  27. }
  28. Icon.propTypes = propTypes
  29. export default Icon