Musical keyboard component written in React.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

109 行
2.4 KiB

  1. import * as React from 'react'
  2. import * as PropTypes from 'prop-types'
  3. import StyledAccidentalKey from '../StyledAccidentalKey/StyledAccidentalKey'
  4. import StyledNaturalKey from '../StyledNaturalKey/StyledNaturalKey'
  5. import Keyboard, { propTypes } from './Keyboard'
  6. const Wrapper: React.FC = (props) => (
  7. <div
  8. {...props}
  9. style={{
  10. // @ts-ignore
  11. '--color-channel-0': '#f55',
  12. '--color-channel-1': '#ff0',
  13. '--color-channel-2': '#0a0',
  14. '--color-channel-3': '#05a',
  15. '--color-channel-4': '#a0f',
  16. '--color-channel-5': '#a00',
  17. '--color-channel-6': '#a50',
  18. '--color-channel-7': '#fa0',
  19. '--color-channel-8': '#0f0',
  20. '--color-channel-9': '#0aa',
  21. '--color-channel-10': '#0ff',
  22. '--color-channel-11': '#f0a',
  23. '--color-channel-12': '#aa0',
  24. '--color-channel-13': '#550',
  25. '--color-channel-14': '#50a',
  26. '--color-channel-15': '#f5f',
  27. }}
  28. />
  29. )
  30. export default {
  31. title: 'Keyboard',
  32. }
  33. type Props = PropTypes.InferProps<typeof propTypes>
  34. // By passing optional props to this story, you can control the props of the component when
  35. // you consume the story in a test.
  36. export const Default = (props?: Partial<Props>) => (
  37. <Wrapper>
  38. <Keyboard {...props} startKey={21} endKey={108} />
  39. </Wrapper>
  40. )
  41. export const WithActiveKeys = (props?: Partial<Props>) => (
  42. <Wrapper>
  43. <Keyboard
  44. {...props}
  45. startKey={21}
  46. endKey={108}
  47. keyChannels={[
  48. {
  49. channel: 0,
  50. key: 60,
  51. velocity: 1,
  52. },
  53. {
  54. channel: 0,
  55. key: 64,
  56. velocity: 1,
  57. },
  58. {
  59. channel: 0,
  60. key: 67,
  61. velocity: 1,
  62. },
  63. ]}
  64. />
  65. </Wrapper>
  66. )
  67. export const WithDifferentKeyRange = (props?: Partial<Props>) => (
  68. <Wrapper>
  69. <Keyboard {...props} height={300} startKey={48} endKey={71} />
  70. </Wrapper>
  71. )
  72. export const Styled = (props?: Partial<Props>) => (
  73. <Wrapper>
  74. <Keyboard
  75. {...props}
  76. startKey={21}
  77. endKey={108}
  78. keyChannels={[
  79. {
  80. channel: 0,
  81. key: 60,
  82. velocity: 1,
  83. },
  84. {
  85. channel: 0,
  86. key: 63,
  87. velocity: 1,
  88. },
  89. {
  90. channel: 0,
  91. key: 67,
  92. velocity: 1,
  93. },
  94. ]}
  95. keyComponents={{
  96. natural: StyledNaturalKey,
  97. accidental: StyledAccidentalKey,
  98. }}
  99. />
  100. </Wrapper>
  101. )