ultimate_turbo_modal 1.0.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 896c6379f97064006b57fbb612cab3c16560af307d2271da0c488785dfc366db
4
- data.tar.gz: aa78d481f27597261e57ca07c0b80f0fc681529e63d92df803347a18c4c1b9da
3
+ metadata.gz: a9827e4a255b0b49e9ca3454c396e0ca2c043041705058562cd097ee55ded670
4
+ data.tar.gz: 0df6f286051741524dce4ebaa9602cd7b1e37b082960bc2886495c4a93b2286c
5
5
  SHA512:
6
- metadata.gz: 260a1fddf247e51ed411f0ae83d85faa2d581f18c8ef71664129b11ad1e7480c6be9da04f7e86321999c0ad9098643a23cb83480b39f79f847ee59939a47098f
7
- data.tar.gz: 102593d43c1b8a94ca85787d53a2f8a8064fd3d17fdec96e382c2f6795baffa599d8478fcd759c85b23d694f091e643e76e6516d1fa8c1d3911487e43f0738f8
6
+ metadata.gz: 0f3f52eb646666e9088b89696f9689ed17b2bf69abe1ea2e7225d0e4e625ecc28d9ae05b391ae640ca096d43b8afd88479278324b84d2515583d303539fb4c89
7
+ data.tar.gz: be333d50d9e831bf94c60e382fd5b0e7ecad5dcfcc7b73236a103aae8a0356179bd52d38a8400a04ed036a81e195115e091a6bfe448c3214e1331d6f4a11c13f
data/README.md CHANGED
@@ -51,7 +51,7 @@ A demo application can be found at https://github.com/cmer/ultimate_turbo_modal-
51
51
 
52
52
  - or -
53
53
 
54
- $ bin/rails importmaps pin ultimate_turbo_modal
54
+ $ bin/importmap pin ultimate_turbo_modal
55
55
 
56
56
  3. Add the following as the first element in the `body` tag of `views/layouts/application.html.erb`:
57
57
 
@@ -110,35 +110,42 @@ Adds padding inside the modal.
110
110
 
111
111
  Shows or hide a close button (X) at the top right of the modal.
112
112
 
113
- ### `advance_history`, default: `true`
113
+ ### `advance`, default: `true`
114
114
 
115
115
  When opening the modal, the URL in the URL bar will change to the URL of the view being shown in the modal. The Back button dismisses the modal and navigates back.
116
116
 
117
- ### `advance_history_url`, default: `nil`
118
-
119
- Override for the URL being shown in the URL bar when `advance_history` is enabled. Default is the actual URL.
117
+ If a URL is specified as a String, the browser history will advance, and the URL shown in the URL bad will be replaced by the URL specified.
120
118
 
121
119
 
122
120
  ### Example usage with options
123
121
 
124
122
  ```erb
125
- <%= modal(padding: true, close_button: false, advance_history_url: "/foo/bar") do %>
123
+ <%= modal(padding: true, close_button: false, advance: false) do %>
124
+ Hello World!
125
+ <% end %>
126
+ ```
127
+
128
+ ```erb
129
+ <%= modal(padding: true, close_button: false, advance: "/foo/bar") do %>
126
130
  Hello World!
127
131
  <% end %>
128
132
  ```
129
133
 
130
134
  ## Installing & Configuring Idiomorph
131
135
 
132
- // Morph Turbo Frame rendering to allow navigation within Turbo Frames
133
- // without having to teardown the entire frame. This is needed to prevent
134
- // the leaving and entering animations from repeating when navigating
135
- // within the modal. You could optionally not use the code below if you
136
- // do not intend to allow navigation within the modal.
137
- //
138
- // Note that Turbo 8 will include Idiomorph by default.
139
- //
140
- // In the meantime, add `<script src="https://unpkg.com/idiomorph"></script>`
141
- // to your HTML <head>.
136
+ Idiomorph can morph Turbo Frame responses to allow seemless navigation within Turbo Frames
137
+ without having to hide and reopen the modal. This is needed to prevent
138
+ the fade out / fade in animations from repeating when navigating within the modal.
139
+
140
+ You could optionally not use the code below if you do not intend to allow navigation within the modal.
141
+
142
+ Note that Turbo 8 will include Idiomorph by default.
143
+
144
+ In the meantime, add `<script src="https://unpkg.com/idiomorph"></script>` to your HTML <head>.
145
+
146
+ And the following code to `application.js`:
147
+
148
+ ```js
142
149
  addEventListener("turbo:before-frame-render", (event) => {
143
150
  event.detail.render = (currentElement, newElement) => {
144
151
  Idiomorph.morph(currentElement, newElement, {
@@ -146,6 +153,7 @@ addEventListener("turbo:before-frame-render", (event) => {
146
153
  })
147
154
  }
148
155
  })
156
+ ```
149
157
 
150
158
 
151
159
  &nbsp;
@@ -9,14 +9,14 @@ class UltimateTurboModal::Base < Phlex::HTML
9
9
 
10
10
  # @param padding [Boolean] Whether to add padding around the modal content
11
11
  # @param close_button [Boolean] Whether to show a close button.
12
- # @param advance_history [Boolean] Whether to update the browser history when opening and closing the modal
13
- # @param advance_history_url [String] Override the URL to use when advancing the history
12
+ # @param advance [Boolean] Whether to update the browser history when opening and closing the modal
13
+ # @param advance_url [String] Override the URL to use when advancing the history
14
14
  # @param request [ActionDispatch::Request] The current Rails request object
15
- def initialize(padding: true, close_button: true, advance_history: true, advance_history_url: nil, request: nil)
15
+ def initialize(padding: true, close_button: true, advance: true, request: nil)
16
16
  @padding = padding
17
17
  @close_button = close_button
18
- @advance_history = advance_history
19
- @advance_history_url = advance_history_url
18
+ @advance = advance
19
+ @advance_url = advance if advance && advance.is_a?(String)
20
20
  @request = request
21
21
 
22
22
  self.class.include Turbo::FramesHelper
@@ -46,8 +46,8 @@ class UltimateTurboModal::Base < Phlex::HTML
46
46
  !!@padding
47
47
  end
48
48
 
49
- def advance_history?
50
- !!@advance_history
49
+ def advance?
50
+ !!@advance
51
51
  end
52
52
 
53
53
  def close_button?
@@ -66,9 +66,9 @@ class UltimateTurboModal::Base < Phlex::HTML
66
66
  turbo_stream? || turbo_frame?
67
67
  end
68
68
 
69
- def advance_history_url
70
- return nil unless advance_history?
71
- @advance_history_url || request.original_url
69
+ def advance_url
70
+ return nil unless advance?
71
+ @advance_url || request.original_url
72
72
  end
73
73
 
74
74
  def method_missing(method, *, &block)
@@ -27,7 +27,7 @@ module UltimateTurboModal::Flavors
27
27
  data: {
28
28
  controller: "modal",
29
29
  modal_target: "container",
30
- modal_advance_history_url_value: advance_history_url,
30
+ modal_advance_url_value: advance_url,
31
31
  action: "turbo:submit-end->modal#submitEnd keyup@window->modal#closeWithKeyboard click@window->modal#outsideModalClicked click->modal#outsideModalClicked",
32
32
  transition_enter: "ease-out duration-300",
33
33
  transition_enter_start: "opacity-0",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UltimateTurboModal
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultimate_turbo_modal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Mercier