-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* commented way more functions * expanded function description *
- Loading branch information
Showing
7 changed files
with
493 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { FunctionParam } from '../lib/graphtoy/constants'; | ||
|
||
const Wrapper = styled.div` | ||
display: grid; | ||
`; | ||
const FunctionName = styled.div` | ||
display: grid; | ||
color: #ffd700; | ||
margin-bottom: 10px; | ||
`; | ||
const FunctionDescriptionP = styled.div` | ||
display: grid; | ||
`; | ||
interface Props { | ||
description: string | string[]; | ||
text: string; | ||
params: FunctionParam[]; | ||
name: string; | ||
} | ||
|
||
function mapDescription(description: string | string[]) { | ||
let mappedDescription: JSX.Element[] = []; | ||
if (Array.isArray(description)) { | ||
mappedDescription = description.map((d, idx) => <span key={idx}>{d}</span>); | ||
} else { | ||
mappedDescription = [<span key={'single-description'}>{description}</span>]; | ||
} | ||
return mappedDescription; | ||
} | ||
const FunctionDescription: React.FC<Props> = ({ | ||
params, | ||
description, | ||
text, | ||
name, | ||
}) => { | ||
return ( | ||
<Wrapper> | ||
<FunctionName>{name}</FunctionName> | ||
<FunctionDescriptionP>{mapDescription(description)}</FunctionDescriptionP> | ||
{params.map((param) => ( | ||
<p style={{ marginBottom: 2 }} key={`${name}-${param.name}`}> | ||
<span style={{ color: '#eb68ff' }}>{param.name}</span> -{' '} | ||
{mapDescription(param.description)} | ||
</p> | ||
))} | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default FunctionDescription; |
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.