Skip to content

Commit

Permalink
Merge pull request #3 from isr-ifi/feat/extended-visual-components
Browse files Browse the repository at this point in the history
feat(components): register new visual components
  • Loading branch information
Chreggii authored Aug 18, 2020
2 parents 5fff43a + 10aafea commit 047cb82
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 93 deletions.
5 changes: 5 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
"eject": "node ../node_modules/react-scripts/bin/react-scripts.js eject"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "file:../node_modules/@fortawesome/fontawesome-svg-core",
"@fortawesome/free-solid-svg-icons": "file:../node_modules/@fortawesome/free-solid-svg-icons",
"@fortawesome/react-fontawesome": "file:../node_modules/@fortawesome/react-fontawesome",
"apexcharts": "file:../node_modules/apexcharts",
"react": "file:../node_modules/react",
"react-apexcharts": "file:../node_modules/react-apexcharts",
"react-dom": "file:../node_modules/react-dom",
"react-scripts": "file:../node_modules/react-scripts",
"react-spring": "file:../node_modules/react-spring",
"react-redux": "file:../node_modules/react-redux",
"redux": "file:../node_modules/redux",
"react-svg": "file:../node_modules/react-svg",
"visual-components": "file:.."
},
"devDependencies": {
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@
"react": "^16.0.0"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.25",
"@fortawesome/free-solid-svg-icons": "^5.11.2",
"@fortawesome/react-fontawesome": "^0.1.7",
"apexcharts": "^3.10.1",
"react-apexcharts": "^1.3.3",
"redux": "^4.0.5",
"react-redux": "^7.1.3"
"react-redux": "^7.1.3",
"react-spring": "^8.0.27",
"react-svg": "^11.0.9"
},
"devDependencies": {
"apexcharts": "^3.10.1",
Expand Down
180 changes: 88 additions & 92 deletions src/components/RollspecificGoals/Planer/Planer.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,99 @@
import { faAngleDoubleUp } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React, { Component } from 'react';
import { ReactSVG } from 'react-svg';

import ReactSVG from 'react-svg';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faAngleDoubleUp, faAngleUp, faMinus, faAngleDoubleDown, faAngleDown } from '@fortawesome/free-solid-svg-icons'

import VerticalBar from "../Elements/VerticalBar";

import step_1 from './img/Infrastruktur_1.svg'
import step_2 from './img/Infrastruktur_2.svg'
import step_3 from './img/Infrastruktur_3.svg'
import step_4 from './img/Infrastruktur_4.svg'
import step_5 from './img/Infrastruktur_5.svg'

import roll_icon from '../../../icons/rolls/Planer.svg'
import roll_icon from '../../../icons/rolls/Planer.svg';
import VerticalBar from '../Elements/VerticalBar';
import step_1 from './img/Infrastruktur_1.svg';
import step_2 from './img/Infrastruktur_2.svg';
import step_3 from './img/Infrastruktur_3.svg';
import step_4 from './img/Infrastruktur_4.svg';
import step_5 from './img/Infrastruktur_5.svg';

class Planer extends React.Component {

constructor(props) {
super(props);

this.settings = {
title: "Test",

show_infographic: true,
show_progress: true,
show_flow: true
};

this.state = {
progress: 0,
steps: [
step_1,
step_2,
step_3,
step_4,
step_5
],
step_nr: 0,
}

constructor(props) {
super(props);

this.settings = {
title: "Test",

show_infographic: true,
show_progress: true,
show_flow: true
};

this.state = {
progress: 0,
steps: [
step_1,
step_2,
step_3,
step_4,
step_5
],
step_nr: 0,
}

componentDidMount() {
setInterval(() => {
this.setState(prevState => ({
progress:
(prevState.progress + Math.floor(Math.random() * 1) + 1) % 100

}));

if (this.state.progress < 20) {
this.setState({step_nr: 0})
} else if (this.state.progress < 40) {
this.setState({step_nr: 1})
} else if (this.state.progress < 60) {
this.setState({step_nr: 2})
} else if (this.state.progress < 80) {
this.setState({step_nr: 3})
} else {
this.setState({step_nr: 4})
}
}, 100);


}


render(){
return (
<div className={`card card-planer step_${this.state.step_nr+1}`}>
<div className={"row card-header"}>
<div className={"roll-logo col-md-1"}>
<ReactSVG className={"roll-svg"} src={roll_icon} />
</div>
<div className={"roll-title col-md-10"}>
<h4>Infrastruktur</h4>
</div>
</div>

<div className={"row card-content"}>
<div className={"col goal-context col-md-10"}>
<img src={this.state.steps[this.state.step_nr]} className="App-logo" alt="logo" />
</div>

<div className={"col goal-chart col-md-2"}>
<div className={"goal-state-container"}>
<div className={"goal-flow"}>
<FontAwesomeIcon icon={ faAngleDoubleUp } />
</div>
<div className={"goal-stock"}>
<VerticalBar progress={this.state.progress} roll={"planer"}/>
</div>
</div>
</div>
</div>
}

componentDidMount() {
setInterval(() => {
this.setState(prevState => ({
progress:
(prevState.progress + Math.floor(Math.random() * 1) + 1) % 100

}));

if (this.state.progress < 20) {
this.setState({ step_nr: 0 })
} else if (this.state.progress < 40) {
this.setState({ step_nr: 1 })
} else if (this.state.progress < 60) {
this.setState({ step_nr: 2 })
} else if (this.state.progress < 80) {
this.setState({ step_nr: 3 })
} else {
this.setState({ step_nr: 4 })
}
}, 100);


}


render() {
return (
<div className={`card card-planer step_${this.state.step_nr + 1}`}>
<div className={"row card-header"}>
<div className={"roll-logo col-md-1"}>
<ReactSVG className={"roll-svg"} src={roll_icon} />
</div>
<div className={"roll-title col-md-10"}>
<h4>Infrastruktur</h4>
</div>
</div>

<div className={"row card-content"}>
<div className={"col goal-context col-md-10"}>
<img src={this.state.steps[this.state.step_nr]} className="App-logo" alt="logo" />
</div>

<div className={"col goal-chart col-md-2"}>
<div className={"goal-state-container"}>
<div className={"goal-flow"}>
<FontAwesomeIcon icon={faAngleDoubleUp} />
</div>
<div className={"goal-stock"}>
<VerticalBar progress={this.state.progress} roll={"planer"} />
</div>
</div>
)
}
</div>
</div>
</div>
)
}
}

export default Planer
1 change: 1 addition & 0 deletions src/icons/rolls/Energie.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/rolls/Industrie.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/rolls/Investor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/rolls/Nischenspieler.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/icons/rolls/Planer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/rolls/Politik.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/rolls/Population.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import GenericRolls from './components/Generic/GenericRolls/GenericRolls';
import GenericTimeseries from './components/Generic/GenericTimeseries/GenericTimeseries';
import GenericValue from './components/Generic/GenericValue/GenericValue';
import PieChart from './components/PieChart/PieChart';
import EnergyProvider from './components/RollspecificGoals/EnergyProvider/EnergyProvider';
import Industry from './components/RollspecificGoals/Industry/Industry';
import Planer from './components/RollspecificGoals/Planer/Planer';
import RollspecificGoals from './components/RollspecificGoals/RollspecificGoals';

export const ExampleComponent = ({ text }) => {
Expand All @@ -16,10 +19,13 @@ export const ExampleComponent = ({ text }) => {
export const visualComponentDict = {
donut_chart: DonutChart,
donut_chart_2: DonutChart2,
energy_provider: EnergyProvider,
generic_rolls: GenericRolls,
generic_timeseries: GenericTimeseries,
generic_value: GenericValue,
industry: Industry,
pie_chart: PieChart,
planer: Planer,
rollspecific_goals: RollspecificGoals,
carbon_budget: CarbonBudget
}

0 comments on commit 047cb82

Please sign in to comment.