mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 10:22:53 +00:00
working with sensor styling
This commit is contained in:
@@ -24,10 +24,6 @@
|
|||||||
display: block;
|
display: block;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
code,
|
|
||||||
pre {
|
|
||||||
white-space: pre-wrap;
|
|
||||||
}
|
|
||||||
.btn {
|
.btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ $transitionDuration: 0.4s;
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
border-radius: 0.5em;
|
border-radius: 0.5em;
|
||||||
|
margin-top: 0.5em;
|
||||||
}
|
}
|
||||||
h2 {
|
h2 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 0.5em;
|
|
||||||
}
|
}
|
||||||
a.toggler {
|
a.toggler {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ $backgroundColor: #FFFFFF;
|
|||||||
html {
|
html {
|
||||||
font-family: 'Roboto Slab', serif;
|
font-family: 'Roboto Slab', serif;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export default class Sidebar extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.onToggle = this.onToggle.bind(this);
|
this.onToggle = this.onToggle.bind(this);
|
||||||
|
this.toggleOff = this.toggleOff.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onToggle() {
|
onToggle() {
|
||||||
@@ -28,6 +29,14 @@ export default class Sidebar extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleOff(){
|
||||||
|
if(this.state.toggler !== ""){
|
||||||
|
this.setState({
|
||||||
|
toggler : ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div class={"Sidebar " + this.state.toggler}>
|
<div class={"Sidebar " + this.state.toggler}>
|
||||||
@@ -37,7 +46,7 @@ export default class Sidebar extends React.Component {
|
|||||||
aria-hidden="true" />
|
aria-hidden="true" />
|
||||||
</a>
|
</a>
|
||||||
<AboutMe/>
|
<AboutMe/>
|
||||||
{this.props.sensor.fetchedList ? <SensorList list={this.props.sensor.list}/> : null}
|
{this.props.sensor.fetchedList ? <SensorList list={this.props.sensor.list} toggleOff={this.toggleOff}/> : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,52 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import {browserHistory} from 'react-router';
|
||||||
import 'whatwg-fetch';
|
import 'whatwg-fetch';
|
||||||
|
|
||||||
import './SensorList.scss';
|
import './SensorList.scss';
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
month: 'numeric',
|
||||||
|
day: 'numeric',
|
||||||
|
year: 'numeric',
|
||||||
|
hour: 'numeric',
|
||||||
|
minute: 'numeric',
|
||||||
|
hour12: true
|
||||||
|
};
|
||||||
|
|
||||||
export default class SensorList extends React.Component {
|
export default class SensorList extends React.Component {
|
||||||
|
|
||||||
|
constructor(){
|
||||||
|
super();
|
||||||
|
this.openLink = this.openLink.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
openLink(){
|
||||||
|
browserHistory.push("/");
|
||||||
|
this.props.toggleOff();
|
||||||
|
}
|
||||||
|
|
||||||
insertSensorData = (sensor, index) => {
|
insertSensorData = (sensor, index) => {
|
||||||
const date = new Date(sensor.updated);
|
const date = new Date(sensor.updated);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={index} class="row">
|
<div key={index} class="row" onClick={this.openLink}>
|
||||||
<div class="item"><h1>{sensor.temperature}</h1><p>Connected</p></div>
|
<div class="item">
|
||||||
|
<h1>{sensor.temperature}°f</h1>
|
||||||
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<h3>{sensor.location}</h3>
|
<h3>{sensor.location}</h3>
|
||||||
<p>{date.toString()}</p>
|
<span class="date">Updated: {date.toLocaleString('en-us', options)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const list = this.props.list;
|
const list = this.props.list;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="SensorList">
|
<div class="SensorList">
|
||||||
<h2>Sensors</h2>
|
<h2>Sensors</h2>
|
||||||
<hr/>
|
|
||||||
{list.map(this.insertSensorData)}
|
{list.map(this.insertSensorData)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,9 +3,26 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-left: -1em;
|
||||||
|
margin-right: -1em;
|
||||||
|
padding: 1em;
|
||||||
|
|
||||||
|
&:hover{
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
.item + .item{
|
.item + .item{
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h2{
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.date{
|
||||||
|
font-size: .8em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user