This repository has been archived by the owner on Jul 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Pass data via value argument and use children to wrap value
- Loading branch information
Showing
34 changed files
with
390 additions
and
129 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 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,14 +1,17 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
|
||
export const ArrayWidget = ({ children, className }) => ( | ||
<span className={cx(className, 'array', 'widget')}> | ||
{children | ||
? children.map((child) => ( | ||
<span key={child.token || child.title || child}> | ||
{child.title || child.token || child} | ||
</span> | ||
)) | ||
: ''} | ||
</span> | ||
); | ||
export const ArrayWidget = ({ value, children, className }) => | ||
value ? ( | ||
<span className={cx(className, 'array', 'widget')}> | ||
{value.map((item) => ( | ||
<span key={item.token || item.title || item}> | ||
{children | ||
? children(item.title || item.token || item) | ||
: item.title || item.token || item} | ||
</span> | ||
))} | ||
</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
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,8 +1,12 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
import { isBoolean } from 'lodash'; | ||
|
||
export const BooleanWidget = ({ children, className }) => ( | ||
<span className={cx(className, 'boolean', 'widget')}> | ||
{children ? 'Yes' : 'No'} | ||
</span> | ||
); | ||
export const BooleanWidget = ({ value, children, className }) => | ||
isBoolean(value) ? ( | ||
<span className={cx(className, 'boolean', 'widget')}> | ||
{children ? children(value ? 'Yes' : 'No') : value ? 'Yes' : 'No'} | ||
</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
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
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
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,8 +1,11 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
|
||
export const PasswordWidget = ({ children, className }) => ( | ||
<span className={cx(className, 'password', 'widget')}> | ||
{children ? '********' : ''} | ||
</span> | ||
); | ||
export const PasswordWidget = ({ value, children, className }) => | ||
value ? ( | ||
<span className={cx(className, 'password', 'widget')}> | ||
{children ? 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
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
|
||
export const SelectWidget = ({ children, className }) => ( | ||
<span className={cx(className, 'select', 'widget')}> | ||
{children?.title || children?.token || children} | ||
</span> | ||
); | ||
export const SelectWidget = ({ value, children, className }) => | ||
value ? ( | ||
<span className={cx(className, 'select', 'widget')}> | ||
{children | ||
? children(value?.title || value?.token || value) | ||
: value?.title || value?.token || value} | ||
</span> | ||
) : ( | ||
'' | ||
); |
Oops, something went wrong.