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

Composite: add Hover and Typeahead subcomponents #64399

Merged
merged 8 commits into from
Aug 9, 2024

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Aug 9, 2024

What?

Follow-up to #63564

Add Composite.Hover and Composite.Typeahead components

Why?

To improve the offering of the Composite component.

These components are also already used in the repository (imported directly from ariakit). Adding them to Composite will allow us to replace those imports with imports from @wordpress/components.

How?

Testing Instructions

  • Open Storybook, go to the Composite component, and play around with the new Hover and Typeahead examples
  • Check the code
  • Check the docs

This PR doesn't include runtime changes to the actual component.

@ciampo ciampo requested a review from ajitbohra as a code owner August 9, 2024 12:35
@ciampo ciampo self-assigned this Aug 9, 2024
@ciampo ciampo requested a review from a team August 9, 2024 12:35
Copy link

github-actions bot commented Aug 9, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ciampo ciampo added [Type] New API New API to be used by plugin developers or package users. [Package] Components /packages/components labels Aug 9, 2024
Comment on lines +223 to +280
decorators: [
( Story ) => {
return (
<>
{ /* Visually style the active composite item */ }
<style>{ `
[data-active-item] {
background-color: #ffc0b5;
}
` }</style>
<Story />
<div
style={ {
marginTop: '2em',
fontSize: '12px',
fontStyle: 'italic',
} }
>
{ /* eslint-disable-next-line no-restricted-syntax */ }
<p id="list-title">Notes</p>
<ul aria-labelledby="list-title">
<li>
The active composite item is highlighted with a
different background color;
</li>
<li>
A composite item can be the active item even
when it doesn&apos;t have keyboard focus.
</li>
</ul>
</div>
</>
);
},
],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This decorator helps to visually identify the active composite item. It is particularly useful in the Hover example, where composite items become "active" on hover without receiving keyboard focus.

Copy link
Member

Choose a reason for hiding this comment

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

Ooo, helpful!

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Works well and tests well, thanks @ciampo! ✅

I appreciate that this will help remove the direct Ariakit imports in dataviews 👏

@ciampo ciampo force-pushed the feat/stabilize-composite/add-subcomponents branch from 100199b to 4c1fab4 Compare August 9, 2024 16:40
@ciampo ciampo enabled auto-merge (squash) August 9, 2024 16:41
@ciampo ciampo merged commit 46a026b into trunk Aug 9, 2024
64 checks passed
@ciampo ciampo deleted the feat/stabilize-composite/add-subcomponents branch August 9, 2024 17:15
@github-actions github-actions bot added this to the Gutenberg 19.1 milestone Aug 9, 2024
getdave pushed a commit that referenced this pull request Aug 14, 2024
* Composite: add Hover and Typeahead subcomponents

* Add hover example + styles to highlight active item

* Add Composite.Hover props docs

* Add Typeahead docs and Storybook example

* CHANGELOG

* Remove the `focusOnHover` and `blurOnHoverEnd` props.

* Remove ariakit references

* Add import statements to code examples

---

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] New API New API to be used by plugin developers or package users.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants