Skip to content

Commit

Permalink
🔨 Fix name and add icon in more info
Browse files Browse the repository at this point in the history
Fixes #251
  • Loading branch information
timmo001 committed Mar 30, 2019
1 parent 747bac5 commit 10b8938
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion src/Components/Cards/Hass/Dialogs/MoreInfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import withMobileDialog from '@material-ui/core/withMobileDialog';
import Dialog from '@material-ui/core/Dialog';
Expand Down Expand Up @@ -63,6 +64,8 @@ class MoreInfo extends React.PureComponent {
const { fullScreen, data, handleChange } = this.props;
const { entity_id, attributes } = data;
const domain = entity_id.substring(0, entity_id.indexOf('.'));
const name = data.name ? data.name : attributes.friendly_name;
const icon = data.icon && data.icon;

return (
<Dialog
Expand All @@ -71,7 +74,16 @@ class MoreInfo extends React.PureComponent {
onClose={() => this.handleClose()}
aria-labelledby="responsive-dialog-title">
<DialogTitle id="responsive-dialog-title">
{attributes.friendly_name}
{icon && (
<span
className={classnames('mdi', `mdi-${icon}`)}
style={{
fontSize: data.size && data.size.icon && data.size.icon,
marginRight: 8
}}
/>
)}
{name}
<IconButton
style={{
position: 'absolute',
Expand Down
8 changes: 4 additions & 4 deletions src/Components/Cards/Hass/Hass.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class Hass extends React.PureComponent {
alarmEntity: undefined
};

handleButtonPress = (domain, entity) => {
handleButtonPress = (domain, entity, card) => {
if (domain === 'light' && entity.state === 'on')
this.buttonPressTimer = setTimeout(
() => this.setState({ moreInfo: entity }),
() => this.setState({ moreInfo: { ...entity, ...card } }),
1000
);
};
Expand Down Expand Up @@ -222,8 +222,8 @@ class Hass extends React.PureComponent {
else if (domain === 'alarm_control_panel')
this.handleAlarmPanelShow(entity);
}}
onTouchStart={() => this.handleButtonPress(domain, entity)}
onMouseDown={() => this.handleButtonPress(domain, entity)}
onTouchStart={() => this.handleButtonPress(domain, entity, card)}
onMouseDown={() => this.handleButtonPress(domain, entity, card)}
onTouchEnd={this.handleButtonRelease}
onMouseUp={this.handleButtonRelease}>
<Card
Expand Down

0 comments on commit 10b8938

Please sign in to comment.