Skip to content

Commit

Permalink
Rendered printer stats component on button click
Browse files Browse the repository at this point in the history
  • Loading branch information
rjfc committed Nov 12, 2019
1 parent 840cba8 commit ff856a1
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 36 deletions.
26 changes: 20 additions & 6 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@
margin: auto;
}

.Home-header-text {
.Printer-stats-header {
width: 500px;
overflow: hidden;
position: relative;
margin: auto;
bottom: 25px;
}

.Header-text {
font-family: 'Lobster', cursive;
font-size: 12vmin;
background: -webkit-linear-gradient(#38ef7d, #11998e);
Expand All @@ -40,7 +48,7 @@
float:left;
}

.Home-header-logo {
.Header-logo {
float:left;
width: 230px;
}
Expand All @@ -57,11 +65,7 @@
border-radius: 3px;
position: relative;
top: 10vh;
}

.Home-button:hover:focus:active{
cursor: pointer;
background-color: #0b8a35;
}

.Home-printer-status {
Expand All @@ -81,4 +85,14 @@
left: 0;
width: 100%;
height: 100%;
}

.Printer-status-container {
background-color: #a3f0b8;
background-color: rgba(163, 240, 184, 0.87);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
7 changes: 4 additions & 3 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import './App.css';
import Home from './Home.js';
import PrinterStats from './PrinterStats.js';

class App extends Component {
state = {
Expand Down Expand Up @@ -49,9 +50,9 @@ class App extends Component {
<div className="App">
<Home button1Text = {"PRINTER STATISTICS"}
button2Text = {"SEARCH 3D MODELS"}
portStatus = {this.state.response}/>


portStatus = {this.state.response}>
<PrinterStats />
</Home>
{ /*<form onSubmit={this.handleSubmit}>
<input
Expand Down
57 changes: 30 additions & 27 deletions client/src/Home.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
import React, { Component } from 'react'
import Logo from './logo.png'
import LogoHeader from "./LogoHeader";
import LargeButton from "./LargeButton";
import PortStatus from "./PortStatus";
import PrinterStats from "./PrinterStats";

const PortStatusDisplay = props => {
const status = props.portStatus;
return (
<h2 className="Home-printer-status">PRINTER STATUS: {status}</h2>
)
};

const HomeHeader = () => {
return (
<div className="Home-header">
<img className="Home-header-logo" src={Logo} alt="Turtle logou"/>
<h1 className="Home-header-text">Turtle</h1>
</div>
)
};
class Home extends Component {
constructor(props){
super(props);

const HomeButton = props => {
const text = props.buttonText;
return (
<div className="Home-button">{text}</div>
)
};
this.state = {
printerStatsActive: false,
};

this.LoadPrinterStats = this.LoadPrinterStats.bind(this);
}

LoadPrinterStats() {
this.setState({ printerStatsActive: true });
}

class Home extends Component {
render() {
const { portStatus } = this.props;
const { button1Text } = this.props;
const { button2Text } = this.props;
if (this.state.printerStatsActive) {
return (
<div className="Printer-status-container">
<LogoHeader headerClass = {"Printer-stats-header"} />
<PrinterStats />
<PortStatus portStatus = { portStatus }/>
</div>
)
}
return (
<div className="Home-container">
<HomeHeader />
<HomeButton buttonText = { button1Text }/>
<LogoHeader headerClass = {"Home-header"} />
<LargeButton buttonText = { button1Text } clickEvent = { this.LoadPrinterStats }/>
<br/>
<HomeButton buttonText = { button2Text }/>
<PortStatusDisplay portStatus = { portStatus }/>

<LargeButton buttonText = { button2Text }/>
<PortStatus portStatus = { portStatus }/>
</div>
)
}
Expand Down
13 changes: 13 additions & 0 deletions client/src/LargeButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { Component } from 'react'

class LargeButton extends Component {
render() {
const { buttonText } = this.props;
const { clickEvent } = this.props;
return (
<div onClick = {clickEvent} className="Home-button">{buttonText}</div>
)
}
}

export default LargeButton
16 changes: 16 additions & 0 deletions client/src/LogoHeader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { Component } from 'react'
import Logo from "./logo.png";

class LogoHeader extends Component {
render() {
const { headerClass } = this.props;
return (
<div className = {headerClass}>
<img className="Header-logo" src={Logo} alt="Turtle logo"/>
<h1 className="Header-text">Turtle</h1>
</div>
)
}
}

export default LogoHeader
12 changes: 12 additions & 0 deletions client/src/PortStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React, { Component } from 'react'

class PortStatus extends Component {
render() {
const { portStatus } = this.props;
return (
<h2 className="Home-printer-status">PRINTER STATUS: {portStatus}</h2>
)
}
}

export default PortStatus
13 changes: 13 additions & 0 deletions client/src/PrinterStats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { Component } from 'react'

class PrinterStats extends Component {
render() {
return (
<div className="Printer-stats-container">

</div>
)
}
}

export default PrinterStats
Binary file modified client/src/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ff856a1

Please sign in to comment.