-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scene: Add shutter value selector to control device action (#2085)
- Loading branch information
1 parent
10287b5
commit 09a7987
Showing
6 changed files
with
111 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Component } from 'preact'; | ||
import { Text } from 'preact-i18n'; | ||
import cx from 'classnames'; | ||
|
||
import { COVER_STATE } from '../../../../server/utils/constants'; | ||
|
||
class ShutterButtons extends Component { | ||
open = () => { | ||
this.props.updateValue(COVER_STATE.OPEN); | ||
}; | ||
|
||
close = () => { | ||
this.props.updateValue(COVER_STATE.CLOSE); | ||
}; | ||
|
||
stop = () => { | ||
this.props.updateValue(COVER_STATE.STOP); | ||
}; | ||
|
||
render({ value, category, type, isLive = false }, {}) { | ||
return ( | ||
<div class="btn-group" role="group"> | ||
<button | ||
class={cx('btn btn-sm btn-secondary', { | ||
active: value === COVER_STATE.OPEN | ||
})} | ||
onClick={this.open} | ||
> | ||
{value === COVER_STATE.OPEN && isLive ? ( | ||
<Text id={`deviceFeatureAction.category.${category}.stateLiveFinished`} plural={COVER_STATE.OPEN} /> | ||
) : ( | ||
<Text id={`deviceFeatureAction.category.${category}.${type}`} plural={COVER_STATE.OPEN} /> | ||
)} | ||
</button> | ||
<button | ||
class={cx('btn btn-sm btn-secondary', 'fe', 'fe-pause', { | ||
active: value === COVER_STATE.STOP | ||
})} | ||
onClick={this.stop} | ||
/> | ||
<button | ||
class={cx('btn btn-sm', 'btn-secondary', { | ||
active: value === COVER_STATE.CLOSE | ||
})} | ||
onClick={this.close} | ||
> | ||
{value === COVER_STATE.CLOSE && isLive ? ( | ||
<Text id={`deviceFeatureAction.category.${category}.stateLiveFinished`} plural={COVER_STATE.CLOSE} /> | ||
) : ( | ||
<Text id={`deviceFeatureAction.category.${category}.${type}`} plural={COVER_STATE.CLOSE} /> | ||
)} | ||
</button> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default ShutterButtons; |
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
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