Skip to content

fix: implement feedback #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 13, 2025
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 35 additions & 32 deletions src/client/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,56 +96,59 @@ export const Editor: FC<EditorProps> = ({
<div className="flex items-center gap-2">
<DropdownMenu>
<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">
<div className="flex items-center justify-center gap-2">
<span className="flex items-center justify-center gap-2 text-xs">
<ZapIcon width={18} height={18} />
<p className="text-xs">Snippets</p>
</div>
Snippets
</span>
<PlusIcon width={18} height={18} />
</DropdownMenuTrigger>

<DropdownMenuPortal>
<DropdownMenuContent align="start">
{snippets.map(
({ name, label, icon: Icon, snippet }, index) => (
<DropdownMenuItem
key={index}
onClick={() => onAddSnippet(name, snippet)}
>
<Icon size={24} />
{label}
</DropdownMenuItem>
),
)}
{snippets.map(({ name, label, icon: Icon, snippet }) => (
<DropdownMenuItem
key={label}
onClick={() => onAddSnippet(name, snippet)}
>
<Icon size={24} />
{label}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenuPortal>
</DropdownMenu>

<DropdownMenu>
<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">
<div className="flex items-center justify-center gap-2">
<span className="flex items-center justify-center gap-2 text-xs">
<NotebookPenIcon width={18} height={18} />
<p className="text-xs">Examples</p>
</div>
Example
</span>
<ChevronDownIcon width={18} height={18} />
</DropdownMenuTrigger>

<DropdownMenuPortal>
<DropdownMenuContent>
{Object.entries(examples).map(([slug, title]) => {
const href = `${window.location.origin}/parameters/example/${slug}`;
return (
<DropdownMenuItem key={slug} asChild={true}>
<a href={href} target="_blank" rel="noreferrer">
<span className="sr-only">
{" "}
(link opens in new tab)
</span>
<ExternalLinkIcon />
{title}
</a>
</DropdownMenuItem>
);
})}
{Object.entries(examples)
.sort()
Copy link
Member

@Parkreiner Parkreiner Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last change: because we didn't give a callback, .sort is going to stringify each entry array and then compare them. I'm guessing that you could get away with value1.localeCompare(value2), where each value is the second element of each entry?

.map(([slug, title]) => {
const href = `${window.location.origin}/parameters/example/${slug}`;
return (
<DropdownMenuItem
key={slug}
asChild={true}
>
<a href={href} target="_blank" rel="noreferrer">
<ExternalLinkIcon />
{title}
<span className="sr-only">
{" "}
(link opens in new tab)
</span>
</a>
</DropdownMenuItem>
);
})}
</DropdownMenuContent>
</DropdownMenuPortal>
</DropdownMenu>
Expand Down