-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61d9613
commit 52be1ca
Showing
2 changed files
with
27 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
export default function Wrapper() { | ||
import React from 'react' | ||
|
||
// @ts-expect-error(type declaration missing) | ||
import RevealBase from '../lib/Base.js' | ||
|
||
/** | ||
* this function is a wrapper for all the reveal components | ||
* @param {object} props | ||
* @param {boolean} props.when | ||
* @param {boolean} props.in | ||
* @param {string} props.inEffect | ||
Check warning on line 11 in src/HOC/wrapper.tsx GitHub Actions / lint
|
||
* @param {string} props.outEffect | ||
Check warning on line 12 in src/HOC/wrapper.tsx GitHub Actions / lint
|
||
* @param {React.ReactNode} children | ||
* @returns {React.ReactNode} | ||
Check warning on line 14 in src/HOC/wrapper.tsx GitHub Actions / lint
|
||
*/ | ||
export default function wrapper(props: { when: any; in: any }, inEffect: any, outEffect: any, children: string | number | boolean | | ||
React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined) { | ||
if ('in' in props) | ||
props.when = props.in | ||
// check if children is a single element | ||
if (React.Children.count(children) < 2) | ||
return <RevealBase {...props} inEffect={inEffect} outEffect={outEffect} children={children} /> | ||
// map through elements if children is an array | ||
children = React.Children.map(children, child => | ||
<RevealBase {...props} inEffect={inEffect} outEffect={outEffect} children={child} />, | ||
) | ||
return 'Fragment' in React ? <React.Fragment>{children}</React.Fragment> : <span>{children}</span> | ||
} |
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