riffusion-app/components/PromptEntry.tsx

89 lines
2.6 KiB
TypeScript
Raw Permalink Normal View History

2022-11-23 22:47:18 -07:00
import { NextComponentType } from 'next'
import { PlayingState } from '../types'
2022-11-23 22:47:18 -07:00
interface PromptEntryProps {
prompt: string
2022-11-24 19:32:39 -07:00
index: number
2022-11-24 00:23:34 -07:00
className: string
playingState: PlayingState
2022-11-23 22:47:18 -07:00
}
2022-11-24 13:39:30 -07:00
export default function PromptEntry({
prompt,
2022-11-24 19:32:39 -07:00
index,
2022-11-24 13:39:30 -07:00
className,
playingState,
}: PromptEntryProps) {
const getPromptCopy = (prompt: string) => {
switch (playingState) {
case PlayingState.UNINITIALIZED:
case PlayingState.SAME_PROMPT:
switch (index) {
case 0:
return prompt
case 1:
return prompt
case 2:
return prompt
case 3:
if (prompt == " " || prompt == "") {
return "..."
}
else {
return prompt
}
case 4:
if (prompt == " " || prompt == "") {
return "UP NEXT: Anything you want"
}
else {
return "UP NEXT: " + prompt
}
default: {
console.log("UNHANDLED default")
return prompt
}
}
case PlayingState.TRANSITION:
switch (index) {
case 0:
return prompt
case 1:
return prompt
case 2:
return prompt
case 3:
return prompt
case 4:
if (prompt == " " || prompt == "") {
return "..."
}
else {
return prompt
}
case 5:
if (prompt == " " || prompt == "") {
return "UP NEXT: Anything you want"
}
else {
return "UP NEXT: " + prompt
}
default: {
console.log("UNHANDLED default")
return prompt
}
}
}
}
2022-11-24 13:39:30 -07:00
2022-11-23 22:47:18 -07:00
return (
<>
<p className={className}>
{getPromptCopy(prompt)}
</p>
</>
2022-11-23 22:47:18 -07:00
)
}