-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add examples dropdown also in code editor panel #50
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a few bits of feedback, but nothing worth blocking over
</DropdownMenu> | ||
<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"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to say that the default output for a Radix trigger is a button
element, so putting two elements that are semantically block-based (div
and p
) inside it is going to make the HTML invalid
Two things come to mind:
- We might be able to switch the markup around. So:
- Get rid of the
div
and move the classes to the trigger - Swap the
p
for aspan
- Get rid of the
- I don't know how if there are any edge cases, but you might be able to use
asChild
to merge the trigger into first immediate child. But even then, you'd want to swap thediv
for abutton
({ name, label, icon: Icon, snippet }, index) => ( | ||
<DropdownMenuItem | ||
key={index} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a guarantee that each snippet will be unique? In that case, I think we should get rid of the index
, and use some combination of the name
and label
as the render key. If neither are guaranteed to be fully unique on their own, we could also concatenate them to make a compound key
<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"> | ||
<NotebookPenIcon width={18} height={18} /> | ||
<p className="text-xs">Examples</p> | ||
</div> | ||
<ChevronDownIcon width={18} height={18} /> | ||
</DropdownMenuTrigger> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same feedback for the trigger above applies here
|
||
<DropdownMenuPortal> | ||
<DropdownMenuContent> | ||
{Object.entries(examples).map(([slug, title]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realistically this isn't a huge deal, but I think that even now, the JS spec doesn't guarantee that Object.entries
makes an array in a deterministic order. The v8 engine does, but I don't know about other engines (I would expect them to follow v8's lead, though)
What this means is that without a .sort
call, there's a risk that the elements could get scrambled up during re-renders. The stable keys will mean that the state won't get mixed up, but there's a risk the list item order will
Closes coder/internal#853