-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented button sensor capability component.
- Loading branch information
1 parent
e2c1a86
commit b5666d2
Showing
7 changed files
with
88 additions
and
6 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
gfx/css/components/capabilities/button-sensor-capability-component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.button-sensor-capability-component { | ||
.button-status-wrap { | ||
padding: 20px 0; | ||
margin: -15px; | ||
text-align: center; | ||
|
||
&.is-button-active { | ||
background-color: #DFD; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
views/components/capabilities/ButtonSensorCapabilityComponent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import classNames from 'classnames'; | ||
|
||
import CircularProgress from 'material-ui/CircularProgress'; | ||
|
||
import AbstractPlatform from '../../../src/AbstractPlatform'; | ||
|
||
class ButtonSensorCapabilityComponent extends Component { | ||
|
||
static propTypes = { | ||
capability: PropTypes.object.isRequired, | ||
deviceInfo: PropTypes.object.isRequired, | ||
measurements: PropTypes.array.isRequired, | ||
}; | ||
|
||
static getType() { | ||
return AbstractPlatform.CapabilityType.BUTTON; | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="capability-component button-sensor-capability-component"> | ||
{this.renderContents()} | ||
</div> | ||
); | ||
} | ||
|
||
renderContents() { | ||
const { | ||
measurements, | ||
} = this.props; | ||
|
||
const measurement = measurements.find( | ||
(item) => item.type === AbstractPlatform.MeasurementType.BUTTON | ||
) || null; | ||
|
||
if (!measurement) { | ||
return ( | ||
<div className="loader-wrap"> | ||
<CircularProgress /> | ||
</div> | ||
); | ||
} | ||
|
||
const isButtonActive = measurement.info.state.value === 1; | ||
|
||
const className = classNames( | ||
'button-status-wrap', { | ||
'is-button-active': isButtonActive, | ||
} | ||
); | ||
|
||
return ( | ||
<div className={className}> | ||
{isButtonActive ? 'Button pressed' : 'Button released'} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
state => ({ | ||
}), { | ||
} | ||
)(ButtonSensorCapabilityComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters