-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Core: Draw highlights on top of canvas and add various new features #30894
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
ghengeveld
wants to merge
45
commits into
next
Choose a base branch
from
highlight-overlay
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,375
−143
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View your CI Pipeline Execution ↗ for commit 31ccf9f.
☁️ Nx Cloud last updated this comment at |
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.
9 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
8 tasks
…ing over menu items
8 tasks
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
yannbf
reviewed
Apr 17, 2025
test-storybooks/portable-stories-kitchen-sink/react/stories/__snapshots__/Button.test.tsx.snap
Outdated
Show resolved
Hide resolved
… body because it doesn't always fill the viewport
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #30968
What I did
elements
option toselectors
, which is more appropriate.color
andstyle
options withstyles
. Boxes can be completely styled, there is no longer a limitation on which CSS properties are supported.hoverStyles
andfocusStyles
options to customize styling for hovered/focused/selected boxes.selectable
option, which makes it possible to select boxes on the canvas. A popop/menu will appear with a list of targeted elements.menu
option which adds custom menu items to the popup. These can trigger a custom channel event when clicked, so it is up to whoever sets this up to setup an event listener.priority
option which serves as a tie-breaker when multiple highlights target the same element.keyframes
option which allows the use of animations instyles
,hoverStyles
orfocusStyles
.REMOVE_HIGHLIGHT
event which allows removal of individual highlights (contrary toRESET_HIGHLIGHT
). Using this requires setting the newid
option on the highlight.SCROLL_INTO_VIEW
event which allows scrolling an element into view and briefly highlighting it.Play around with it here: https://highlight-overlay--635781f3500dd2c49e189caf.chromatic.com/?path=/story/blocks-controls-range--with-min&addonPanel=storybook/a11y/panel&a11ySelection=passes.color-contrast.4
Demo stories here: https://highlight-overlay--635781f3500dd2c49e189caf.chromatic.com/?path=/story/highlight-usehighlights--default
(note that if you want to try it on other stories through the a11y addon, you must refresh Storybook because these useHighlights stories override the global instance)
Screen.Recording.2025-03-31.at.15.37.51.mov
New API
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
This PR replaces the old CSS outline method with a new overlay mechanism that renders highlight boxes on top of the canvas, improving visual clarity and interaction.
• Modified /code/core/src/highlight/useHighlights.ts to implement reactive overlay boxes using MutationObserver and ResizeObserver.
• Updated /code/addons/a11y/src/components/A11yContext.tsx to handle selection and revamped highlight events.
• Added /code/core/src/highlight/useHighlights.stories.tsx to demonstrate various overlay scenarios.
• Adjusted /code/.storybook/main.ts to integrate the new highlight overlay story directory.
• Revised /code/core/src/highlight/utils.ts with enhanced createElement and noted a potential unsubscribe issue in useStore.