Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Dokumenations anzeige schoen machen #28

Merged
merged 5 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions client/src/Components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import ParameterView from "../ParameterView/ParameterView";
import TreeView from "../TreeView/TreeView";

function App() {
const [parameters, setParameters] = useState([]);

return (
<div className="App">
<TreeView />
<ParameterView parameters={null}/>
<TreeView setParameters={setParameters}/>
<ParameterView inputParameters={parameters}/>
</div>
);
}
Expand Down
25 changes: 25 additions & 0 deletions client/src/Components/ParameterView/DocumentationText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, {useState} from "react";
import "./ParameterView.css";

// @ts-ignore
const DocumentationText = ({inputText}) => {

const [readMore,setReadMore] = useState(false);
const moreTextOption = inputText.length > 50

const linkName = readMore ? '[Read less]' : '[Read more]'

return (
<div>
<p>{!readMore && inputText.substr(0, 50)}
{readMore && inputText}
<button className="read-more-button" onClick={()=>{setReadMore(!readMore)}}>
{moreTextOption && linkName}
</button>
</p>

</div>
);
};

export default DocumentationText;
22 changes: 22 additions & 0 deletions client/src/Components/ParameterView/ParameterNode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import "./ParameterView.css";
import DocumentationText from "./DocumentationText";
import PythonParameter from "../../model/PythonParameter";

type ParameterProps = {inputParameter: PythonParameter}

const ParameterNode = ({inputParameter}: ParameterProps) => {
return (
<div className="parametersList">

<span className="parameter-name">
<h4>{inputParameter?.name}</h4>
</span>

<DocumentationText inputText={inputParameter?.docstring}/>
</div>
);
};

export default ParameterNode;

42 changes: 42 additions & 0 deletions client/src/Components/ParameterView/ParameterView.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.parameterViewDiv{
position: -webkit-sticky;
position: sticky;
top: 0;
padding-right: 1rem;
}

.parameterViewDiv h2{
padding-top: 1rem;
padding-left: 1rem;
}

.parameterViewDiv a{
padding-left: .5rem;
}

.parametersList {
padding-left: 1rem;
padding-bottom: .5rem;
}

.parameter-name {
font-weight: bold;
}

.visibility-indicator {
display: inline-block;
width: 1rem;
}

.read-more-button {
background: none!important;
border: none;
/*padding: 0!important;*/
padding-left: 0.5rem;
/*optional*/
font-family: arial, sans-serif;
/*input has OS specific font-family*/
color: #069;
text-decoration: underline;
cursor: pointer;
}
17 changes: 0 additions & 17 deletions client/src/Components/ParameterView/ParameterView.js

This file was deleted.

24 changes: 24 additions & 0 deletions client/src/Components/ParameterView/ParameterView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ParameterNode from "./ParameterNode";
import React from "react";
import PythonParameter from "../../model/PythonParameter";

type ParameterViewProps = {inputParameters: PythonParameter[]}

const ParameterView = ({inputParameters}: ParameterViewProps) => {

return (

<div className="parameterViewDiv">
<h2>Parameters</h2>
{
inputParameters?.map(function (parameters) {
return (<ParameterNode key={parameters.name} inputParameter={parameters} />)
})
}

</div>
)
};

export default ParameterView;