Skip to content

Commit

Permalink
Enabled edit button for progress bar (#578)
Browse files Browse the repository at this point in the history
Co-authored-by: Shubham Sharma <[email protected]>
  • Loading branch information
skv93-coder and Shubham Sharma authored Feb 20, 2024
1 parent f6fede8 commit b6aac58
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
29 changes: 2 additions & 27 deletions app/components/progress-bar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,15 @@
step='10'
{{on 'change' this.onChange}}
{{on 'input' this.onInput}}
disabled={{not this.isEditable}}
/>
<button
data-test-progress-bar-button
{{on 'click' this.turnEditModeOn}}
class='progress-slider__button
{{unless this.isEditable "progress-slider__button--hover"}}'
type='button'
>
{{#if this.isEditable}}
<span class='progress-slider__button__text'>{{@value}}</span>
{{else}}
<svg
class='progress-slider__button__edit-icon'
viewBox='0 0 24 24'
fill='none'
xmlns='http://www.w3.org/2000/svg'
>
<path
class='progress-slider__button__edit-icon__inner'
opacity='0.5'
d='M4 20H8L18 10L14 6L4 16V20Z'
fill='#000000'
/>
<path
class='progress-slider__button__edit-icon__outer'
d='M18 10L21 7L17 3L14 6M18 10L8 20H4V16L14 6M18 10L14 6'
stroke='#000000'
stroke-width='1.5'
stroke-linecap='round'
stroke-linejoin='round'
/>
</svg>
{{/if}}
<span class='progress-slider__button__text'>{{@value}}</span>

</button>

</div>
21 changes: 0 additions & 21 deletions app/components/progress-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,16 @@ import { action } from '@ember/object';
import { debounce } from '@ember/runloop';

export default class ProgressBarComponent extends Component {
@tracked isEditable = false;
@tracked value = this.args.value;
lastEditTime = null;

@action turnEditModeOn() {
this.isEditable = true;
this.lastEditTime = Date.now();
this.setEditableToFalse();
}

setEditableToFalse() {
setTimeout(() => {
const timeDelta = Date.now() - this.lastEditTime;
if (this.isEditable && timeDelta >= 5000) {
this.isEditable = false;
} else if (this.isEditable) {
this.setEditableToFalse();
}
}, 5000);
}

@action onInput(e) {
this.lastEditTime = Date.now();
this.value = e.target.value;
if (this.args.onInput) {
this.args.onInput(this.value);
}
}

@action onChange(e) {
this.lastEditTime = Date.now();
if (this.args.onChange) {
debounce(this, this.debouncedChange, e, 600);
}
Expand Down

0 comments on commit b6aac58

Please sign in to comment.