-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WID-100: add functionality to display the description of the componen…
…t arguments
- Loading branch information
1 parent
8c14590
commit 70f585f
Showing
13 changed files
with
468 additions
and
248 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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as React from "react"; | ||
import Toggle from 'react-toggle' | ||
import {useCallback, useRef} from "react"; | ||
import {WithToggleProps} from "./types"; | ||
|
||
|
||
export default function WithToggle(props: WithToggleProps){ | ||
const ref = useRef(null); | ||
|
||
const changeHandler = useCallback(async () => { | ||
await props.setShowDescription(!props.showDescription) | ||
await props.setDescriptionStr(props.description) | ||
}, [props.description, props.showDescription]) | ||
|
||
return ( | ||
<div ref ={ref} className="alignToggle"> | ||
{props.renderToggleBeforeChildren ? | ||
<> | ||
{ | ||
props.description && | ||
<Toggle | ||
className='description' | ||
name='Description' | ||
checked={props.showDescription} | ||
onChange={changeHandler} | ||
/> | ||
} | ||
<span style={{display: "inline-block", paddingLeft: "0.3rem"}}> | ||
{props.children} | ||
</span> | ||
</> | ||
: | ||
<> | ||
<span style={{display: "inline-block", paddingRight: "0.3rem"}}> | ||
{props.children} | ||
</span> | ||
{ | ||
props.description && | ||
<Toggle | ||
className='description' | ||
name='Description' | ||
checked={props.showDescription} | ||
onChange={changeHandler} | ||
/> | ||
} | ||
</> | ||
} | ||
</div> | ||
) | ||
} |
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,14 @@ | ||
import {ReactElement} from "react"; | ||
|
||
export type WithToggleProps = { | ||
renderToggleBeforeChildren : boolean; | ||
children: ReactElement[] | ReactElement | string; | ||
showDescription: boolean; | ||
setShowDescription: any; | ||
setDescriptionStr: (param: string) => void; | ||
description: string; | ||
} | ||
|
||
export type WithToggleState = { | ||
showDescription : boolean | ||
} |
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
Oops, something went wrong.