Musical keyboard component written in React.
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.
 
 
 
 

39 lines
930 B

  1. import * as React from 'react'
  2. import * as PropTypes from 'prop-types'
  3. import keyPropTypes from '../../services/keyPropTypes'
  4. type Props = PropTypes.InferProps<typeof keyPropTypes>
  5. const NaturalKey: React.FC<Props> = ({ keyChannels }) => (
  6. <div
  7. style={{
  8. width: '100%',
  9. height: '100%',
  10. backgroundColor: 'var(--color-natural-key, white)',
  11. border: '1px solid',
  12. boxSizing: 'border-box',
  13. position: 'relative',
  14. }}
  15. >
  16. {Array.isArray(keyChannels!) &&
  17. keyChannels.map((c) => (
  18. <div
  19. key={c!.channel}
  20. style={{
  21. width: '100%',
  22. height: '100%',
  23. position: 'absolute',
  24. top: 0,
  25. left: 0,
  26. opacity: 0.75,
  27. backgroundColor: `var(--color-channel-${c!.channel}, Highlight)`,
  28. }}
  29. />
  30. ))}
  31. </div>
  32. )
  33. NaturalKey.propTypes = keyPropTypes
  34. export default NaturalKey