Skip to content

Commit

Permalink
Final touches before merge
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed May 15, 2024
1 parent da65e21 commit ce77bdb
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 31 deletions.
87 changes: 62 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,30 @@

## Table of Contents

- [Why TurboBoost Commands?](#why-turboboost-commands)
- [Sponsors](#sponsors)
- [Dependencies](#dependencies)
- [Setup](#setup)
- [Usage](#usage)
- [Event Delegates](#event-delegates)
- [Lifecycle Events](#lifecycle-events)
- [Targeting Frames](#targeting-frames)
- [Working with Forms](#working-with-forms)
- [Server Side Commands](#server-side-commands)
- [Appending Turbo Streams](#appending-turbo-streams)
- [Setting Instance Variables](#setting-instance-variables)
- [Prevent Controller Action](#prevent-controller-action)
- [Broadcasting Turbo Streams](#broadcasting-turbo-streams)
- [Community](#community)
- [Developing](#developing)
- [Notable Files](#notable-files)
- [Deploying](#deploying)
- [Notable Files](#notable-files-1)
- [How to Deploy](#how-to-deploy)
- [Releasing](#releasing)
- [About TurboBoost](#about-turboboost)
- [License](#license)
- [Why TurboBoost Commands?](#why-turboboost-commands)
- [Sponsors](#sponsors)
- [Dependencies](#dependencies)
- [Setup](#setup)
- [Usage](#usage)
- [Event Delegates](#event-delegates)
- [Lifecycle Events](#lifecycle-events)
- [Targeting Frames](#targeting-frames)
- [Working with Forms](#working-with-forms)
- [Server Side Commands](#server-side-commands)
- [Appending Turbo Streams](#appending-turbo-streams)
- [Setting Instance Variables](#setting-instance-variables)
- [Prevent Controller Action](#prevent-controller-action)
- [Broadcasting Turbo Streams](#broadcasting-turbo-streams)
- [Tracking Page State](#tracking-page-state)
- [Community](#community)
- [Developing](#developing)
- [Notable Files](#notable-files)
- [Deploying](#deploying)
- [Notable Files](#notable-files-1)
- [How to Deploy](#how-to-deploy)
- [Releasing](#releasing)
- [About TurboBoost](#about-turboboost)
- [License](#license)

<!-- Tocer[finish]: Auto-generated, don't remove. -->

Expand Down Expand Up @@ -381,7 +382,8 @@ end

_This proves especially powerful when paired with [TurboBoost Streams](https://github.com/hopsoft/turbo_boost-streams)._

> 📘 **NOTE:** `turbo_stream.invoke` is a [TurboBoost Streams](https://github.com/hopsoft/turbo_boost-streams#usage) feature.
> [!NOTE]
> `turbo_stream.invoke` is a [TurboBoost Streams](https://github.com/hopsoft/turbo_boost-streams#usage) feature.
### Setting Instance Variables

Expand Down Expand Up @@ -476,7 +478,42 @@ end
_Learn more about Turbo Stream broadcasting by reading through the
[hotwired/turbo-rails](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb) source code._

> 📘 **NOTE:** `broadcast_invoke_later_to` is a [TurboBoost Streams](https://github.com/hopsoft/turbo_boost-streams#broadcasting) feature.
> [!NOTE]
> `broadcast_invoke_later_to` is a [TurboBoost Streams](https://github.com/hopsoft/turbo_boost-streams#broadcasting) feature.
### Tracking Page State

You can opt-in to remember transient page state when using Rails tag helpers with `turbo_boost[:remember]` to track
element attribute values between requests.

```erb
<%= tag.details id: "page-state-example", turbo_boost: { remember: [:open] } do %>
<summary>Page State Example</summary>
Content...
<% end %>
```

The code above will be expanded to this HTML.

```html
<details id="form_driver" data-turbo-boost-state-attributes="['open']">
<summary>Page State Example</summary>
Content...
</details>
```

Several things happen when you use `turbo_boost[:remember]` to track page state.

1. A command is dispatched whenever the value of a registered attribute changes.
1. The server updates tracked state and notifies the client.
1. Subsequent requests forward the current state to the server with each request.
1. Server side rendering reflects the current page state.
1. After a DOM update, the client verifies the page state and will restore attribute values _(if necessary)_.

This feature works with all attributes, including aria, data, and custom attributes.

> [!WARNING]
> Elements must have an `id` assigned to participate in page state tracking.
## Community

Expand Down
2 changes: 1 addition & 1 deletion bin/docker/run/local
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fi
# ============================================================================================================
npm install
if [ ! -f "/mnt/external/.playwright" ]; then
npx playwright@latest install chromium --with-deps
yes | npx playwright@latest install chromium --with-deps
touch /mnt/external/.playwright
fi
bundle install
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/app/assets/builds/tailwind.css

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions test/dummy/config/importmap.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# frozen_string_literal: true

# Pin npm packages by running ./bin/importmap

pin "@hotwired/stimulus", to: "@hotwired--stimulus.js" # @3.2.2
pin "@hotwired/turbo", to: "@hotwired--turbo.js" # @8.0.4
pin "@hotwired/turbo-rails", to: "@hotwired--turbo-rails.js" # @8.0.4
pin "@rails/actioncable", to: "@rails--actioncable.js" # @7.1.3
pin "@rails/actioncable/src", to: "@rails--actioncable--src.js" # @7.1.3
pin "@turbo-boost/streams", to: "@turbo-boost--streams.js" # @0.1.11

# NOTE: The following libs stop working if we allow Rails to vendor them
Expand All @@ -18,4 +17,3 @@
pin "@turbo-boost/commands", to: "@turbo-boost/commands.js"

pin "application", preload: true
pin "@rails/actioncable/src", to: "@rails--actioncable--src.js" # @7.1.3
2 changes: 1 addition & 1 deletion turbo_boost-commands.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rouge"
s.add_development_dependency "runfile"
s.add_development_dependency "sprockets-rails"
s.add_development_dependency "sqlite3"
s.add_development_dependency "sqlite3", "~> 1.4"
s.add_development_dependency "standardrb"
s.add_development_dependency "tailwindcss-rails"
s.add_development_dependency "webdrivers"
Expand Down

0 comments on commit ce77bdb

Please sign in to comment.