@@ -3,7 +3,10 @@ import {
3
3
CheckIcon ,
4
4
ChevronDownIcon ,
5
5
CopyIcon ,
6
+ ExternalLinkIcon ,
6
7
FileJsonIcon ,
8
+ NotebookPenIcon ,
9
+ PlusIcon ,
7
10
UsersIcon ,
8
11
ZapIcon ,
9
12
} from "lucide-react" ;
@@ -22,6 +25,7 @@ import { useEditor } from "@/client/contexts/editor";
22
25
import { useTheme } from "@/client/contexts/theme" ;
23
26
import { Users } from "@/client/editor/Users" ;
24
27
import { type SnippetFunc , snippets } from "@/client/snippets" ;
28
+ import { examples } from "@/examples" ;
25
29
import type { ParameterWithSource } from "@/gen/types" ;
26
30
import type { User } from "@/user" ;
27
31
import { cn } from "@/utils/cn" ;
@@ -89,31 +93,63 @@ export const Editor: FC<EditorProps> = ({
89
93
< Tabs . Trigger icon = { UsersIcon } label = "Users" value = "users" />
90
94
</ div >
91
95
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 >
117
153
</ div >
118
154
</ Tabs . List >
119
155
0 commit comments