npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@turbo-boost/elements

v0.1.0

Published

Pre-built easy to use reactive TurboBoost elements for Rails/Hotwire apps.

Downloads

170

Readme

Pre-built easy to use reactive TurboBoost elements for Rails/Hotwire apps.

Table of Contents

Sponsors

Dependencies

Setup

Add TurboBoost Elements dependencies

# Gemfile
gem "turbo-rails", ">= 1.1", "< 2"
+gem "turbo_boost-elements", "~> VERSION"
# package.json
"dependencies": {
  "@hotwired/turbo-rails": ">=7.2",
+  "@turbo-boost/elements": "^VERSION"
# app/javascript/application.js
import '@hotwired/turbo-rails'
+import '@turbo-boost/elements'

Add TurboBoost to your Rails app

# app/views/layouts/application.html.erb
<html>
  <head>
+  <%= turbo_boost.meta_tag %>
  </head>
  <body>
  </body>
</html>

Elements

<toggle-trigger> and <toggle-target>

Toggle content via conditional rendering.

This example will re-render the post partial and toggle the form section.

<!-- app/views/posts/_post.html.erb -->
<%= tag.div id: dom_id(post) do %>
  <!-- content -->

  <%= toggle_trigger_tag renders: current_partial_path, morphs: dom_id(post),
    controls: dom_id(post, :form), locals: local_assigns, assigns: { post: @post } do %>
    <% if toggle_target_collapsed?  dom_id(post, :form) %>
      <%= link_to "Edit Post Inline", request.path %>
    <% else %>
      <%= link_to "Cancel Editing Post", request.path %>
    <% end %>
  <% end %>

  <%= toggle_target_tag dom_id(post, :form) do %>
    <%= render "posts/form", post: post %>
  <% end %>

  <!-- content -->
<% end %>

Tag Helpers

  • toggle_trigger_tag

    • renders - REQUIRED, the partial path to render
    • morphs - REQUIRED, dom_id of the partial's outermost containing element
    • controls - REQUIRED, dom_id of the toggle target
    • assigns - {}, assigns required to render the partial (i.e. instance variables)
    • locals - {}, local_assigns required to render the parital
    • collapse_selector - nil, CSS selector for other matching targets to collapse when the target is expanded
    • focus_selector - nil, CSS selector for the element to focus when the target is expanded
    • method - :toggle, method to inovke (:show, :hide, :toggle)
    • disabled - false, disable the trigger
    • remember - false, remember ephemeral UI state between requests
    • kwargs - generic support for additional element attributes like class etc.
    • &block - a Ruby block that emits this trigger's content
  • toggle_target_tag

    • id - REQUIRED, the dom_id for the element
    • collapse_on - [], list of events that will collapse this target
    • collapse_selector - nil, CSS selector for other matching targets to collapse when this target is expanded
    • expanded - false, override to force expansion
    • focus_selector - nil, CSS selector for the element to focus when this target is expanded
    • kwargs - generic support for additional element attributes like class etc.
    • &block - a Ruby block that emits this target's content

If a named keyword argument is shared by both the trigger and target, the trigger value will take precendence because multiple triggers might control the same target.

DevTools

TurboBoost ships with client/browser based devtools designed to improve the developer experience. You can enable the devtools with JavaScript like so.

TurboBoost.devtools.start()

Introductory Video

Watch the introduction on YouTube

Releasing

  1. Run npm install and bundle to pick up the latest
  2. Update the version number consistently in the following files:
    • lib/turbo_boost/elements/version.rb - pre-release versions should use .preN
    • app/javascript/version.js - pre-release versions use -preN
    • package.json - pre-release versions use -preN
  3. Run bin/standardize
  4. Run rake build and npm run build
  5. Commit and push changes to GitHub
  6. Run rake release
  7. Run npm publish --access public
  8. Commit and push changes to GitHub
  9. Create a new release on GitHub (here) and generate the changelog for the stable release for it

License

The gem is available as open source under the terms of the MIT License.