(
values: Record<string, unknown> = {},
)
| 57 | }; |
| 58 | |
| 59 | export const comboboxExampleCode = ( |
| 60 | values: Record<string, unknown> = {}, |
| 61 | ): string => { |
| 62 | const placeholder = values.placeholder as string | undefined; |
| 63 | |
| 64 | const props: string[] = []; |
| 65 | if (placeholder !== undefined && placeholder !== "Select a fruit…") |
| 66 | props.push(`placeholder="${placeholder}"`); |
| 67 | const extraProps = props.length |
| 68 | ? `\n ${props.join("\n ")}` |
| 69 | : ""; |
| 70 | |
| 71 | const optsStr = ""; |
| 72 | |
| 73 | return `import { useCurrentFrame } from "remotion"; |
| 74 | import { revealCount } from "@/lib/remocn-ui"; |
| 75 | import { Combobox } from "@/components/remocn/combobox"; |
| 76 | import { useComboboxTransition } from "@/components/remocn/use-combobox-transition"; |
| 77 | import { useSelectItemTransition } from "@/components/remocn/use-select-item-transition"; |
| 78 | |
| 79 | // Typing "ba" filters ["Apple","Banana","Orange","Grape"] to ["Banana"]. |
| 80 | const QUERY = "ba"; |
| 81 | const TYPE_START = 32; |
| 82 | const FPS = 30; |
| 83 | const CPS = 4; |
| 84 | |
| 85 | export const Scene = () => { |
| 86 | const frame = useCurrentFrame(); |
| 87 | |
| 88 | // Panel opens at frame 16, closes at frame 100. |
| 89 | const panelStyle = useComboboxTransition( |
| 90 | [ |
| 91 | { at: 16, state: "opened", duration: 12 }, |
| 92 | { at: 100, state: "closed", duration: 12 }, |
| 93 | ]${optsStr}, |
| 94 | ); |
| 95 | |
| 96 | // revealCount drives how many characters of QUERY are visible. |
| 97 | const revealed = revealCount( |
| 98 | Math.max(0, frame - TYPE_START), |
| 99 | FPS, |
| 100 | QUERY.length, |
| 101 | CPS, |
| 102 | ); |
| 103 | |
| 104 | // Animate the first row of the filtered list once "ba" narrows it to Banana. |
| 105 | const itemStyle = useSelectItemTransition( |
| 106 | [ |
| 107 | { at: 60, state: "hover", duration: 8 }, |
| 108 | { at: 72, state: "press", duration: 6 }, |
| 109 | { at: 80, state: "selected", duration: 8 }, |
| 110 | ]${optsStr}, |
| 111 | ); |
| 112 | |
| 113 | return ( |
| 114 | <div style={{ position: "relative", width: "100%", height: "100%" }}> |
| 115 | <Combobox${extraProps} |
| 116 | style={panelStyle} |
nothing calls this directly
no outgoing calls
no test coverage detected