-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* `DisclosureContent`: migrate from `reakit` to `@ariakit/react` * add changelog entry * include `WordPressComponentProps` & spread props * move changelog entry to UNRELEASED * adjust comment to mention `Ariakit` rather than `reakit` * remove link to `ariakit` docs & comment about future plans
- Loading branch information
Showing
4 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
// eslint-disable-next-line no-restricted-imports | ||
import * as Ariakit from '@ariakit/react'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { forwardRef } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { DisclosureContentProps } from './types'; | ||
import type { WordPressComponentProps } from '../context'; | ||
|
||
/** | ||
* Accessible Disclosure component that controls visibility of a section of | ||
* content. It follows the WAI-ARIA Disclosure Pattern. | ||
*/ | ||
const UnforwardedDisclosureContent = ( | ||
{ | ||
visible, | ||
children, | ||
...props | ||
}: WordPressComponentProps< DisclosureContentProps, 'div', false >, | ||
ref: React.ForwardedRef< any > | ||
) => { | ||
const disclosure = Ariakit.useDisclosureStore( { open: visible } ); | ||
|
||
return ( | ||
<Ariakit.DisclosureContent | ||
store={ disclosure } | ||
ref={ ref } | ||
{ ...props } | ||
> | ||
{ children } | ||
</Ariakit.DisclosureContent> | ||
); | ||
}; | ||
|
||
export const DisclosureContent = forwardRef( UnforwardedDisclosureContent ); | ||
export default DisclosureContent; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export type DisclosureContentProps = { | ||
/** | ||
* If set to `true` the content will be shown, otherwise it's hidden. | ||
*/ | ||
visible?: boolean; | ||
/** | ||
* The content to display within the component. | ||
*/ | ||
children: React.ReactNode; | ||
}; |