From 6ee5492d2b8cdd4637b1a7793b527215cfb3c8fe Mon Sep 17 00:00:00 2001 From: Tnks2U Date: Mon, 25 Nov 2024 15:15:28 +0900 Subject: [PATCH 1/3] =?UTF-8?q?lint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ledPicker/ledPicker.jsx | 15 ++++++++------- src/components/ledPicker/ledPickerContainer.jsx | 7 +------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/components/ledPicker/ledPicker.jsx b/src/components/ledPicker/ledPicker.jsx index 1936687d..d59f0109 100644 --- a/src/components/ledPicker/ledPicker.jsx +++ b/src/components/ledPicker/ledPicker.jsx @@ -243,15 +243,15 @@ class LedPicker extends Component { {ledStatus.map((leds, x) => leds.map((led, y) => { const brightness = ledStatus[x][y]; - const targetStyle = this.theme[ - `led_item_selected_${brightness}` - ]; + const targetStyle = + this.theme[`led_item_selected_${brightness}`]; const key = `led${x}${y}`; return (
0 && - this.theme.led_item_selected} ${targetStyle}`} + className={`${this.theme.led_item} ${ + brightness > 0 && this.theme.led_item_selected + } ${targetStyle}`} key={key} onClick={() => { this._handleLedStatusChange({ @@ -276,8 +276,9 @@ class LedPicker extends Component { const brightness = ledStatus[x][y]; return (
0 && - this.theme.led_item_selected}`} + className={`${this.theme.led_item} ${ + brightness > 0 && this.theme.led_item_selected + }`} key={`led${x}${y}`} onClick={() => this._handleLedStatusChange({ diff --git a/src/components/ledPicker/ledPickerContainer.jsx b/src/components/ledPicker/ledPickerContainer.jsx index f8ef3d26..0b72f94d 100644 --- a/src/components/ledPicker/ledPickerContainer.jsx +++ b/src/components/ledPicker/ledPickerContainer.jsx @@ -20,11 +20,6 @@ const mapDispatchToProps = (dispatch) => ({ export default withWrapper({ type: 'microBitLedPicker', -})( - connect( - undefined, - mapDispatchToProps - )(LedPickerContainer) -); +})(connect(undefined, mapDispatchToProps)(LedPickerContainer)); // mapStateToProps, // mapDispatchToProps From 623a5eac9195c90f72882972e2fd2684926d0ee6 Mon Sep 17 00:00:00 2001 From: Tnks2U Date: Mon, 25 Nov 2024 15:16:07 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20ledpicker=20=ED=81=B4=EB=A6=AD?= =?UTF-8?q?=EC=8B=9C=20=EB=B0=9D=EA=B8=B0=EC=88=9C=EC=84=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ledPicker/ledPicker.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/ledPicker/ledPicker.jsx b/src/components/ledPicker/ledPicker.jsx index d59f0109..bf709c70 100644 --- a/src/components/ledPicker/ledPicker.jsx +++ b/src/components/ledPicker/ledPicker.jsx @@ -178,9 +178,9 @@ class LedPicker extends Component { } } else { if (withLevel) { - status[x][y] += 1; - if (status[x][y] > 9) { - status[x][y] = 0; + status[x][y] -= 1; + if (status[x][y] < 0) { + status[x][y] = 9; } } else { if (status[x][y] == targetBrightness) { From b940d155d31a95238bf40c5c22b28f486a05a66c Mon Sep 17 00:00:00 2001 From: Tnks2U Date: Tue, 26 Nov 2024 17:27:35 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20ledpicker=20longPress=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ledPicker/ledPicker.jsx | 44 +++++++++++++++++++------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/components/ledPicker/ledPicker.jsx b/src/components/ledPicker/ledPicker.jsx index bf709c70..6ad20d85 100644 --- a/src/components/ledPicker/ledPicker.jsx +++ b/src/components/ledPicker/ledPicker.jsx @@ -5,7 +5,9 @@ import { debounce } from 'lodash'; import root from 'window-or-global'; import produce from 'immer'; import Theme from '@utils/Theme'; -import Dropdown from '@components/widget/dropdown'; + +let timer = null; +let islongPress = false; class LedPicker extends Component { get PICKER_WIDTH() { @@ -166,7 +168,7 @@ class LedPicker extends Component { }, }; } - _handleLedStatusChange = ({ x, y, isReset, value }) => { + _handleLedStatusChange = ({ x, y, isReset, resetOne }) => { const { onChangeLedPicker, withLevel, maxBrightness } = this.props; const status = this.state.ledStatus; const targetBrightness = maxBrightness || 1; @@ -178,9 +180,13 @@ class LedPicker extends Component { } } else { if (withLevel) { - status[x][y] -= 1; - if (status[x][y] < 0) { - status[x][y] = 9; + if (resetOne) { + status[x][y] = 0; + } else { + status[x][y] -= 1; + if (status[x][y] < 0) { + status[x][y] = 9; + } } } else { if (status[x][y] == targetBrightness) { @@ -201,6 +207,25 @@ class LedPicker extends Component { ); }; + _handleMouseDown = (x, y) => (e) => { + timer = setTimeout(() => { + this._handleLedStatusChange({ x, y, isReset: false, resetOne: true }); + islongPress = true; + }, 500); + }; + + _handleMouseUp = (x, y) => (e) => { + if (timer) { + clearTimeout(timer); + timer = null; + } + if (islongPress) { + islongPress = false; + } else { + this._handleLedStatusChange({ x, y, isReset: false }); + } + }; + render() { const { className, @@ -253,13 +278,8 @@ class LedPicker extends Component { brightness > 0 && this.theme.led_item_selected } ${targetStyle}`} key={key} - onClick={() => { - this._handleLedStatusChange({ - x, - y, - isReset: false, - }); - }} + onMouseDown={this._handleMouseDown(x, y)} + onMouseUp={this._handleMouseUp(x, y)} >
{brightness}