Skip to content

fix: More Notion-like side menu positioning #812

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 2 commits into from
Jun 6, 2024

Conversation

matthewlipski
Copy link
Collaborator

This PR changes the side menu to be positioned centered on the first line of a block. Blocks with no text content usually assume the line height of a paragraph block.

This solution is a bit hacky in that the line height values for different blocks are hard coded instead of taking them from a bounding box, though fixing this would add a lot of complexity. Fortunately, it's easy for consumers to change those values via CSS.

Also, Notion does not center the side menu for things like file blocks, instead using the paragraph block line height, as you can see below:
Screenshot 2024-06-05 at 22 45 12
I think this looks really ugly since the block is short enough that I think it should be centered, so I changed this for file & audio blocks also, as well as for when the add file button is showing in all types of file blocks.

Closes #386

Copy link

vercel bot commented Jun 5, 2024

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

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Jun 6, 2024 11:54am
blocknote-website ✅ Ready (Inspect) Visit Preview Jun 6, 2024 11:54am

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

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

I think it's really smart to do it this way by adding an attribute and then use CSS for the exact positioning! Also great that you tested with the different frameworks.

My only suggestion would be to do this a little bit more "semantically" / pay more attention to naming (naming is always key!).

You now use data-block-height, but actually don't pass a height, but some sort of type. Why don't we just use data-block-type and pass the block type directly? (and with a bit more extra info for files / headings)

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

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

nice, ok when passing CI!

@matthewlipski matthewlipski merged commit ba5971d into main Jun 6, 2024
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.

Side menu is incorrectly positioned in the middle of a block
2 participants