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

Commit

Permalink
Merge pull request #52 from lars-reimann/ReadMoreAktualisieren
Browse files Browse the repository at this point in the history
Read more aktualisieren
  • Loading branch information
lars-reimann authored Jun 18, 2021
2 parents ad99a4c + d9f54fc commit d96db9e
Show file tree
Hide file tree
Showing 10 changed files with 475 additions and 255,901 deletions.
2 changes: 2 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"react": "^17.0.2",
"react-bootstrap": "^1.5.2",
"react-dom": "^17.0.2",
"react-markdown": "^6.0.2",
"react-scripts": "4.0.3",
"remark-gfm": "^1.0.0",
"web-vitals": "^1.0.1"
},
"scripts": {
Expand Down
30 changes: 20 additions & 10 deletions client/src/Components/ParameterView/DocumentationText.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import React, {useState} from "react";
import "./ParameterView.css";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import classNames from "classnames";

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

const [readMore,setReadMore] = useState(false);
const moreTextOption = inputText.length > 50
const shortenedText = inputText.split("\n")[0];
const hasMultipleLines = shortenedText !== inputText;

const linkName = readMore ? '[Read less]' : '[Read more]'
const [readMore, setReadMore] = useState(false);

const cssClasses = classNames(
"read-more-button",
{
"pl-1-5rem": !hasMultipleLines,
}
);

return (
<div className="documentation-text">
<p>{!readMore && inputText.substr(0, 50)}
{readMore && inputText}
<button className="read-more-button" onClick={()=>{setReadMore(!readMore)}}>
{moreTextOption && linkName}
</button>
</p>
<div className="docu-paragraph" onClick={() => {
setReadMore(!readMore)
}}>
{!readMore && hasMultipleLines && "▶"}
{readMore && hasMultipleLines && "▼"}
<ReactMarkdown className={cssClasses} children={readMore ? inputText : shortenedText}
remarkPlugins={[remarkGfm]}/>

</div>
);
Expand Down
10 changes: 5 additions & 5 deletions client/src/Components/ParameterView/ParameterNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ type ParameterProps = {inputParameter: PythonParameter}

const ParameterNode = ({inputParameter}: ParameterProps) => {

const hasDescription = !!inputParameter.docstring;
const hasDescription = !!inputParameter.description;

return (
<div className="parametersList">
<span className="parameter-header">
<div className="parameter-header">
<h4 className={"parameter-name"}>{inputParameter?.name}</h4>
<Dropdown>
<Dropdown.Toggle size="sm" variant="outline-primary">
Expand All @@ -23,14 +23,14 @@ const ParameterNode = ({inputParameter}: ParameterProps) => {
<Dropdown.Item eventKey="enum">@Enum</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</span>
</div>
{
hasDescription &&
<DocumentationText inputText={inputParameter?.docstring}/>
<DocumentationText inputText={inputParameter?.description}/>
}
{
!hasDescription &&
<p>No Documentation available</p>
<p className="pl-1-5rem">No Documentation available</p>
}

</div>
Expand Down
21 changes: 15 additions & 6 deletions client/src/Components/ParameterView/ParameterView.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
position: -webkit-sticky;
position: sticky;
top: 0;
overflow-x: hidden;
}

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

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

.parameterViewDiv a{
Expand All @@ -22,12 +25,22 @@
padding-bottom: .5rem;
}

.docuTextHidden {
text-overflow: ellipsis;
}

.docu-paragraph{
display: flex;
justify-content: flex-start;
}

.parameter-header {
display: flex;
justify-content: flex-start;
font-weight: bold;
}

.parameter-name {
float: left;
margin-right: 15px;
}

Expand All @@ -41,15 +54,11 @@
}

.read-more-button {
text-align: left;
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;
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/Components/TreeView/TreeView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import Tree from "../Tree/Tree";
import './tree-view.css';
import packageJson from "../../sklearn.json";
import packageJson from "../../data/sklearn_new_schema.json";
import PythonPackageBuilder from "../../model/PythonPackageBuilder";

type TreeViewProps = {
Expand Down
Loading

0 comments on commit d96db9e

Please sign in to comment.