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

Add optional "busy" slot to show activity #30

Merged
merged 17 commits into from
Jan 28, 2023
Merged

Add optional "busy" slot to show activity #30

merged 17 commits into from
Jan 28, 2023

Conversation

hopsoft
Copy link
Owner

@hopsoft hopsoft commented Jan 17, 2023

Adds an optional busy slot to toggle triggers and targets to show activity whenever a command roundtrips to the server.

Resolves #24

Depends on hopsoft/turbo_boost-streams#41

This PR adds the "busy" content feature. Busy content can be used to indicate activity to the user.

<%= tag.div id: dom_id(record) do %>
  <%= toggle_trigger_tag renders: current_partial_path, morphs: dom_id(record), 
    controls: dom_id(record, :example), locals: local_assigns do %>
    <%= toggle_busy_tag do %>
    Loading.... (only shown when busy)
    <% end %>
    <a>Toggle the Target</a>
  <% end %>

  <%= toggle_target_tag dom_id(record, :example) do %>
    This block is only executed if the target is "expanded."

    Toggled content...    
    <%= render "path/to/toggled/content" %>

    <%= toggle_busy_tag do %>
      Loading.... (only shown when busy if the target is expanded)
    <% end %>
  <% end %>
<% end %>

The following UX "best practices" are implicitly applied to the busy content.

  • Busy content is only shown if the remote toggle command takes longer than 100 milliseconds to return
  • Busy content remains visible for a minimum of 400 milliseconds

NOTE: Both the trigger and target can define busy content.

@hopsoft hopsoft marked this pull request as ready for review January 27, 2023 00:27
@hopsoft hopsoft changed the title Add busy slot to show activity Add optional "busy" slot to show activity Jan 28, 2023
@hopsoft hopsoft merged commit 5913e20 into main Jan 28, 2023
@hopsoft hopsoft deleted the hopsoft/activity branch January 28, 2023 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create activity slot for toggle triggers/targets that round trip for content
1 participant