Musical keyboard component written in React.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

56 satır
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 AccidentalKey: React.FC<Props> = ({ label = '', orientation = 0 }) => (
  15. <div
  16. style={{
  17. width: '100%',
  18. height: '100%',
  19. backgroundColor: 'var(--color-accidental-key, black)',
  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. filter: 'invert(100)',
  42. [BOTTOM_CSS_ATTRIBUTES[orientation || 0]]: 0,
  43. [LEFT_CSS_ATTRIBUTES[orientation || 0]]: 0,
  44. [WIDTH_CSS_ATTRIBUTES[orientation || 0]]: '100%',
  45. }}
  46. >
  47. {label}
  48. </div>
  49. </div>
  50. )
  51. export default AccidentalKey