๐ Hold to save button
Challenge #49
Context
As a member of the development team, you have to respond to a specific request from the UX designer, ๐ฉ๐ปโ๐จ Lucie, who has designed a button that must be held down for X amount of time to save a save request.
Sacha ๐ถ๐ผ the trainee has already integrated the design but doesnโt know how to perform the โholdableโ functionality.
So youโre going to take over from him.
Functional expectation
โAs a user, I would like to save something by holding down the button for a certain amount of time.โ
Here the prototype made by Lucie:
Acceptance Criteria
- We should be able to configure a maintenance duration in milliseconds.
- Pressing and holding the button triggers the countdown on the
mousedown
event. - On
mouseleave
ormouseup
events, the progress bar is reset to 0. - The progress bar representing the remaining relative time should reflect the remaining time.
- Simulates a backend request when the hold time is over (console log or alert).
- You must maximize the use of RxJS operators and be as declarative as possible.
Tips ๐คซ (if you really need it and after careful consideration)
- Create the `HoldableDirective`
- Use `TemplateRef` and `fromEvent` from RxJS to catch events or `@HostListener`
- Perhaps the following RxJS operators can help you: interval, takeUntil, switchMap, takeWhile/retry...