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.
 
 
 
 

57 lines
1.3 KiB

  1. import * as React from 'react'
  2. import * as PropTypes from 'prop-types'
  3. import {
  4. BOTTOM_CSS_ATTRIBUTES,
  5. LEFT_CSS_ATTRIBUTES,
  6. WIDTH_CSS_ATTRIBUTES,
  7. ORIENTATIONS,
  8. } from '../../services/constants'
  9. const propTypes = {
  10. label: PropTypes.string,
  11. orientation: PropTypes.oneOf(ORIENTATIONS),
  12. }
  13. type Props = PropTypes.InferProps<typeof propTypes>
  14. const NaturalKey: React.FC<Props> = ({ label = '', orientation = 0 }) => (
  15. <div
  16. style={{
  17. width: '100%',
  18. height: '100%',
  19. backgroundColor: 'var(--color-natural-key, white)',
  20. border: '1px solid',
  21. boxSizing: 'border-box',
  22. position: 'relative',
  23. }}
  24. >
  25. <div
  26. style={{
  27. width: '100%',
  28. height: '100%',
  29. position: 'absolute',
  30. top: 0,
  31. left: 0,
  32. opacity: 'var(--opacity-highlight)',
  33. backgroundColor: `var(--color-active-key, Highlight)`,
  34. }}
  35. />
  36. <div
  37. style={{
  38. position: 'absolute',
  39. display: 'grid',
  40. placeContent: 'center',
  41. [BOTTOM_CSS_ATTRIBUTES[orientation || 0]]: 0,
  42. [LEFT_CSS_ATTRIBUTES[orientation || 0]]: 0,
  43. [WIDTH_CSS_ATTRIBUTES[orientation || 0]]: '100%',
  44. }}
  45. >
  46. {label}
  47. </div>
  48. </div>
  49. )
  50. NaturalKey.propTypes = propTypes
  51. export default NaturalKey