Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render Counting Timer in UI with Alpine.js #99

Closed
3 tasks done
nelsonic opened this issue Jul 11, 2022 · 5 comments
Closed
3 tasks done

Render Counting Timer in UI with Alpine.js #99

nelsonic opened this issue Jul 11, 2022 · 5 comments
Assignees
Labels
enhancement New feature or enhancement of existing functionality T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented Jul 11, 2022

Todo

Using: https://github.com/dwyl/learn-alpine.js/blob/main/stopwatch.html as inspiration ...

  • Render the timer element on the page using Alpine.js and use LiveView to sync between devices/clients
  • Should display hh:mm:ss and count up one second at a time.
  • Should use the Timer.start as the start time for the timer so that any new browsers/clients joining mid-way through a timer get the correct time.
@nelsonic nelsonic added enhancement New feature or enhancement of existing functionality technical A technical issue that requires understanding of the code, infrastructure or dependencies T1h Time Estimate 1 Hour labels Jul 11, 2022
@nelsonic
Copy link
Member Author

@SimonLab we discussed this on our call today.
My reasoning for using Alpine.js is to make the code in the app_live.html.heex template as declarative as possible:

https://github.com/dwyl/app-mvp-phoenix/blob/a4dc98e37c96f4886c140e0ecf5fca9b10c0fd53/lib/app_web/live/app_live.html.heex#L48-L69

The Server Side code doesn't need to know anything about the UI/UX of Timers.
The Server just knows the Timer.start and Timer.end data/values and the client can render them however it wants.

@nelsonic
Copy link
Member Author

This is working: #89 (comment) but is a total "hack".
The timer is disconnected from the start (i.e. the actual start time of the timer)

Will refactor it at the end of the PR. ⏳

@nelsonic
Copy link
Member Author

This is bugging me so I want to try and tackle it ... 🙄
Basically we want to have the timer in the UI using the Timer.start value.
and we want it to continue running when new items are added.

Going to try and figure this out. But it will definitely be a "hack" as I'm not a PETAL expert by any means.

@nelsonic
Copy link
Member Author

Instead of the "hack" I re-wrote the function and now we can have multiple timers running concurrently:

image

I'm still refactoring some bits but confident it will all be working as expected very soon. 🧑‍💻

@nelsonic nelsonic self-assigned this Jul 15, 2022
@nelsonic nelsonic added this to More ToDo ThanCanEver Be Done in Nelson's List via automation Jul 15, 2022
@nelsonic
Copy link
Member Author

Next: #103

Nelson's List automation moved this from More ToDo ThanCanEver Be Done to Done Jul 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement of existing functionality T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
Nelson's List
  
Done
Development

No branches or pull requests

1 participant