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

feat(edgeless): support pie menu widget #6493

Merged
merged 36 commits into from
Mar 21, 2024

Conversation

golok727
Copy link
Contributor

@golok727 golok727 commented Mar 17, 2024

A pie menu inspired by Blender's interface.

For preview I have added a tools menu for edgeless the trigger is 'q'.

tests are wip...

Usage

  • Trigger Key: Each menu is associated with a trigger key to open it. To activate a menu, press and hold the trigger key.

  • Navigation: While holding the trigger key, move the cursor towards the desired action within the pie menu. Hovering over a wedge of the pie menu highlights that action. Release the trigger key to select the highlighted action.

  • Submenu: Submenus can be accessed by hovering over the submenu node (with a blue dot) within the pie menu. To close a submenu just hover over the desired center node

  • Keeping Menu Open: If the trigger key is released before the "SELECT_ON_RELEASE_TIMEOUT" (150ms default) threshold, the pie menu remains open and you can select with your mouse.

  • Shortcut Selection: The numeric keys (0-9) correspond to actions within the pie menu. Pressing a numeric key selects the pie node associated with that number directly.

I have also provided a pie builder api to build pie menus layouts easier. Looking forward for help to make the api better.

Preview

pie2.1.mp4

Pie-preview3
Pie-preview2
Pie-preview1

New!

Color Node

image
image

Color.Node.mp4

Copy link

vercel bot commented Mar 17, 2024

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

Name Status Preview Comments Updated (UTC)
blocksuite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 4:56am
blocksuite-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 4:56am

@hwangdev97
Copy link
Member

Great, this pie menu is exactly what we need!

But there are some color issues that can be quickly addressed. It's best to choose colors from the theme for the hover state so that it can have better light/dark mode compatibility.

shot-2024-03-18-16 08 18@2x

In addition, it is recommended to set a feature flag for related functions so that different users can control the function switch.

In fact, our product design itself also has plans to design a circular menu. I never expected the open-source community to complete it ahead of us!

@golok727
Copy link
Contributor Author

golok727 commented Mar 18, 2024

But there are some color issues that can be quickly addressed. It's best to choose colors from the theme for the hover state so that it can have better light/dark mode compatibility.

Hey! While working on it I used the hover color (--affine-hover-color) but it had some transparency, which didn't look right when hovering over it in the current setup. so for now I just used a hardcoded value. I will fix it 👍🏻

@doodlewind doodlewind added the notable Major improvement worth emphasizing label Mar 18, 2024
Copy link
Member

@doodlewind doodlewind left a comment

Choose a reason for hiding this comment

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

@golok727 thanks again for the great work! I've seen previous comment regarding feature flags and some best practice, and here's the advice:

  • It's really a smooth and polished feature to try, so landing this without feature flag should be fine - we may fallback if needed but no worries.
  • Limiting the usage of this widget in edgeless mode should be expected.

I think @Saul-Mirone would land this after some style checks.

Thanks again for your feat. If you are interested in BlockSuite, AFFiNE and related contributions, feel free to DM me: doodlewind at toeverything dot info

Copy link
Collaborator

@Saul-Mirone Saul-Mirone left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

packages/blocks/src/_specs/_specs.ts Outdated Show resolved Hide resolved
@golok727
Copy link
Contributor Author

golok727 commented Mar 20, 2024

@Saul-Mirone, just to clarify, you mentioned removing it from both the DocSpec and EdgelessSpec, correct? I've commented it out as per your instructions. Additionally, as @doodlewind pointed out, since this is an edgeless-only feature, I've removed its support in Page. PTA👀. Btw I don't know how to enable it in the playground.

Copy link
Member

@doodlewind doodlewind left a comment

Choose a reason for hiding this comment

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

@golok727 you can search for enable_synced_doc_block to see how feature flags is being used in the codebase. Adding a enable_pie_menu flag and test this flag on the key handler for q should be adequate. Also in this way you can enable the flag by default in BlockSuite playground, since there are defaultFlags that can be used to override.

@golok727
Copy link
Contributor Author

@golok727 you can search for enable_synced_doc_block to see how feature flags is being used in the codebase. Adding a enable_pie_menu flag and test this flag on the key handler for q should be adequate. Also in this way you can enable the flag by default in BlockSuite playground, since there are defaultFlags that can be used to override.

Thanks! I added the flag...

@Saul-Mirone Saul-Mirone merged commit b2e0019 into toeverything:master Mar 21, 2024
19 checks passed
@golok727 golok727 deleted the feat/pie branch March 21, 2024 06:42
Brooooooklyn pushed a commit to toeverything/AFFiNE that referenced this pull request Mar 25, 2024
## Features
- toeverything/blocksuite#6544 @golok727
- toeverything/blocksuite#6543 @golok727
- toeverything/blocksuite#6536 @donteatfriedrice
- toeverything/blocksuite#6497 @doouding
- toeverything/blocksuite#6514 @regischen
- toeverything/blocksuite#6523 @donteatfriedrice
- toeverything/blocksuite#6530 @zzj3720
- toeverything/blocksuite#6526 @fourdim
- toeverything/blocksuite#6532 @donteatfriedrice
- toeverything/blocksuite#6493 @golok727
- toeverything/blocksuite#6529 @zzj3720
- toeverything/blocksuite#6528 @zzj3720
- toeverything/blocksuite#6509 @zzj3720
- toeverything/blocksuite#6525 @doodlewind
- toeverything/blocksuite#6502 @donteatfriedrice
- toeverything/blocksuite#6489 @Flrande

## Bugfix
- toeverything/blocksuite#6558 @fourdim
- toeverything/blocksuite#6556 @fourdim
- toeverything/blocksuite#6547 @fundon
- toeverything/blocksuite#6537 @golok727
- toeverything/blocksuite#6531 @donteatfriedrice
- toeverything/blocksuite#6524 @doodlewind
- toeverything/blocksuite#6519 @regischen
- toeverything/blocksuite#6517 @doodlewind
- toeverything/blocksuite#6516 @doodlewind
- toeverything/blocksuite#6510 @donteatfriedrice
- toeverything/blocksuite#6511 @congzhou09
- toeverything/blocksuite#6507 @doouding
- toeverything/blocksuite#6500 @fourdim
- toeverything/blocksuite#6486 @congzhou09
- toeverything/blocksuite#6495 @donteatfriedrice
- toeverything/blocksuite#6488 @Saul-Mirone
- toeverything/blocksuite#6482 @Flrande
- toeverything/blocksuite#6558 @fourdim

## Refactor
- toeverything/blocksuite#6548 @doodlewind
- toeverything/blocksuite#6522 @doodlewind
- toeverything/blocksuite#6518 @regischen
- toeverything/blocksuite#6521 @Saul-Mirone

## Misc
- toeverything/blocksuite#6557 @fourdim
- toeverything/blocksuite#6546 @Flrande
- docs: update package desc
- toeverything/blocksuite#6527 @fourdim
- toeverything/blocksuite#6505 @Brooooooklyn
- toeverything/blocksuite#6503 @fourdim
- v0.13.0
- toeverything/blocksuite#6496 @doodlewind
- toeverything/blocksuite#6562 @donteatfriedrice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notable Major improvement worth emphasizing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants