Ringtone app

index.tsx 3.6 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import {FC, FormEventHandler} from 'react'
  2. import styled from 'styled-components'
  3. import { LeftSidebarWithMenu } from '@theoryofnekomata/viewfinder'
  4. import {models} from '@tonality/library-common'
  5. import CreateRingtoneForm from '../../organisms/forms/CreateRingtone'
  6. import Link from '../../molecules/navigation/Link'
  7. import OmnisearchForm from '../../organisms/forms/Omnisearch'
  8. import Brand from '../../molecules/brand/Brand'
  9. const TopBarComponent = styled('div')({
  10. backgroundColor: 'var(--color-bg, white)',
  11. })
  12. const SidebarMenuComponent = styled('div')({
  13. backgroundColor: 'var(--color-bg, white)',
  14. })
  15. const Padding = styled('div')({
  16. padding: '2rem 0',
  17. })
  18. type Props = {
  19. onSearch?: FormEventHandler,
  20. onSubmit?: FormEventHandler,
  21. composer: models.Composer,
  22. currentRingtone?: models.Ringtone,
  23. composerRingtones: models.Ringtone[],
  24. updateTempo: ({ songRef, dataRef, setTempo, }) => (...args: unknown[]) => void,
  25. updateView: ({ setNoteGlyph, setRestGlyph, noteGlyphs, restGlyphs, }) => (...args: unknown[]) => void,
  26. addRest: ({ formRef, dataRef, songRef, }) => (...args: unknown[]) => void,
  27. addNote: ({ dataRef, formRef, songRef, soundManagerRef, }) => (...args: unknown[]) => void,
  28. togglePlayback: ({ formRef, songRef, soundManagerRef, setPlayTimestamp, setPlaying, }) => (...args: unknown[]) => void,
  29. updateSong: ({ formRef, songRef, }) => (...args: unknown[]) => void,
  30. play: ({ dataRef, playing, setPlaying, playTimestamp, }) => void,
  31. }
  32. const CreateRingtoneTemplate: FC<Props> = ({
  33. onSearch,
  34. onSubmit,
  35. composer,
  36. currentRingtone = {},
  37. composerRingtones = [],
  38. updateTempo,
  39. updateView,
  40. addRest,
  41. addNote,
  42. togglePlayback,
  43. updateSong,
  44. play,
  45. }) => {
  46. return (
  47. <LeftSidebarWithMenu.Layout
  48. brand={
  49. <Brand />
  50. }
  51. userLink={
  52. <div>
  53. User
  54. </div>
  55. }
  56. topBarComponent={TopBarComponent}
  57. sidebarMenuComponent={SidebarMenuComponent}
  58. topBarCenter={
  59. <OmnisearchForm
  60. labels={{
  61. form: 'Search',
  62. query: 'Query',
  63. }}
  64. onSubmit={onSearch}
  65. action="/api/a/search"
  66. />
  67. }
  68. linkComponent={({ url, icon, label, }) => (
  69. <Link
  70. href={url}
  71. >
  72. <LeftSidebarWithMenu.SidebarMenuContainer>
  73. <LeftSidebarWithMenu.SidebarMenuItemIcon>
  74. {icon}
  75. </LeftSidebarWithMenu.SidebarMenuItemIcon>
  76. {label}
  77. </LeftSidebarWithMenu.SidebarMenuContainer>
  78. </Link>
  79. )}
  80. moreLinkMenuItem={{
  81. label: 'More',
  82. icon: 'M',
  83. url: {},
  84. }}
  85. moreLinkComponent={({ url, icon, label, }) => (
  86. <Link
  87. href={url}
  88. >
  89. <LeftSidebarWithMenu.MoreSidebarMenuContainer>
  90. <LeftSidebarWithMenu.MoreSidebarMenuItemIcon>
  91. {icon}
  92. </LeftSidebarWithMenu.MoreSidebarMenuItemIcon>
  93. {label}
  94. </LeftSidebarWithMenu.MoreSidebarMenuContainer>
  95. </Link>
  96. )}
  97. sidebarMenuItems={[
  98. {
  99. id: 'browse',
  100. label: 'Browse',
  101. icon: 'B',
  102. url: {
  103. pathname: '/ringtones',
  104. },
  105. },
  106. {
  107. id: 'compose',
  108. label: 'Compose',
  109. icon: 'C',
  110. url: {
  111. pathname: '/my/create/ringtone',
  112. },
  113. },
  114. ]}
  115. >
  116. <Padding>
  117. <CreateRingtoneForm
  118. onSubmit={onSubmit}
  119. defaultValues={{
  120. ...currentRingtone,
  121. composerId: composer.id,
  122. }}
  123. action="/api/a/create/ringtone"
  124. labels={{
  125. form: 'Create Ringtone',
  126. name: 'Name',
  127. data: 'Data',
  128. cta: 'Post',
  129. }}
  130. updateTempo={updateTempo}
  131. updateView={updateView}
  132. addRest={addRest}
  133. addNote={addNote}
  134. togglePlayback={togglePlayback}
  135. updateSong={updateSong}
  136. play={play}
  137. />
  138. </Padding>
  139. </LeftSidebarWithMenu.Layout>
  140. )
  141. }
  142. export default CreateRingtoneTemplate