ultimate_turbo_modal 2.1.2 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.tool-versions +1 -1
- data/CHANGELOG.md +11 -0
- data/CLAUDE.md +188 -2
- data/Gemfile.lock +1 -1
- data/README.md +22 -0
- data/VERSION +1 -1
- data/javascript/index.js +12 -3
- data/javascript/modal_controller.js +11 -3
- data/javascript/package.json +2 -1
- data/javascript/styles/vanilla.css +86 -0
- data/lib/generators/ultimate_turbo_modal/templates/flavors/custom.rb +29 -2
- data/lib/generators/ultimate_turbo_modal/templates/flavors/tailwind.rb +30 -3
- data/lib/generators/ultimate_turbo_modal/templates/flavors/tailwind3.rb +29 -2
- data/lib/generators/ultimate_turbo_modal/templates/flavors/vanilla.rb +31 -3
- data/lib/generators/ultimate_turbo_modal/update_generator.rb +97 -0
- data/lib/ultimate_turbo_modal/base.rb +34 -13
- data/lib/ultimate_turbo_modal.rb +1 -0
- data/script/build_and_release.sh +20 -7
- metadata +7 -99
- data/demo-app/.gitattributes +0 -7
- data/demo-app/.gitignore +0 -34
- data/demo-app/.ruby-version +0 -1
- data/demo-app/.tool-versions +0 -2
- data/demo-app/Gemfile +0 -41
- data/demo-app/Gemfile.lock +0 -248
- data/demo-app/Procfile.dev +0 -3
- data/demo-app/README.md +0 -15
- data/demo-app/Rakefile +0 -6
- data/demo-app/app/assets/builds/.keep +0 -0
- data/demo-app/app/assets/images/.keep +0 -0
- data/demo-app/app/assets/stylesheets/application.css +0 -42
- data/demo-app/app/controllers/application_controller.rb +0 -10
- data/demo-app/app/controllers/concerns/.keep +0 -0
- data/demo-app/app/controllers/concerns/set_flavor.rb +0 -10
- data/demo-app/app/controllers/hide_from_backends_controller.rb +0 -34
- data/demo-app/app/controllers/modal_controller.rb +0 -11
- data/demo-app/app/controllers/posts_controller.rb +0 -69
- data/demo-app/app/controllers/welcome_controller.rb +0 -2
- data/demo-app/app/helpers/application_helper.rb +0 -9
- data/demo-app/app/javascript/application.js +0 -4
- data/demo-app/app/javascript/controllers/application.js +0 -13
- data/demo-app/app/javascript/controllers/dark_mode_controller.js +0 -28
- data/demo-app/app/javascript/controllers/flash_controller.js +0 -9
- data/demo-app/app/javascript/controllers/hello_controller.js +0 -7
- data/demo-app/app/javascript/controllers/index.js +0 -15
- data/demo-app/app/models/application_record.rb +0 -3
- data/demo-app/app/models/concerns/.keep +0 -0
- data/demo-app/app/models/post.rb +0 -4
- data/demo-app/app/views/hide_from_backends/_notice.html.erb +0 -10
- data/demo-app/app/views/hide_from_backends/create.turbo_stream.erb +0 -2
- data/demo-app/app/views/hide_from_backends/new.html.erb +0 -30
- data/demo-app/app/views/layouts/application.html.erb +0 -40
- data/demo-app/app/views/modal/index.html.erb +0 -45
- data/demo-app/app/views/modal/show.html.erb +0 -39
- data/demo-app/app/views/posts/_form.html.erb +0 -36
- data/demo-app/app/views/posts/_post.html.erb +0 -9
- data/demo-app/app/views/posts/edit.html.erb +0 -9
- data/demo-app/app/views/posts/index.html.erb +0 -14
- data/demo-app/app/views/posts/new.html.erb +0 -3
- data/demo-app/app/views/posts/show.html.erb +0 -21
- data/demo-app/app/views/shared/_flash.html.erb +0 -13
- data/demo-app/app/views/welcome/index.html.erb +0 -19
- data/demo-app/bin/bundle +0 -109
- data/demo-app/bin/dev +0 -18
- data/demo-app/bin/rails +0 -4
- data/demo-app/bin/rake +0 -4
- data/demo-app/bin/setup +0 -34
- data/demo-app/config/application.rb +0 -43
- data/demo-app/config/boot.rb +0 -3
- data/demo-app/config/credentials.yml.enc +0 -1
- data/demo-app/config/database.yml +0 -25
- data/demo-app/config/environment.rb +0 -14
- data/demo-app/config/environments/development.rb +0 -51
- data/demo-app/config/environments/production.rb +0 -67
- data/demo-app/config/environments/test.rb +0 -42
- data/demo-app/config/initializers/assets.rb +0 -7
- data/demo-app/config/initializers/content_security_policy.rb +0 -25
- data/demo-app/config/initializers/filter_parameter_logging.rb +0 -8
- data/demo-app/config/initializers/inflections.rb +0 -14
- data/demo-app/config/initializers/new_framework_defaults_8_0.rb +0 -30
- data/demo-app/config/initializers/permissions_policy.rb +0 -11
- data/demo-app/config/initializers/ultimate_turbo_modal.rb +0 -12
- data/demo-app/config/initializers/ultimate_turbo_modal_tailwind.rb +0 -21
- data/demo-app/config/initializers/ultimate_turbo_modal_vanilla.rb +0 -21
- data/demo-app/config/locales/en.yml +0 -33
- data/demo-app/config/puma.rb +0 -41
- data/demo-app/config/routes.rb +0 -9
- data/demo-app/config.ru +0 -6
- data/demo-app/db/migrate/20230331002502_create_posts.rb +0 -10
- data/demo-app/db/migrate/20231031012703_add_post.rb +0 -9
- data/demo-app/db/migrate/20231128141054_add_publish_on_to_posts.rb +0 -5
- data/demo-app/db/schema.rb +0 -22
- data/demo-app/lib/assets/.keep +0 -0
- data/demo-app/lib/tasks/.keep +0 -0
- data/demo-app/log/.keep +0 -0
- data/demo-app/package.json +0 -28
- data/demo-app/postcss.config.js +0 -7
- data/demo-app/public/400.html +0 -114
- data/demo-app/public/404.html +0 -114
- data/demo-app/public/406-unsupported-browser.html +0 -114
- data/demo-app/public/422.html +0 -114
- data/demo-app/public/500.html +0 -114
- data/demo-app/public/apple-touch-icon-precomposed.png +0 -0
- data/demo-app/public/apple-touch-icon.png +0 -0
- data/demo-app/public/favicon.ico +0 -0
- data/demo-app/public/icon.png +0 -0
- data/demo-app/public/icon.svg +0 -3
- data/demo-app/public/img/bootstrap-logo-shadow.png +0 -0
- data/demo-app/public/img/unicat.jpg +0 -0
- data/demo-app/public/img/vanilla.png +0 -0
- data/demo-app/public/robots.txt +0 -1
- data/demo-app/tmp/.keep +0 -0
- data/demo-app/tmp/pids/.keep +0 -0
- data/demo-app/vendor/.keep +0 -0
- data/demo-app/yarn.lock +0 -1035
data/demo-app/Gemfile.lock
DELETED
@@ -1,248 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
ultimate_turbo_modal (2.1.1)
|
5
|
-
actionpack
|
6
|
-
activesupport
|
7
|
-
phlex-rails
|
8
|
-
railties
|
9
|
-
stimulus-rails
|
10
|
-
turbo-rails
|
11
|
-
|
12
|
-
GEM
|
13
|
-
remote: https://rubygems.org/
|
14
|
-
specs:
|
15
|
-
actioncable (8.0.2)
|
16
|
-
actionpack (= 8.0.2)
|
17
|
-
activesupport (= 8.0.2)
|
18
|
-
nio4r (~> 2.0)
|
19
|
-
websocket-driver (>= 0.6.1)
|
20
|
-
zeitwerk (~> 2.6)
|
21
|
-
actionmailbox (8.0.2)
|
22
|
-
actionpack (= 8.0.2)
|
23
|
-
activejob (= 8.0.2)
|
24
|
-
activerecord (= 8.0.2)
|
25
|
-
activestorage (= 8.0.2)
|
26
|
-
activesupport (= 8.0.2)
|
27
|
-
mail (>= 2.8.0)
|
28
|
-
actionmailer (8.0.2)
|
29
|
-
actionpack (= 8.0.2)
|
30
|
-
actionview (= 8.0.2)
|
31
|
-
activejob (= 8.0.2)
|
32
|
-
activesupport (= 8.0.2)
|
33
|
-
mail (>= 2.8.0)
|
34
|
-
rails-dom-testing (~> 2.2)
|
35
|
-
actionpack (8.0.2)
|
36
|
-
actionview (= 8.0.2)
|
37
|
-
activesupport (= 8.0.2)
|
38
|
-
nokogiri (>= 1.8.5)
|
39
|
-
rack (>= 2.2.4)
|
40
|
-
rack-session (>= 1.0.1)
|
41
|
-
rack-test (>= 0.6.3)
|
42
|
-
rails-dom-testing (~> 2.2)
|
43
|
-
rails-html-sanitizer (~> 1.6)
|
44
|
-
useragent (~> 0.16)
|
45
|
-
actiontext (8.0.2)
|
46
|
-
actionpack (= 8.0.2)
|
47
|
-
activerecord (= 8.0.2)
|
48
|
-
activestorage (= 8.0.2)
|
49
|
-
activesupport (= 8.0.2)
|
50
|
-
globalid (>= 0.6.0)
|
51
|
-
nokogiri (>= 1.8.5)
|
52
|
-
actionview (8.0.2)
|
53
|
-
activesupport (= 8.0.2)
|
54
|
-
builder (~> 3.1)
|
55
|
-
erubi (~> 1.11)
|
56
|
-
rails-dom-testing (~> 2.2)
|
57
|
-
rails-html-sanitizer (~> 1.6)
|
58
|
-
activejob (8.0.2)
|
59
|
-
activesupport (= 8.0.2)
|
60
|
-
globalid (>= 0.3.6)
|
61
|
-
activemodel (8.0.2)
|
62
|
-
activesupport (= 8.0.2)
|
63
|
-
activerecord (8.0.2)
|
64
|
-
activemodel (= 8.0.2)
|
65
|
-
activesupport (= 8.0.2)
|
66
|
-
timeout (>= 0.4.0)
|
67
|
-
activestorage (8.0.2)
|
68
|
-
actionpack (= 8.0.2)
|
69
|
-
activejob (= 8.0.2)
|
70
|
-
activerecord (= 8.0.2)
|
71
|
-
activesupport (= 8.0.2)
|
72
|
-
marcel (~> 1.0)
|
73
|
-
activesupport (8.0.2)
|
74
|
-
base64
|
75
|
-
benchmark (>= 0.3)
|
76
|
-
bigdecimal
|
77
|
-
concurrent-ruby (~> 1.0, >= 1.3.1)
|
78
|
-
connection_pool (>= 2.2.5)
|
79
|
-
drb
|
80
|
-
i18n (>= 1.6, < 2)
|
81
|
-
logger (>= 1.4.2)
|
82
|
-
minitest (>= 5.1)
|
83
|
-
securerandom (>= 0.3)
|
84
|
-
tzinfo (~> 2.0, >= 2.0.5)
|
85
|
-
uri (>= 0.13.1)
|
86
|
-
base64 (0.2.0)
|
87
|
-
benchmark (0.4.0)
|
88
|
-
bigdecimal (3.1.9)
|
89
|
-
bindex (0.8.1)
|
90
|
-
builder (3.3.0)
|
91
|
-
concurrent-ruby (1.3.5)
|
92
|
-
connection_pool (2.5.0)
|
93
|
-
crass (1.0.6)
|
94
|
-
cssbundling-rails (1.4.3)
|
95
|
-
railties (>= 6.0.0)
|
96
|
-
date (3.4.1)
|
97
|
-
debug (1.10.0)
|
98
|
-
irb (~> 1.10)
|
99
|
-
reline (>= 0.3.8)
|
100
|
-
drb (2.2.1)
|
101
|
-
erubi (1.13.1)
|
102
|
-
faker (3.5.1)
|
103
|
-
i18n (>= 1.8.11, < 2)
|
104
|
-
globalid (1.2.1)
|
105
|
-
activesupport (>= 6.1)
|
106
|
-
i18n (1.14.7)
|
107
|
-
concurrent-ruby (~> 1.0)
|
108
|
-
io-console (0.8.0)
|
109
|
-
irb (1.15.2)
|
110
|
-
pp (>= 0.6.0)
|
111
|
-
rdoc (>= 4.0.0)
|
112
|
-
reline (>= 0.4.2)
|
113
|
-
jsbundling-rails (1.3.1)
|
114
|
-
railties (>= 6.0.0)
|
115
|
-
logger (1.7.0)
|
116
|
-
loofah (2.24.0)
|
117
|
-
crass (~> 1.0.2)
|
118
|
-
nokogiri (>= 1.12.0)
|
119
|
-
mail (2.8.1)
|
120
|
-
mini_mime (>= 0.1.1)
|
121
|
-
net-imap
|
122
|
-
net-pop
|
123
|
-
net-smtp
|
124
|
-
marcel (1.0.4)
|
125
|
-
mini_mime (1.1.5)
|
126
|
-
minitest (5.25.5)
|
127
|
-
net-imap (0.5.6)
|
128
|
-
date
|
129
|
-
net-protocol
|
130
|
-
net-pop (0.1.2)
|
131
|
-
net-protocol
|
132
|
-
net-protocol (0.2.2)
|
133
|
-
timeout
|
134
|
-
net-smtp (0.5.1)
|
135
|
-
net-protocol
|
136
|
-
nio4r (2.7.4)
|
137
|
-
nokogiri (1.18.7-arm64-darwin)
|
138
|
-
racc (~> 1.4)
|
139
|
-
phlex (1.11.0)
|
140
|
-
phlex-rails (1.2.2)
|
141
|
-
phlex (>= 1.10, < 2)
|
142
|
-
railties (>= 6.1, < 9)
|
143
|
-
pp (0.6.2)
|
144
|
-
prettyprint
|
145
|
-
prettyprint (0.2.0)
|
146
|
-
propshaft (1.1.0)
|
147
|
-
actionpack (>= 7.0.0)
|
148
|
-
activesupport (>= 7.0.0)
|
149
|
-
rack
|
150
|
-
railties (>= 7.0.0)
|
151
|
-
psych (5.2.3)
|
152
|
-
date
|
153
|
-
stringio
|
154
|
-
puma (6.6.0)
|
155
|
-
nio4r (~> 2.0)
|
156
|
-
racc (1.8.1)
|
157
|
-
rack (3.1.12)
|
158
|
-
rack-session (2.1.0)
|
159
|
-
base64 (>= 0.1.0)
|
160
|
-
rack (>= 3.0.0)
|
161
|
-
rack-test (2.2.0)
|
162
|
-
rack (>= 1.3)
|
163
|
-
rackup (2.2.1)
|
164
|
-
rack (>= 3)
|
165
|
-
rails (8.0.2)
|
166
|
-
actioncable (= 8.0.2)
|
167
|
-
actionmailbox (= 8.0.2)
|
168
|
-
actionmailer (= 8.0.2)
|
169
|
-
actionpack (= 8.0.2)
|
170
|
-
actiontext (= 8.0.2)
|
171
|
-
actionview (= 8.0.2)
|
172
|
-
activejob (= 8.0.2)
|
173
|
-
activemodel (= 8.0.2)
|
174
|
-
activerecord (= 8.0.2)
|
175
|
-
activestorage (= 8.0.2)
|
176
|
-
activesupport (= 8.0.2)
|
177
|
-
bundler (>= 1.15.0)
|
178
|
-
railties (= 8.0.2)
|
179
|
-
rails-dom-testing (2.2.0)
|
180
|
-
activesupport (>= 5.0.0)
|
181
|
-
minitest
|
182
|
-
nokogiri (>= 1.6)
|
183
|
-
rails-html-sanitizer (1.6.2)
|
184
|
-
loofah (~> 2.21)
|
185
|
-
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
186
|
-
railties (8.0.2)
|
187
|
-
actionpack (= 8.0.2)
|
188
|
-
activesupport (= 8.0.2)
|
189
|
-
irb (~> 1.13)
|
190
|
-
rackup (>= 1.0.0)
|
191
|
-
rake (>= 12.2)
|
192
|
-
thor (~> 1.0, >= 1.2.2)
|
193
|
-
zeitwerk (~> 2.6)
|
194
|
-
rake (13.2.1)
|
195
|
-
rdoc (6.13.1)
|
196
|
-
psych (>= 4.0.0)
|
197
|
-
reline (0.6.1)
|
198
|
-
io-console (~> 0.5)
|
199
|
-
securerandom (0.4.1)
|
200
|
-
sqlite3 (2.6.0-arm64-darwin)
|
201
|
-
stimulus-rails (1.3.4)
|
202
|
-
railties (>= 6.0.0)
|
203
|
-
stringio (3.1.6)
|
204
|
-
thor (1.3.2)
|
205
|
-
timeout (0.4.3)
|
206
|
-
turbo-rails (2.0.13)
|
207
|
-
actionpack (>= 7.1.0)
|
208
|
-
railties (>= 7.1.0)
|
209
|
-
tzinfo (2.0.6)
|
210
|
-
concurrent-ruby (~> 1.0)
|
211
|
-
uri (1.0.3)
|
212
|
-
useragent (0.16.11)
|
213
|
-
web-console (4.2.1)
|
214
|
-
actionview (>= 6.0.0)
|
215
|
-
activemodel (>= 6.0.0)
|
216
|
-
bindex (>= 0.4.0)
|
217
|
-
railties (>= 6.0.0)
|
218
|
-
websocket-driver (0.7.7)
|
219
|
-
base64
|
220
|
-
websocket-extensions (>= 0.1.0)
|
221
|
-
websocket-extensions (0.1.5)
|
222
|
-
zeitwerk (2.7.2)
|
223
|
-
|
224
|
-
PLATFORMS
|
225
|
-
arm64-darwin-22
|
226
|
-
arm64-darwin-23
|
227
|
-
arm64-darwin-24
|
228
|
-
|
229
|
-
DEPENDENCIES
|
230
|
-
cssbundling-rails
|
231
|
-
debug
|
232
|
-
faker
|
233
|
-
jsbundling-rails
|
234
|
-
propshaft
|
235
|
-
puma (~> 6.6)
|
236
|
-
rails (~> 8.0.2)
|
237
|
-
sqlite3
|
238
|
-
stimulus-rails
|
239
|
-
turbo-rails
|
240
|
-
tzinfo-data
|
241
|
-
ultimate_turbo_modal!
|
242
|
-
web-console
|
243
|
-
|
244
|
-
RUBY VERSION
|
245
|
-
ruby 3.3.9p170
|
246
|
-
|
247
|
-
BUNDLED WITH
|
248
|
-
2.6.7
|
data/demo-app/Procfile.dev
DELETED
data/demo-app/README.md
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# The Ultimate Turbo Modal for Rails - Demo
|
2
|
-
|
3
|
-
This is a demo application. You can find the Ruby Gem and instructions on how to use
|
4
|
-
it in your own application at https://github.com/cmer/ultimate_turbo_modal.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# Getting up and running...
|
9
|
-
|
10
|
-
```sh
|
11
|
-
bin/rails db:create db:migrate db:seed
|
12
|
-
yarn install
|
13
|
-
bin/dev
|
14
|
-
open http://localhost:3000
|
15
|
-
```
|
data/demo-app/Rakefile
DELETED
File without changes
|
File without changes
|
@@ -1,42 +0,0 @@
|
|
1
|
-
@import 'tailwindcss';
|
2
|
-
@import 'ultimate_turbo_modal/dist/vanilla.css' layer(components);
|
3
|
-
@import 'flatpickr/dist/flatpickr.css' layer(base);
|
4
|
-
|
5
|
-
@plugin '@tailwindcss/aspect-ratio';
|
6
|
-
@plugin '@tailwindcss/forms';
|
7
|
-
@plugin '@tailwindcss/typography';
|
8
|
-
|
9
|
-
@custom-variant dark (&:is(.dark *));
|
10
|
-
|
11
|
-
@theme {
|
12
|
-
--font-sans:
|
13
|
-
Inter var, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
14
|
-
'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
|
15
|
-
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
16
|
-
}
|
17
|
-
|
18
|
-
@layer base {
|
19
|
-
|
20
|
-
*,
|
21
|
-
::after,
|
22
|
-
::before,
|
23
|
-
::backdrop,
|
24
|
-
::file-selector-button {
|
25
|
-
border-color: var(--color-gray-200, currentcolor);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
#ts-notice:not(:empty) {
|
30
|
-
position: fixed;
|
31
|
-
top: 0.5rem;
|
32
|
-
right: 0.5rem;
|
33
|
-
width: auto;
|
34
|
-
border: 1px solid;
|
35
|
-
padding: 1rem;
|
36
|
-
margin-top: 2.5rem;
|
37
|
-
margin-bottom: 2.5rem;
|
38
|
-
color: black;
|
39
|
-
border-color: rgba(0, 148, 0, 0.8);
|
40
|
-
background-color: rgba(176, 255, 176, 0.6);
|
41
|
-
max-width: 32rem;
|
42
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
class ApplicationController < ActionController::Base
|
2
|
-
include SetFlavor
|
3
|
-
|
4
|
-
def set_modal_properties
|
5
|
-
%i[padding advance close_button].each do |it|
|
6
|
-
instance_variable_set("@#{it}", params[it] == "1" || params[it].nil?)
|
7
|
-
end
|
8
|
-
@override_url = "/custom-advance-history-url" if @advance
|
9
|
-
end
|
10
|
-
end
|
File without changes
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# Sometimes it might be desirable to close the modal from the backend.
|
2
|
-
# This can be done with Turbo Stream as such:
|
3
|
-
#
|
4
|
-
# <%= turbo_stream.modal(:hide) %>
|
5
|
-
#
|
6
|
-
# This controller is an example of how to do that.
|
7
|
-
class HideFromBackendsController < ApplicationController
|
8
|
-
def new
|
9
|
-
# Show form
|
10
|
-
end
|
11
|
-
|
12
|
-
def create
|
13
|
-
form_is_valid? ? close_modal : render(:new, status: :unprocessable_entity)
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def close_modal
|
19
|
-
if inside_modal?
|
20
|
-
# `create.turbo_stream.erb` will be rendered.
|
21
|
-
# A message will appear in the browser, and the backend
|
22
|
-
# will trigger a modal close via turbo stream.
|
23
|
-
else
|
24
|
-
# if not inside a modal, simply redirect
|
25
|
-
redirect_to("/")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def form_is_valid?
|
30
|
-
return true if request.params[:action] == 'new'
|
31
|
-
params[:email].present?
|
32
|
-
end
|
33
|
-
helper_method :form_is_valid?
|
34
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
class PostsController < ApplicationController
|
2
|
-
before_action :set_post, only: %i[show edit update destroy]
|
3
|
-
before_action :set_modal_properties
|
4
|
-
|
5
|
-
# GET /posts
|
6
|
-
def index
|
7
|
-
@posts = Post.all
|
8
|
-
end
|
9
|
-
|
10
|
-
# GET /posts/1
|
11
|
-
def show
|
12
|
-
@modal_title = @post.title
|
13
|
-
end
|
14
|
-
|
15
|
-
# GET /posts/new
|
16
|
-
def new
|
17
|
-
@post = Post.new
|
18
|
-
@modal_title = "New Post"
|
19
|
-
end
|
20
|
-
|
21
|
-
# GET /posts/1/edit
|
22
|
-
def edit
|
23
|
-
@modal_title = "Edit Post"
|
24
|
-
end
|
25
|
-
|
26
|
-
# POST /posts
|
27
|
-
def create
|
28
|
-
@post = Post.new(post_params)
|
29
|
-
@modal_title = "New Post"
|
30
|
-
|
31
|
-
if @post.save
|
32
|
-
redirect_to "/",
|
33
|
-
notice: "Post was successfully created.",
|
34
|
-
status: :see_other
|
35
|
-
else
|
36
|
-
render :new, status: :unprocessable_entity
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# PATCH/PUT /posts/1
|
41
|
-
def update
|
42
|
-
if @post.update(post_params)
|
43
|
-
redirect_to "/",
|
44
|
-
notice: "Post was successfully updated.",
|
45
|
-
status: :see_other
|
46
|
-
else
|
47
|
-
render :edit, status: :unprocessable_entity
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# DELETE /posts/1
|
52
|
-
def destroy
|
53
|
-
redirect_to "/",
|
54
|
-
notice: "Post was successfully destroyed. (but not really)",
|
55
|
-
status: :see_other
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
# Use callbacks to share common setup or constraints between actions.
|
61
|
-
def set_post
|
62
|
-
@post = Post.find(params[:id])
|
63
|
-
end
|
64
|
-
|
65
|
-
# Only allow a list of trusted parameters through.
|
66
|
-
def post_params
|
67
|
-
params.require(:post).permit(:title, :body)
|
68
|
-
end
|
69
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
module ApplicationHelper
|
2
|
-
def h1_classes
|
3
|
-
"text-2xl font-bold tracking-tight text-gray-900 sm:text-4xl border-b mb-2 dark:text-white"
|
4
|
-
end
|
5
|
-
|
6
|
-
def button_classes
|
7
|
-
"rounded-md bg-indigo-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-xs hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
|
8
|
-
end
|
9
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { Application } from "@hotwired/stimulus"
|
2
|
-
|
3
|
-
const application = Application.start()
|
4
|
-
|
5
|
-
// Configure Stimulus development experience
|
6
|
-
application.debug = false
|
7
|
-
window.Stimulus = application
|
8
|
-
|
9
|
-
// Flatpickr
|
10
|
-
import Flatpickr from "stimulus-flatpickr"
|
11
|
-
application.register('flatpickr', Flatpickr)
|
12
|
-
|
13
|
-
export { application }
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import { Controller } from "@hotwired/stimulus"
|
2
|
-
|
3
|
-
export default class extends Controller {
|
4
|
-
static targets = ["toggle"];
|
5
|
-
|
6
|
-
toggleTheme() {
|
7
|
-
// Toggle the dark class on the html element
|
8
|
-
if (document.documentElement.classList.contains('dark')) {
|
9
|
-
document.documentElement.classList.remove('dark');
|
10
|
-
this.setCookie('theme', 'light');
|
11
|
-
} else {
|
12
|
-
document.documentElement.classList.add('dark');
|
13
|
-
this.setCookie('theme', 'dark');
|
14
|
-
}
|
15
|
-
}
|
16
|
-
|
17
|
-
setCookie(name, value, days = 7) {
|
18
|
-
const expires = new Date(Date.now() + days * 864e5).toUTCString();
|
19
|
-
document.cookie = `${name}=${value};expires=${expires};path=/`;
|
20
|
-
}
|
21
|
-
|
22
|
-
getCookie(name) {
|
23
|
-
const value = `; ${document.cookie}`;
|
24
|
-
const parts = value.split(`; ${name}=`);
|
25
|
-
if (parts.length === 2) return parts.pop().split(';').shift();
|
26
|
-
return null;
|
27
|
-
}
|
28
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
// This file is auto-generated by ./bin/rails stimulus:manifest:update
|
2
|
-
// Run that command whenever you add a new controller or create them with
|
3
|
-
// ./bin/rails generate stimulus controllerName
|
4
|
-
|
5
|
-
import { application } from "./application"
|
6
|
-
|
7
|
-
import DarkModeController from "./dark_mode_controller"
|
8
|
-
application.register("dark-mode", DarkModeController)
|
9
|
-
|
10
|
-
import FlashController from "./flash_controller"
|
11
|
-
application.register("flash", FlashController)
|
12
|
-
|
13
|
-
// import { UltimateTurboModalController } from "../../../../ultimate_turbo_modal-rails/javascript/dist/ultimate_turbo_modal.js"
|
14
|
-
import { UltimateTurboModalController } from "ultimate_turbo_modal"
|
15
|
-
application.register("modal", UltimateTurboModalController)
|
File without changes
|
data/demo-app/app/models/post.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
<% if local_assigns[:message] %>
|
2
|
-
<div id="ts-notice">
|
3
|
-
<%= local_assigns[:message] %>
|
4
|
-
<div class="mt-3 font-medium">
|
5
|
-
<a href="#" onclick="document.getElementById('ts-notice').innerHTML=''; return false;">Close</a>
|
6
|
-
</div>
|
7
|
-
</div>
|
8
|
-
<% else %>
|
9
|
-
<div id="ts-notice"></div>
|
10
|
-
<% end %>
|
@@ -1,30 +0,0 @@
|
|
1
|
-
<%= modal(title: "My Glorious Form") do %>
|
2
|
-
<% if !inside_modal? %>
|
3
|
-
<div class="px-4 py-5 sm:p-3">
|
4
|
-
<h3 class="text-base font-semibold leading-6 text-gray-900">My Glorious Form</h3>
|
5
|
-
<% end %>
|
6
|
-
|
7
|
-
<div class="mt-2 max-w-xl text-sm text-gray-500 dark:text-white">
|
8
|
-
<p>Upon submission, the modal will be closed from the backend.</p>
|
9
|
-
<p class="mt-2">If no email is entered, the form will be redisplayed with errors.</p>
|
10
|
-
</div>
|
11
|
-
|
12
|
-
<% if !form_is_valid? %>
|
13
|
-
<div class="my-4 text-red-700 font-semibold">
|
14
|
-
Email is required!
|
15
|
-
</div>
|
16
|
-
<% end %>
|
17
|
-
|
18
|
-
<%= form_with url: hide_from_backend_path, method: :post, class: "mt-5 sm:flex sm:items-center" do %>
|
19
|
-
<div class="w-full sm:max-w-xs">
|
20
|
-
<label for="email" class="sr-only">Email</label>
|
21
|
-
<input type="email" name="email" id="email" class="block w-full rounded-md border-0 py-1.5 text-gray-900 ring-gray-300 shadow-xs ring-1 ring-inset placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" placeholder="you@example.com">
|
22
|
-
</div>
|
23
|
-
|
24
|
-
<button type="submit" class="mt-3 inline-flex w-full items-center justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-xs hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 sm:ml-3 sm:mt-0 sm:w-auto">Save</button>
|
25
|
-
<% end %>
|
26
|
-
|
27
|
-
<% if !inside_modal? %>
|
28
|
-
</div>
|
29
|
-
<% end %>
|
30
|
-
<% end %>
|
@@ -1,40 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html class="<%= cookies[:theme] == "dark" ? "dark" : "" %>">
|
3
|
-
<head>
|
4
|
-
<title>Ultimate Turbo Modal</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<%= csrf_meta_tags %>
|
7
|
-
<%= csp_meta_tag %>
|
8
|
-
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
9
|
-
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
|
10
|
-
</head>
|
11
|
-
|
12
|
-
<body class="dark:bg-slate-800 dark:text-white transition-colors">
|
13
|
-
<%= turbo_frame_tag "modal" %>
|
14
|
-
<%= render partial: "shared/flash" %>
|
15
|
-
|
16
|
-
<div class="container mx-auto mt-8 px-5 bg-white dark:bg-slate-800 transition-colors">
|
17
|
-
<%= yield %>
|
18
|
-
</div>
|
19
|
-
|
20
|
-
<div class="fixed right-4 top-4 h-6 text-black dark:text-white" data-controller="dark-mode">
|
21
|
-
<button data-action="click->dark-mode#toggleTheme">
|
22
|
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 dark:hidden">
|
23
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z" />
|
24
|
-
</svg>
|
25
|
-
|
26
|
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 hidden dark:block">
|
27
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z" />
|
28
|
-
</svg>
|
29
|
-
</button>
|
30
|
-
</div>
|
31
|
-
|
32
|
-
<a href="/">
|
33
|
-
<% if UltimateTurboModal.flavor == :tailwind %>
|
34
|
-
<svg class="fixed right-4 bottom-4 h-12" viewBox="0 0 50 31" class="text-slate-900 dark:text-white w-auto h-5"><path fill-rule="evenodd" clip-rule="evenodd" d="M25.517 0C18.712 0 14.46 3.382 12.758 10.146c2.552-3.382 5.529-4.65 8.931-3.805 1.941.482 3.329 1.882 4.864 3.432 2.502 2.524 5.398 5.445 11.722 5.445 6.804 0 11.057-3.382 12.758-10.145-2.551 3.382-5.528 4.65-8.93 3.804-1.942-.482-3.33-1.882-4.865-3.431C34.736 2.92 31.841 0 25.517 0zM12.758 15.218C5.954 15.218 1.701 18.6 0 25.364c2.552-3.382 5.529-4.65 8.93-3.805 1.942.482 3.33 1.882 4.865 3.432 2.502 2.524 5.397 5.445 11.722 5.445 6.804 0 11.057-3.381 12.758-10.145-2.552 3.382-5.529 4.65-8.931 3.805-1.941-.483-3.329-1.883-4.864-3.432-2.502-2.524-5.398-5.446-11.722-5.446z" fill="#38bdf8"></path></svg>
|
35
|
-
<% elsif UltimateTurboModal.flavor == :vanilla %>
|
36
|
-
<img class="fixed right-4 bottom-4 h-16" src="/img/vanilla.png">
|
37
|
-
<% end %>
|
38
|
-
</a>
|
39
|
-
</body>
|
40
|
-
</html>
|