-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #816 from gmx-io/release-15
Release 15
- Loading branch information
Showing
60 changed files
with
2,918 additions
and
1,552 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 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,63 @@ | ||
import React, { ReactNode } from "react"; | ||
|
||
interface ExchangeInfoProps { | ||
children?: ReactNode; | ||
divider?: ReactNode; | ||
className?: string; | ||
} | ||
|
||
interface ExchangeInfoGroupProps { | ||
children?: ReactNode; | ||
} | ||
|
||
const LINE_DIVIDER = <div className="line-divider" />; | ||
|
||
function ExchangeInfo({ children, className, divider = LINE_DIVIDER }: ExchangeInfoProps) { | ||
const childrenArr = React.Children.toArray(children) as React.ReactElement[]; | ||
|
||
return ( | ||
<div className={className}> | ||
{childrenArr | ||
.reduce((acc, child, index) => { | ||
if (isExchangeInfoGroup(child)) { | ||
const groupChildren = React.Children.toArray(child.props.children).filter(Boolean) as React.ReactElement[]; | ||
|
||
if (groupChildren.length) { | ||
acc.push( | ||
React.cloneElement(child, { | ||
key: child.props.key ?? index, | ||
children: groupChildren, | ||
}) | ||
); | ||
} | ||
} else { | ||
acc.push(child); | ||
} | ||
|
||
return acc; | ||
}, [] as React.ReactElement[]) | ||
.map((child, index, arr) => { | ||
const isLast = index === arr.length - 1; | ||
|
||
return ( | ||
<> | ||
{child} | ||
{!isLast && divider} | ||
</> | ||
); | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
function ExchangeInfoGroup({ children }: ExchangeInfoGroupProps) { | ||
return <>{children}</>; | ||
} | ||
|
||
function isExchangeInfoGroup(child: ReactNode) { | ||
return React.isValidElement(child) && child.type === ExchangeInfoGroup; | ||
} | ||
|
||
ExchangeInfo.Group = ExchangeInfoGroup; | ||
|
||
export { ExchangeInfo }; |
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 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
4 changes: 2 additions & 2 deletions
4
src/components/Modal/ModalWithPortal.js → src/components/Modal/ModalWithPortal.tsx
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
Oops, something went wrong.