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

Function commandMenuExampleCode

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

Source from the content-addressed store, hash-verified

55};
56
57export const commandMenuExampleCode = (
58 _values: Record<string, unknown> = {},
59): string => {
60 const extraProps = "";
61 const optsStr = "";
62
63 return `import { useCurrentFrame } from "remotion";
64import { revealCount } from "@/lib/remocn-ui";
65import { CommandMenu } from "@/components/remocn/command-menu";
66import { useCommandMenuTransition } from "@/components/remocn/use-command-menu-transition";
67import { useCommandMenuItemTransition } from "@/components/remocn/use-command-menu-item-transition";
68
69const QUERY = "settings";
70const TYPE_START = 20;
71const FPS = 30;
72const CPS = 4;
73
74export const Scene = () => {
75 const frame = useCurrentFrame();
76
77 // Panel zooms in, holds while query is typed and a row is selected, then closes.
78 const panelStyle = useCommandMenuTransition(
79 [
80 { at: 16, state: "opened", duration: 16 },
81 { at: 108, state: "closed", duration: 12 },
82 ]${optsStr},
83 );
84
85 // revealCount drives how many characters of QUERY are visible — the component
86 // filters the list as more characters appear.
87 const revealed = revealCount(
88 Math.max(0, frame - TYPE_START),
89 FPS,
90 QUERY.length,
91 CPS,
92 );
93
94 // Animate the first row of the filtered list: idle → hover → press → selected.
95 const itemStyle = useCommandMenuItemTransition(
96 [
97 { at: 84, state: "hover", duration: 8 },
98 { at: 92, state: "press", duration: 6 },
99 { at: 100, state: "selected", duration: 8 },
100 ]${optsStr},
101 );
102
103 return (
104 <div style={{ position: "relative", width: "100%", height: "100%" }}>
105 <CommandMenu${extraProps}
106 style={panelStyle}
107 query={QUERY}
108 revealCount={revealed}
109 itemStyles={[itemStyle]}
110 />
111 </div>
112 );
113};`;
114};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected