@@ -3,7 +3,10 @@ import {
33 CheckIcon ,
44 ChevronDownIcon ,
55 CopyIcon ,
6+ ExternalLinkIcon ,
67 FileJsonIcon ,
8+ NotebookPenIcon ,
9+ PlusIcon ,
710 UsersIcon ,
811 ZapIcon ,
912} from "lucide-react" ;
@@ -22,6 +25,7 @@ import { useEditor } from "@/client/contexts/editor";
2225import { useTheme } from "@/client/contexts/theme" ;
2326import { Users } from "@/client/editor/Users" ;
2427import { type SnippetFunc , snippets } from "@/client/snippets" ;
28+ import { examples } from "@/examples" ;
2529import type { ParameterWithSource } from "@/gen/types" ;
2630import type { User } from "@/user" ;
2731import { cn } from "@/utils/cn" ;
@@ -89,31 +93,63 @@ export const Editor: FC<EditorProps> = ({
8993 < Tabs . Trigger icon = { UsersIcon } label = "Users" value = "users" />
9094 </ div >
9195
92- < DropdownMenu >
93- < DropdownMenuTrigger className = "flex w-fit min-w-[140px] cursor-pointer items-center justify-between rounded-md border bg-surface-primary px-2 py-1.5 text-content-secondary transition-colors hover:text-content-primary data-[state=open]:text-content-primary" >
94- < div className = "flex items-center justify-center gap-2" >
95- < ZapIcon width = { 18 } height = { 18 } />
96- < p className = "text-xs" > Snippets</ p >
97- </ div >
98- < ChevronDownIcon width = { 18 } height = { 18 } />
99- </ DropdownMenuTrigger >
100-
101- < DropdownMenuPortal >
102- < DropdownMenuContent align = "start" >
103- { snippets . map (
104- ( { name, label, icon : Icon , snippet } , index ) => (
105- < DropdownMenuItem
106- key = { index }
107- onClick = { ( ) => onAddSnippet ( name , snippet ) }
108- >
109- < Icon size = { 24 } />
110- { label }
111- </ DropdownMenuItem >
112- ) ,
113- ) }
114- </ DropdownMenuContent >
115- </ DropdownMenuPortal >
116- </ DropdownMenu >
96+ < div className = "flex items-center gap-2" >
97+ < DropdownMenu >
98+ < DropdownMenuTrigger className = "flex w-fit min-w-[140px] cursor-pointer items-center justify-between rounded-md border bg-surface-primary px-2 py-1.5 text-content-secondary transition-colors hover:text-content-primary data-[state=open]:text-content-primary" >
99+ < div className = "flex items-center justify-center gap-2" >
100+ < ZapIcon width = { 18 } height = { 18 } />
101+ < p className = "text-xs" > Snippets</ p >
102+ </ div >
103+ < PlusIcon width = { 18 } height = { 18 } />
104+ </ DropdownMenuTrigger >
105+
106+ < DropdownMenuPortal >
107+ < DropdownMenuContent align = "start" >
108+ { snippets . map (
109+ ( { name, label, icon : Icon , snippet } , index ) => (
110+ < DropdownMenuItem
111+ key = { index }
112+ onClick = { ( ) => onAddSnippet ( name , snippet ) }
113+ >
114+ < Icon size = { 24 } />
115+ { label }
116+ </ DropdownMenuItem >
117+ ) ,
118+ ) }
119+ </ DropdownMenuContent >
120+ </ DropdownMenuPortal >
121+ </ DropdownMenu >
122+
123+ < DropdownMenu >
124+ < DropdownMenuTrigger className = "flex w-fit min-w-[140px] cursor-pointer items-center justify-between rounded-md border bg-surface-primary px-2 py-1.5 text-content-secondary transition-colors hover:text-content-primary data-[state=open]:text-content-primary" >
125+ < div className = "flex items-center justify-center gap-2" >
126+ < NotebookPenIcon width = { 18 } height = { 18 } />
127+ < p className = "text-xs" > Examples</ p >
128+ </ div >
129+ < ChevronDownIcon width = { 18 } height = { 18 } />
130+ </ DropdownMenuTrigger >
131+
132+ < DropdownMenuPortal >
133+ < DropdownMenuContent >
134+ { Object . entries ( examples ) . map ( ( [ slug , title ] ) => {
135+ const href = `${ window . location . origin } /parameters/example/${ slug } ` ;
136+ return (
137+ < DropdownMenuItem key = { slug } asChild = { true } >
138+ < a href = { href } target = "_blank" rel = "noreferrer" >
139+ < span className = "sr-only" >
140+ { " " }
141+ (link opens in new tab)
142+ </ span >
143+ < ExternalLinkIcon />
144+ { title }
145+ </ a >
146+ </ DropdownMenuItem >
147+ ) ;
148+ } ) }
149+ </ DropdownMenuContent >
150+ </ DropdownMenuPortal >
151+ </ DropdownMenu >
152+ </ div >
117153 </ div >
118154 </ Tabs . List >
119155
0 commit comments