1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 18:32:50 +00:00

working with sensor styling

This commit is contained in:
2016-09-08 13:34:01 +00:00
parent fc6af3cd4e
commit cb28f25b97
6 changed files with 56 additions and 13 deletions

View File

@@ -1,30 +1,52 @@
import React from 'react';
import {browserHistory} from 'react-router';
import 'whatwg-fetch';
import './SensorList.scss';
export default class SensorList extends React.Component {
const options = {
month: 'numeric',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
hour12: true
};
export default class SensorList extends React.Component {
constructor(){
super();
this.openLink = this.openLink.bind(this);
}
openLink(){
browserHistory.push("/");
this.props.toggleOff();
}
insertSensorData = (sensor, index) => {
const date = new Date(sensor.updated);
return (
<div key={index} class="row">
<div class="item"><h1>{sensor.temperature}</h1><p>Connected</p></div>
<div key={index} class="row" onClick={this.openLink}>
<div class="item">
<h1>{sensor.temperature}°f</h1>
</div>
<div class="item">
<h3>{sensor.location}</h3>
<p>{date.toString()}</p>
<span class="date">Updated: {date.toLocaleString('en-us', options)}</span>
</div>
</div>
);
}
render() {
const list = this.props.list;
return (
<div class="SensorList">
<h2>Sensors</h2>
<hr/>
{list.map(this.insertSensorData)}
</div>
)

View File

@@ -3,9 +3,26 @@
display: flex;
flex-direction: row;
align-items: center;
cursor: pointer;
margin-left: -1em;
margin-right: -1em;
padding: 1em;
&:hover{
background-color: gray;
}
.item + .item{
margin-left: 1em;
}
h2{
margin-bottom: 0;
}
.date{
font-size: .8em;
}
}
}