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

feat(tickertape): implement ticker tape model and functionality #687

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nick-popovic
Copy link

@nick-popovic nick-popovic commented Dec 11, 2024

Ticker Tape Model in Bubble Tea

Overview

The tickertape.Model is used in a Bubble Tea application to create a scrolling ticker tape effect. Here's a summary of its usage:

Initialization

  • The Model struct is initialized with text, position, and ticker width.
  • The Init method starts the ticking process by returning a command that triggers periodic updates.

Updating

  • The Update method handles incoming messages:
    • WindowSizeMsg updates the ticker width.
    • tickMsg updates the position of the ticker tape and schedules the next tick.
  • The UpdateText method allows updating the text of the ticker tape.
  • The UpdateWidth method allows updating the width of the ticker tape.

Rendering

  • The View method generates the current view of the ticker tape based on the position and width.

Integration

  • In the main application model, an instance of tickertape.Model is created and managed.
  • The main model's Update method delegates relevant messages to the ticker tape model's Update method.
  • The main model's View method includes the ticker tape's view.
  • To use this model inside the parent/main model, you need to update you parent/main model's Init method. Example can be found here https://gist.github.com/nick-popovic/2f2dd4f94f5daff52b54edbbcd41164a

Example

demo

This setup allows the ticker tape to scroll text across the screen, updating its position at regular intervals.

@meowgorithm meowgorithm added the enhancement New feature or request label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants