Musical keyboard component written in React.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

424 linhas
13 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 LIGHT_COLOR = 'white'
  10. const propTypes = {
  11. label: PropTypes.string,
  12. orientation: PropTypes.oneOf(ORIENTATIONS),
  13. }
  14. type Props = PropTypes.InferProps<typeof propTypes>
  15. const StyledNaturalKey: React.FC<Props> = ({ label = '', orientation = 0 }) => (
  16. <div
  17. style={{
  18. width: '100%',
  19. height: '100%',
  20. position: 'relative',
  21. }}
  22. >
  23. <div
  24. style={{
  25. position: 'absolute',
  26. top: 0,
  27. left: 0,
  28. width: '100%',
  29. height: '100%',
  30. }}
  31. >
  32. <div
  33. style={{
  34. width: '100%',
  35. height: '100%',
  36. position: 'relative',
  37. }}
  38. >
  39. <div
  40. style={{
  41. width: '100%',
  42. height: '100%',
  43. backgroundColor: 'black',
  44. position: 'absolute',
  45. top: '0',
  46. left: '0',
  47. }}
  48. />
  49. <div
  50. style={{
  51. width: '100%',
  52. height: '100%',
  53. padding:
  54. 'calc(1px * var(--size-scale-factor, 1)) 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  55. boxSizing: 'border-box',
  56. position: 'absolute',
  57. top: '0',
  58. left: '0',
  59. }}
  60. >
  61. <div
  62. style={{
  63. width: '100%',
  64. height: '100%',
  65. backgroundColor: `var(--color-natural-key, #e3e3e5)`,
  66. borderRadius: '0 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  67. opacity: 1,
  68. }}
  69. />
  70. </div>
  71. <div
  72. style={{
  73. width: '100%',
  74. height: 'calc(33 / 80 * 100%)',
  75. padding:
  76. '0 calc(1px * var(--size-scale-factor, 1)) calc(2px * var(--size-scale-factor, 1)) calc(2px * var(--size-scale-factor, 1))',
  77. boxSizing: 'border-box',
  78. backgroundClip: 'content-box',
  79. position: 'absolute',
  80. bottom: '0',
  81. left: '0',
  82. maskImage: 'linear-gradient(to bottom, transparent, white)',
  83. WebkitMaskImage: 'linear-gradient(to bottom, transparent, white)',
  84. backgroundColor: LIGHT_COLOR,
  85. opacity: 0.25,
  86. }}
  87. />
  88. <div
  89. style={{
  90. width: '100%',
  91. height: '100%',
  92. backgroundColor: 'black',
  93. padding:
  94. 'calc(1px * var(--size-scale-factor, 1)) calc(2px * var(--size-scale-factor, 1)) calc(3px * var(--size-scale-factor, 1)) calc(3px * var(--size-scale-factor, 1))',
  95. boxSizing: 'border-box',
  96. backgroundClip: 'content-box',
  97. position: 'absolute',
  98. bottom: '0',
  99. left: '0',
  100. opacity: '0.08',
  101. maskImage: 'linear-gradient(to bottom, transparent, white)',
  102. WebkitMaskImage: 'linear-gradient(to bottom, transparent, white)',
  103. }}
  104. />
  105. <div
  106. style={{
  107. width: '100%',
  108. height: 'calc(2px * var(--size-scale-factor, 1))',
  109. padding: '0 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  110. boxSizing: 'border-box',
  111. position: 'absolute',
  112. bottom: '0',
  113. left: '0',
  114. }}
  115. >
  116. <div
  117. style={{
  118. width: '100%',
  119. height: '100%',
  120. backgroundColor: 'black',
  121. borderRadius: '0 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  122. opacity: '0.25',
  123. }}
  124. />
  125. </div>
  126. <div
  127. style={{
  128. width: 'calc(2px * var(--size-scale-factor, 1))',
  129. height: '100%',
  130. padding:
  131. 'calc(1px * var(--size-scale-factor, 1)) 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  132. boxSizing: 'border-box',
  133. position: 'absolute',
  134. bottom: '0',
  135. left: '0',
  136. }}
  137. >
  138. <div
  139. style={{
  140. width: '100%',
  141. height: '100%',
  142. backgroundColor: 'black',
  143. borderRadius: '0 0 0 calc(1px * var(--size-scale-factor, 1))',
  144. opacity: '0.07',
  145. }}
  146. />
  147. </div>
  148. <div
  149. style={{
  150. width: '100%',
  151. height: 'calc(6px * var(--size-scale-factor, 1))',
  152. padding: 'calc(1px * var(--size-scale-factor, 1)) 0 0 calc(1px * var(--size-scale-factor, 1))',
  153. boxSizing: 'border-box',
  154. position: 'absolute',
  155. top: '0',
  156. left: '0',
  157. }}
  158. >
  159. <div
  160. style={{
  161. width: '100%',
  162. height: '100%',
  163. backgroundColor: 'black',
  164. maskImage: 'linear-gradient(to bottom, white, transparent)',
  165. WebkitMaskImage: 'linear-gradient(to bottom, white, transparent)',
  166. opacity: '0.12',
  167. }}
  168. />
  169. </div>
  170. <div
  171. style={{
  172. width: '100%',
  173. padding: 'calc(1px * var(--size-scale-factor, 1)) 0 0 calc(1px * var(--size-scale-factor, 1))',
  174. boxSizing: 'border-box',
  175. position: 'absolute',
  176. top: '0',
  177. left: '0',
  178. height: 'calc(3px * var(--size-scale-factor, 1))',
  179. }}
  180. >
  181. <div
  182. style={{
  183. width: '100%',
  184. height: '100%',
  185. backgroundColor: 'black',
  186. opacity: '0.12',
  187. }}
  188. />
  189. </div>
  190. <div
  191. style={{
  192. width: 'calc(1px * var(--size-scale-factor, 1))',
  193. height: '100%',
  194. padding: 'calc(1px * var(--size-scale-factor, 1)) 0 calc(1px * var(--size-scale-factor, 1)) 0',
  195. boxSizing: 'border-box',
  196. position: 'absolute',
  197. bottom: '0',
  198. right: '0',
  199. }}
  200. >
  201. <div
  202. style={{
  203. width: '100%',
  204. height: '100%',
  205. backgroundColor: LIGHT_COLOR,
  206. borderRadius: '0 0 calc(1px * var(--size-scale-factor, 1)) 0',
  207. opacity: '0.12',
  208. }}
  209. />
  210. </div>
  211. </div>
  212. </div>
  213. <div
  214. style={{
  215. position: 'absolute',
  216. top: 0,
  217. left: 0,
  218. width: '100%',
  219. height: '100%',
  220. opacity: 'var(--opacity-highlight)',
  221. }}
  222. >
  223. <div
  224. style={{
  225. width: '100%',
  226. height: '100%',
  227. position: 'relative',
  228. }}
  229. >
  230. <div
  231. style={{
  232. width: '100%',
  233. height: '100%',
  234. backgroundColor: 'black',
  235. position: 'absolute',
  236. top: '0',
  237. left: '0',
  238. }}
  239. />
  240. <div
  241. style={{
  242. width: '100%',
  243. height: '100%',
  244. padding:
  245. 'calc(1px * var(--size-scale-factor, 1)) 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  246. boxSizing: 'border-box',
  247. position: 'absolute',
  248. top: '0',
  249. left: '0',
  250. }}
  251. >
  252. <div
  253. style={{
  254. width: '100%',
  255. height: '100%',
  256. backgroundColor: `var(--color-active-key, Highlight)`,
  257. borderRadius: '0 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  258. opacity: 0.75,
  259. }}
  260. />
  261. </div>
  262. <div
  263. style={{
  264. width: '100%',
  265. height: 'calc(33 / 80 * 100%)',
  266. padding:
  267. '0 calc(1px * var(--size-scale-factor, 1)) calc(2px * var(--size-scale-factor, 1)) calc(2px * var(--size-scale-factor, 1))',
  268. boxSizing: 'border-box',
  269. backgroundClip: 'content-box',
  270. position: 'absolute',
  271. bottom: '0',
  272. left: '0',
  273. maskImage: 'linear-gradient(to bottom, transparent, white)',
  274. WebkitMaskImage: 'linear-gradient(to bottom, transparent, white)',
  275. backgroundColor: LIGHT_COLOR,
  276. opacity: 0.12,
  277. }}
  278. />
  279. <div
  280. style={{
  281. width: '100%',
  282. height: '100%',
  283. backgroundColor: 'black',
  284. padding:
  285. 'calc(1px * var(--size-scale-factor, 1)) calc(2px * var(--size-scale-factor, 1)) calc(3px * var(--size-scale-factor, 1)) calc(3px * var(--size-scale-factor, 1))',
  286. boxSizing: 'border-box',
  287. backgroundClip: 'content-box',
  288. position: 'absolute',
  289. bottom: '0',
  290. left: '0',
  291. opacity: '0.08',
  292. maskImage: 'linear-gradient(to bottom, transparent, white)',
  293. WebkitMaskImage: 'linear-gradient(to bottom, transparent, white)',
  294. }}
  295. />
  296. <div
  297. style={{
  298. width: '100%',
  299. height: 'calc(2px * var(--size-scale-factor, 1))',
  300. padding: '0 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  301. boxSizing: 'border-box',
  302. position: 'absolute',
  303. bottom: '0',
  304. left: '0',
  305. }}
  306. >
  307. <div
  308. style={{
  309. width: '100%',
  310. height: '100%',
  311. backgroundColor: 'black',
  312. borderRadius: '0 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  313. opacity: '0.25',
  314. }}
  315. />
  316. </div>
  317. <div
  318. style={{
  319. width: 'calc(2px * var(--size-scale-factor, 1))',
  320. height: '100%',
  321. padding:
  322. 'calc(1px * var(--size-scale-factor, 1)) 0 calc(1px * var(--size-scale-factor, 1)) calc(1px * var(--size-scale-factor, 1))',
  323. boxSizing: 'border-box',
  324. position: 'absolute',
  325. bottom: '0',
  326. left: '0',
  327. }}
  328. >
  329. <div
  330. style={{
  331. width: '100%',
  332. height: '100%',
  333. backgroundColor: 'black',
  334. borderRadius: '0 0 0 calc(1px * var(--size-scale-factor, 1))',
  335. opacity: '0.07',
  336. }}
  337. />
  338. </div>
  339. <div
  340. style={{
  341. width: '100%',
  342. height: 'calc(6px * var(--size-scale-factor, 1))',
  343. padding: 'calc(1px * var(--size-scale-factor, 1)) 0 0 calc(1px * var(--size-scale-factor, 1))',
  344. boxSizing: 'border-box',
  345. position: 'absolute',
  346. top: '0',
  347. left: '0',
  348. }}
  349. >
  350. <div
  351. style={{
  352. width: '100%',
  353. height: '100%',
  354. backgroundColor: 'black',
  355. maskImage: 'linear-gradient(to bottom, white, transparent)',
  356. WebkitMaskImage: 'linear-gradient(to bottom, white, transparent)',
  357. opacity: '0.12',
  358. }}
  359. />
  360. </div>
  361. <div
  362. style={{
  363. width: '100%',
  364. padding: 'calc(1px * var(--size-scale-factor, 1)) 0 0 calc(1px * var(--size-scale-factor, 1))',
  365. boxSizing: 'border-box',
  366. position: 'absolute',
  367. top: '0',
  368. left: '0',
  369. height: 'calc(4px * var(--size-scale-factor, 1))',
  370. }}
  371. >
  372. <div
  373. style={{
  374. width: '100%',
  375. height: '100%',
  376. backgroundColor: 'black',
  377. opacity: '0.12',
  378. }}
  379. />
  380. </div>
  381. <div
  382. style={{
  383. width: 'calc(1px * var(--size-scale-factor, 1))',
  384. height: '100%',
  385. padding: 'calc(1px * var(--size-scale-factor, 1)) 0 calc(1px * var(--size-scale-factor, 1)) 0',
  386. boxSizing: 'border-box',
  387. position: 'absolute',
  388. bottom: '0',
  389. right: '0',
  390. }}
  391. >
  392. <div
  393. style={{
  394. width: '100%',
  395. height: '100%',
  396. backgroundColor: LIGHT_COLOR,
  397. borderRadius: '0 0 calc(1px * var(--size-scale-factor, 1)) 0',
  398. opacity: '0.12',
  399. }}
  400. />
  401. </div>
  402. </div>
  403. </div>
  404. <div
  405. style={{
  406. position: 'absolute',
  407. display: 'grid',
  408. placeContent: 'center',
  409. [BOTTOM_CSS_ATTRIBUTES[orientation || 0]]: 0,
  410. [LEFT_CSS_ATTRIBUTES[orientation || 0]]: 0,
  411. [WIDTH_CSS_ATTRIBUTES[orientation || 0]]: '100%',
  412. }}
  413. >
  414. {label}
  415. </div>
  416. </div>
  417. )
  418. export default StyledNaturalKey