MCPcopy Create free account
hub / github.com/Remocn/remocn / comboboxExampleCode

Function comboboxExampleCode

components/docs/examples/combobox-example.tsx:59–122  ·  view source on GitHub ↗
(
  values: Record<string, unknown> = {},
)

Source from the content-addressed store, hash-verified

57};
58
59export 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";
74import { revealCount } from "@/lib/remocn-ui";
75import { Combobox } from "@/components/remocn/combobox";
76import { useComboboxTransition } from "@/components/remocn/use-combobox-transition";
77import { useSelectItemTransition } from "@/components/remocn/use-select-item-transition";
78
79// Typing "ba" filters ["Apple","Banana","Orange","Grape"] to ["Banana"].
80const QUERY = "ba";
81const TYPE_START = 32;
82const FPS = 30;
83const CPS = 4;
84
85export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected