Skip to content
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

feature: add component toolbar portal target #360

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

4leite
Copy link
Contributor

@4leite 4leite commented Mar 4, 2024

Note: This also adjusts the position of the toolbar, attaching it to the top border of the component to prevent the component above 'flashing' on hover. This becomes quite intrusive when interacting with the toolbar regularly.

Copy link

vercel bot commented Mar 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
puck-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2024 10:45am
puck-docs ✅ Ready (Inspect) Visit Preview Mar 5, 2024 10:45am

Copy link

vercel bot commented Mar 4, 2024

@4leite is attempting to deploy a commit to the Measured Team on Vercel.

A member of the Team first needs to authorize it.

@4leite
Copy link
Contributor Author

4leite commented Mar 4, 2024

adds support for #150

Copy link
Member

@chrisvxd chrisvxd left a comment

Choose a reason for hiding this comment

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

Thanks @4leite! Couple of questions

width: auto;
top: -48px;
top: -37px;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think moving the toolbar here is the right solution, as leaving space between the toolbar and the border is a deliberate design choice that gives. I agree the flashing is annoying, but I think the better solution would be to create an invisible spacer between them that prevents the hover from bubbling up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup happy to implement that approach instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -97,6 +97,7 @@ export const DraggableComponent = ({
{label && (
<div className={getClassName("actionsLabel")}>{label}</div>
)}
<div id={`DraggableComponentToolbarPortal-${id}`} />
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of this portal? To inject new actions into the toolbar?

If so, I think a first party API might be a cleaner way of doing this instead of asking the user to inject via a portal. Something like <Puck toolbarActions={<div />} />

Copy link
Contributor Author

@4leite 4leite Mar 5, 2024

Choose a reason for hiding this comment

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

I want to be able to inject from the inline editor. eg https://inline-rich-text.vercel.app/edit (click on the heading).
In the above example they are at the end of toolbar, but I think the middle is better (that was just the easiest for me to target with getElement / css Query hack).
These are dynamically changing based on lexical plugins and contextual for each draggable component.
An alternative would be to set them via setUI, but I do think the portal option is much cleaner for my particular use case.

Copy link
Member

@chrisvxd chrisvxd Mar 25, 2024

Choose a reason for hiding this comment

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

I think this API needs a bit more thought before we move forwards:

  1. I don't think we should be using portals for some elements of custom UI, and props for others.
  2. Users may wish to remove existing overlay controls (possibly a separate, but related API)

I'm now tracking this here: #377

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would still like the (amended) UI fix for the dropdown, which I can put as a separate PR.

#377 is good, but... I would still at the least like a stable data-* attribute I can target in the mean time, even if it's an experimental, undocumented solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants