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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all 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()
.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