Source

components/MusicSelection/MusicCard/MusicCard.js

  1. // NPM module imports
  2. import React from "react";
  3. import PropTypes from "prop-types";
  4. // Component imports
  5. import RectangularButton from "../../Buttons/RectangularButton/RectangularButton";
  6. // File imports
  7. import * as buttonTypes from "../../Buttons/buttonTypes";
  8. import * as rectButtonBgColors from "../../Buttons/RectangularButton/rectangularButtonColorOptions";
  9. import * as cardColorOptions from "./musicCardColorOptions";
  10. // Style imports
  11. import styles from "./MusicCard.module.scss";
  12. /**
  13. * Renders the MusicCard component
  14. * @component
  15. * @category MusicSelection
  16. * @author Dan Levy <danlevy124@gmail.com>
  17. */
  18. const MusicCard = (props) => {
  19. // Returns the JSX to render
  20. return (
  21. <div className={`${styles.musicCard} ${styles[props.cardColor]}`}>
  22. {/* Music title */}
  23. <h1 className={styles.musicCardName}>{props.title}</h1>
  24. {/* Composers */}
  25. <h2 className={styles.musicCardComposers}>{props.composers}</h2>
  26. {/* Division line */}
  27. <span className={styles.musicCardDivisionLine}></span>
  28. {/* Options */}
  29. <div className={styles.musicCardButtons}>
  30. {/* View song button */}
  31. <RectangularButton
  32. backgroundColor={rectButtonBgColors.WHITE}
  33. type={buttonTypes.BUTTON}
  34. value="view-song"
  35. text="View Song"
  36. onClick={props.onViewSongClick}
  37. />
  38. {/* View performance button */}
  39. <RectangularButton
  40. backgroundColor={rectButtonBgColors.WHITE}
  41. type={buttonTypes.BUTTON}
  42. value="view-performance"
  43. text="View Performance"
  44. onClick={props.onViewPerformanceClick}
  45. />
  46. </div>
  47. </div>
  48. );
  49. };
  50. // Prop types for the MusicCard component
  51. MusicCard.propTypes = {
  52. /**
  53. * The title of the music
  54. */
  55. title: PropTypes.string.isRequired,
  56. /**
  57. * A string containing all composer(s)
  58. */
  59. composers: PropTypes.string.isRequired,
  60. /**
  61. * The background color of the card.
  62. * See [options]{@link module:musicCardColorOptions}.
  63. */
  64. cardColor: PropTypes.oneOf(Object.values(cardColorOptions)).isRequired,
  65. /**
  66. * Click handler for viewing (i.e. practicing) the song
  67. */
  68. onViewSongClick: PropTypes.func.isRequired,
  69. /**
  70. * Click handler for viewing the performance for the selected song
  71. */
  72. onViewPerformanceClick: PropTypes.func.isRequired,
  73. };
  74. export default MusicCard;