inertia_rails 3.13.0 → 3.14.0

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/lib/generators/inertia/install/frameworks.yml +3 -18
  4. data/lib/generators/inertia/install/install_generator.rb +51 -6
  5. data/lib/generators/inertia/install/templates/assets/rails.svg +9 -0
  6. data/lib/generators/inertia/install/templates/controller.rb +6 -1
  7. data/lib/generators/inertia/install/templates/react/InertiaExample.jsx +42 -46
  8. data/lib/generators/inertia/install/templates/react/InertiaExample.module.css +63 -41
  9. data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +45 -46
  10. data/lib/generators/inertia/install/templates/react/inertia.jsx +1 -1
  11. data/lib/generators/inertia/install/templates/react/inertia.tsx +3 -3
  12. data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +103 -69
  13. data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +104 -69
  14. data/lib/generators/inertia/install/templates/svelte/inertia.js +1 -1
  15. data/lib/generators/inertia/install/templates/svelte/inertia.ts +1 -1
  16. data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +107 -70
  17. data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +129 -92
  18. data/lib/generators/inertia/install/templates/vue/inertia.js +3 -3
  19. data/lib/generators/inertia/install/templates/vue/inertia.ts +3 -3
  20. data/lib/generators/inertia_templates/scaffold/templates/react/form.tsx.tt +3 -3
  21. data/lib/generators/inertia_templates/scaffold/templates/svelte/form.ts.svelte.tt +3 -3
  22. data/lib/generators/inertia_templates/scaffold/templates/svelte/new.svelte.tt +1 -1
  23. data/lib/generators/inertia_templates/scaffold/templates/svelte/new.ts.svelte.tt +1 -1
  24. data/lib/generators/inertia_templates/scaffold/templates/vue/form.ts.vue.tt +3 -3
  25. data/lib/generators/inertia_tw_templates/scaffold/templates/react/form.tsx.tt +3 -3
  26. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/form.ts.svelte.tt +3 -3
  27. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/new.svelte.tt +1 -2
  28. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/new.ts.svelte.tt +1 -1
  29. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/form.ts.vue.tt +3 -3
  30. data/lib/inertia_rails/version.rb +1 -1
  31. data/lib/inertia_rails.rb +1 -0
  32. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 611e06ee0f1697740744921528223e862a4d4f7533fe195c40cfd5cdc8f6b7b4
4
- data.tar.gz: 97f4302df2a4b8b1e09d36ae9f375942ce672079e247e7694f535fe1e5128206
3
+ metadata.gz: 8e02de8da9dda43a24dae17c59496938d35eef2caa4bade2543d4336201baa0e
4
+ data.tar.gz: ae6952effd0e1144dc78f2c7f2a3ae9ccc0f1b6011000ef9a7ecfe9f8d9166aa
5
5
  SHA512:
6
- metadata.gz: 4aeb2fa0fc8bc672d74ab72c702706a9ddc0a98d7e0f224a3a933d9b66173c6232e125f2cca76a6b43c6e85c8fd1d12aaaee2ff203f85ce2a64476c01f2e9ce7
7
- data.tar.gz: 6f8b818fb214b5f0ea18cc0c3930bd35587dd5a7b310e66e86dd4cbde5add15654ef26280427890182b12fc09f23e71bc5e5e4467c46a46ed0f68c2f23028d66
6
+ metadata.gz: 5426c306db138b90256fc924f20f6ce5b68583c431f10f49f1acd5eb64c013b9ed1f4d75472dfab8a971df43a9ad4a03a2854f2a1dff5fbbb4d09748b9b92a0d
7
+ data.tar.gz: f12bd8e51187679c56a6db6e545687d7ac5c795d20e9d74d5865897b61e9d0308480f4dc06a62fca9d32aa1129041977bdf4be2f69061aaccb3b571972d7d6cc
data/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.14.0] - 2025-11-27
8
+
9
+ Lots of quality of life improvements!
10
+
11
+ * OG Pilot in Awesome page (@raulpopadineti)
12
+ * Expose InertiaRails version (@capripot)
13
+ * Svelte improvements to install generators (@alec-c4)
14
+ * Add start kits to docs (@skryukov)
15
+ * Fix types in React install templates (@skryukov)
16
+ * Update docs with new inertia branding (@skryukov)
17
+ * Add protocol diagram (@skryukov)
18
+ * Fix forceIndicesArrayFormatInFormData in install generator (@skryukov)
19
+ * Add Kickstart templates to awesome page (@alec-c4)
20
+ * Improve generators for TypeScript users (@Andy9822)
21
+ * Update example pages to mimic Rails styling and appear at root path by default (@capripot)
22
+ * Update error types in install templates (@skryukov)
23
+
7
24
  ## [3.13.0] - 2025-11-19
8
25
 
9
26
  * Update installers (@skryukov)
@@ -13,16 +13,11 @@ react:
13
13
  vite_plugin_call: "react()"
14
14
  copy_files_ts:
15
15
  "InertiaExample.tsx": "%{js_destination_path}/pages/inertia_example/index.tsx"
16
- "tsconfig.json": "tsconfig.json"
17
- "tsconfig.app.json": "tsconfig.app.json"
18
- "tsconfig.node.json": "tsconfig.node.json"
19
- "types/vite-env.d.ts": "%{js_destination_path}/types/vite-env.d.ts"
20
- "types/globals.d.ts": "%{js_destination_path}/types/globals.d.ts"
21
- "types/index.ts": "%{js_destination_path}/types/index.ts"
22
16
  copy_files_js:
23
17
  "InertiaExample.jsx": "%{js_destination_path}/pages/inertia_example/index.jsx"
24
18
  copy_files:
25
19
  "InertiaExample.module.css": "%{js_destination_path}/pages/inertia_example/index.module.css"
20
+ "../assets/rails.svg": "%{js_destination_path}/assets/rails.svg"
26
21
  "../assets/react.svg": "%{js_destination_path}/assets/react.svg"
27
22
  "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
28
23
  "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
@@ -39,17 +34,12 @@ vue:
39
34
  vite_plugin_import: "import vue from '@vitejs/plugin-vue'"
40
35
  vite_plugin_call: "vue()"
41
36
  copy_files:
37
+ "../assets/rails.svg": "%{js_destination_path}/assets/rails.svg"
42
38
  "../assets/vue.svg": "%{js_destination_path}/assets/vue.svg"
43
39
  "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
44
40
  "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
45
41
  copy_files_ts:
46
42
  "InertiaExample.ts.vue": "%{js_destination_path}/pages/inertia_example/index.vue"
47
- "tsconfig.json": "tsconfig.json"
48
- "tsconfig.app.json": "tsconfig.app.json"
49
- "tsconfig.node.json": "tsconfig.node.json"
50
- "types/vite-env.d.ts": "%{js_destination_path}/types/vite-env.d.ts"
51
- "types/globals.d.ts": "%{js_destination_path}/types/globals.d.ts"
52
- "types/index.ts": "%{js_destination_path}/types/index.ts"
53
43
  copy_files_js:
54
44
  "InertiaExample.vue": "%{js_destination_path}/pages/inertia_example/index.vue"
55
45
 
@@ -68,15 +58,10 @@ svelte:
68
58
  vite_plugin_call: "svelte()"
69
59
  copy_files_ts:
70
60
  "InertiaExample.ts.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
71
- "tsconfig.json": "tsconfig.json"
72
- "tsconfig.node.json": "tsconfig.node.json"
73
- "types/vite-env.d.ts": "%{js_destination_path}/types/vite-env.d.ts"
74
- "types/globals.d.ts": "%{js_destination_path}/types/globals.d.ts"
75
- "types/index.ts": "%{js_destination_path}/types/index.ts"
76
61
  copy_files_js:
77
62
  "InertiaExample.svelte": "%{js_destination_path}/pages/inertia_example/index.svelte"
78
63
  copy_files:
79
- "svelte.config.js": "svelte.config.js"
64
+ "../assets/rails.svg": "%{js_destination_path}/assets/rails.svg"
80
65
  "../assets/svelte.svg": "%{js_destination_path}/assets/svelte.svg"
81
66
  "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
82
67
  "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
@@ -101,6 +101,12 @@ module Inertia
101
101
  say "Copying #{inertia_entrypoint} entrypoint"
102
102
  copy_file "#{framework}/#{inertia_entrypoint}", js_file_path("entrypoints/#{inertia_entrypoint}")
103
103
 
104
+ # Copy framework-specific config files
105
+ if svelte?
106
+ say 'Copying svelte.config.js'
107
+ copy_file 'svelte/svelte.config.js', file_path('svelte.config.js')
108
+ end
109
+
104
110
  say 'Copying InertiaController'
105
111
  copy_file 'inertia_controller.rb', file_path('app/controllers/inertia_controller.rb')
106
112
 
@@ -112,7 +118,7 @@ module Inertia
112
118
  ERB
113
119
  insert_into_file application_layout.to_s, headers, after: "<%= vite_client_tag %>\n"
114
120
 
115
- if framework == 'react' && !application_layout.read.include?('vite_react_refresh_tag')
121
+ if react? && !application_layout.read.include?('vite_react_refresh_tag')
116
122
  say 'Adding Vite React Refresh tag to the application layout'
117
123
  insert_into_file application_layout.to_s, "<%= vite_react_refresh_tag %>\n ",
118
124
  before: '<%= vite_client_tag %>'
@@ -124,7 +130,7 @@ module Inertia
124
130
  say_error '- <title>...</title>'
125
131
  say_error '+ <title data-inertia>...</title>'
126
132
  say_error '+ <%= inertia_ssr_head %>'
127
- say_error '+ <%= vite_react_refresh_tag %>' if framework == 'react'
133
+ say_error '+ <%= vite_react_refresh_tag %>' if react?
128
134
  say_error "+ <%= #{vite_tag} %>"
129
135
  end
130
136
  end
@@ -142,14 +148,30 @@ module Inertia
142
148
 
143
149
  add_dependencies(*FRAMEWORKS[framework]['packages_ts'])
144
150
 
145
- say 'Copying adding scripts to package.json'
151
+ say 'Copying tsconfig and types'
152
+
153
+ # Copy tsconfig files
154
+ tsconfig_files = %w[tsconfig.json tsconfig.node.json]
155
+ tsconfig_files << 'tsconfig.app.json' unless svelte?
156
+
157
+ tsconfig_files.each do |file|
158
+ template "#{framework}/#{file}", file_path(file)
159
+ end
160
+
161
+ # Copy type definition files
162
+ types_files = %w[types/vite-env.d.ts types/globals.d.ts types/index.ts]
163
+ types_files.each do |file|
164
+ template "#{framework}/#{file}", file_path("#{js_destination_path}/#{file}")
165
+ end
166
+
167
+ say 'Adding TypeScript check scripts to package.json'
146
168
  if svelte?
147
169
  run 'npm pkg set scripts.check="svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"'
148
- end
149
- if framework == 'vue'
170
+ elsif react?
171
+ run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
172
+ elsif vue?
150
173
  run 'npm pkg set scripts.check="vue-tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
151
174
  end
152
- run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"' if framework == 'react'
153
175
  end
154
176
 
155
177
  def install_example_page
@@ -158,6 +180,7 @@ module Inertia
158
180
 
159
181
  say 'Adding a route for the example Inertia controller'
160
182
  route "get 'inertia-example', to: 'inertia_example#index'"
183
+ route "root 'inertia_example#index'" unless File.read(file_path('config/routes.rb')).match?(/^\s*root\s+/)
161
184
 
162
185
  say 'Copying page assets'
163
186
  copy_files = FRAMEWORKS[framework]['copy_files'].merge(
@@ -201,6 +224,7 @@ module Inertia
201
224
  exit(false)
202
225
  end
203
226
  if (capture = run('bundle exec vite install', capture: !verbose?))
227
+ rename_application_js_to_ts if typescript?
204
228
  say 'Vite Rails successfully installed', :green
205
229
  else
206
230
  say capture
@@ -213,6 +237,15 @@ module Inertia
213
237
  end
214
238
  end
215
239
 
240
+ def rename_application_js_to_ts
241
+ return unless File.exist?(application_js_path)
242
+ return unless application_layout.read.include?("<%= vite_javascript_tag 'application' %>")
243
+
244
+ FileUtils.mv(application_js_path, application_ts_path)
245
+ gsub_file application_layout.to_s, /<%= vite_javascript_tag 'application' %>/,
246
+ "<%= vite_typescript_tag 'application' %>"
247
+ end
248
+
216
249
  def ruby_vite_installed?
217
250
  return true if package_manager.present? && ruby_vite?
218
251
 
@@ -274,6 +307,14 @@ module Inertia
274
307
  @typescript = options[:typescript] || yes?('Would you like to use TypeScript? (y/n)', :green)
275
308
  end
276
309
 
310
+ def application_js_path
311
+ js_file_path('entrypoints/application.js')
312
+ end
313
+
314
+ def application_ts_path
315
+ js_file_path('entrypoints/application.ts')
316
+ end
317
+
277
318
  def inertia_entrypoint
278
319
  "inertia.#{typescript? ? 'ts' : 'js'}#{'x' if react?}"
279
320
  end
@@ -303,6 +344,10 @@ module Inertia
303
344
  framework.start_with? 'react'
304
345
  end
305
346
 
347
+ def vue?
348
+ framework.start_with? 'vue'
349
+ end
350
+
306
351
  def inertia_package
307
352
  "#{FRAMEWORKS[framework]['inertia_package']}@#{options[:inertia_version]}"
308
353
  end
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="100px" height="100px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
4
+ <g id="rails">
5
+ <path d="M100,50 C100,22.38575 77.61425,0 50,0 C22.38575,0 0,22.38575 0,50 C0,77.61425 22.38575,100 50,100 C77.61425,100 100,77.61425 100,50 Z" id="Path" fill="#D30001"></path>
6
+ <path d="M93.892357,43.4595403 L93.892357,47.5730437 L86.5920182,47.5730437 L86.5920182,49.4715837 L90.2760899,49.4715837 C92.248599,49.4715837 94.348624,50.9380148 94.474087,53.4380961 L94.48,53.6754938 L94.48,55.2576105 C94.392176,58.2655695 91.9368789,59.3966123 90.4084611,59.4587878 L90.2760899,59.4615206 L82.8853448,59.4615206 L82.8853448,55.3706188 L90.3664966,55.3480172 L90.3664966,53.3590705 L86.8858399,53.3590705 C85.1105816,53.3590705 82.8040078,52.0201552 82.6658457,49.4041504 L82.6593281,49.1551604 L82.6593281,47.7312554 C82.6593281,45.0330152 84.937541,43.5484024 86.7247921,43.4634063 L86.8858399,43.4595403 L93.892357,43.4595403 Z M75.200778,43.4595403 L75.200778,55.3254155 L81.3710331,55.3254155 L81.3710331,59.4615206 L70.6352412,59.4615206 L70.6352412,43.4595403 L75.200778,43.4595403 Z M68.7593029,43.4595403 L68.7593029,59.4615206 L64.1711644,59.4615206 L64.1711644,43.4595403 L68.7593029,43.4595403 Z M53.5483809,43.4595403 L57.955706,43.4595403 L58.14343,43.4662215 C58.1772909,43.468495 58.2123757,43.4713714 58.2485901,43.4748858 L58.4786776,43.5039036 C59.7700605,43.7024512 62.0250592,44.6252852 62.1538484,47.4107623 L62.1596161,47.6634504 L62.1596161,59.4615206 L57.887901,59.4615206 L57.887901,56.6363122 L53.7517959,56.6363122 L53.7517959,59.4615206 L49.3444708,59.4615206 L49.3444708,47.6634504 C49.3444708,46.3450198 50.3485534,43.6166009 53.2913698,43.4660394 L53.5483809,43.4595403 Z M33.808529,43.4567822 L42.3887147,43.4573571 L42.6276381,43.4941033 L42.775584,43.5235203 L43.0497001,43.5888785 L43.2622199,43.6487853 L43.4945424,43.7235035 C43.5347217,43.7372739 43.5755826,43.7517236 43.6170534,43.7668839 L43.8726225,43.8666215 L44.1393843,43.9849067 C45.4954358,44.6251933 47.1420698,46.017065 47.1420698,49.0012007 C47.1420698,52.1842788 45.5955457,53.5026906 44.4432336,54.0432484 L44.2322685,54.1357529 L44.0333857,54.2116184 L43.849428,54.272437 L43.6832382,54.3198006 L43.4734874,54.3691007 L43.2138381,54.410937 L48.2195276,59.4615206 L41.8445687,59.4615206 L38.1183604,55.60063 L38.1183604,59.4615206 L33.808529,59.4615206 L33.808529,43.4567822 Z M55.8155893,40.3698629 L56.260581,40.7925436 L56.017613,40.9705317 L55.6693799,41.2398682 L55.4695226,41.4027886 C50.2296259,37.5282171 45.8218772,35.9806477 42.2724036,35.5874349 L41.7464229,35.5369641 C40.7073487,35.4527515 39.7456368,35.467154 38.8619927,35.5485103 L38.4266795,35.5946214 C38.3552127,35.6031876 38.2842888,35.6121822 38.2139083,35.6215867 L37.7981488,35.6827872 L37.3954497,35.7529479 L37.0058303,35.8311894 L36.6293105,35.9166321 C36.5676499,35.9314238 36.5065359,35.9464789 36.445969,35.9617791 L36.0891351,36.0563748 L35.7454497,36.155973 L35.4149323,36.2596943 L35.0976026,36.3666592 L34.7934801,36.4759882 L34.5025845,36.5868019 L34.0910843,36.7538822 L33.5888941,36.9736437 L32.9355205,37.2825393 L32.3254155,37.5831068 C27.6265289,40.2050856 25.4714861,44.4291779 24.5572153,48.4697531 L24.4349052,49.0455369 C24.3968548,49.2369202 24.3614774,49.4276945 24.328632,49.617667 L24.2375516,50.1849866 L24.1608198,50.7463387 L24.0975923,51.3005664 C24.0881329,51.3922798 24.0792009,51.4836481 24.0707789,51.5746472 L24.0262249,52.1160194 L23.9930648,52.647375 C23.9884406,52.7350353 23.9842561,52.8222301 23.9804935,52.9089352 L23.962841,53.423097 L23.9544717,53.9243501 L23.9545413,54.4115377 L23.9686219,55.1134156 L23.9969414,55.7771385 L24.0366503,56.3988022 L24.0848995,56.9745021 L24.1388397,57.5003338 L24.2146878,58.1171217 L24.288834,58.6290587 L24.3688342,59.1074343 L24.4374337,59.4615206 L6.5821167,59.4615206 L6.6406067,59.0197953 L6.6869435,58.7246505 L6.7499641,58.3599263 L6.863246,57.7707194 L6.9726247,57.2556287 L7.1546512,56.4771199 L7.3207888,55.8284427 L7.4467121,55.3668484 L7.6597595,54.6330259 L7.818725,54.1175217 L7.9918978,53.5820518 L8.1798441,53.0275292 L8.3831298,52.4548672 L8.6023211,51.8649789 L8.8379839,51.2587775 L9.0906843,50.6371763 C9.1342523,50.5323435 9.1785537,50.4269072 9.2236005,50.3208862 L9.5029185,49.6778975 L9.8006892,49.0217919 L10.1174786,48.3534827 L10.4538526,47.673883 L10.8103775,46.983906 C11.1771664,46.2890449 11.5750304,45.5799876 12.0065168,44.8608436 C16.7528669,36.9502602 24.8442637,30.9608184 31.4213488,30.373175 C36.4667294,29.8677656 41.3138924,31.3008573 45.3657116,33.2528185 L46.0156974,33.5736767 L46.6511742,33.902286 L47.2715761,34.237301 C47.3736887,34.2935959 47.4751497,34.3501017 47.5759471,34.4067902 L48.1726757,34.7488915 L48.7529147,35.0940354 L49.3160983,35.4408765 L49.8616607,35.7880697 L50.389036,36.1342696 L50.8976583,36.478131 C50.9808345,36.5351716 51.0632058,36.5920587 51.1447603,36.6487643 L51.6241923,36.9865955 L52.0834567,37.3187249 L52.5219877,37.6438074 L52.9392194,37.9604976 L53.523893,38.4168545 L54.0574604,38.8467616 L54.6860841,39.3709795 L55.3324273,39.932381 L55.8155893,40.3698629 Z M25.1154837,54.9411872 L27.5564638,55.8226522 C27.6694721,56.7078841 27.8295672,57.5460293 27.9975102,58.3109283 L28.0989038,58.7608689 L25.3867037,57.7889972 L25.352869,57.5768354 L25.2868269,57.1012511 L25.2256668,56.5600316 C25.1776383,56.0825714 25.1380854,55.5401313 25.1154837,54.9411872 Z M56.6222076,47.279222 L55.1078959,47.279222 C54.1678721,47.279222 53.8687735,47.688994 53.7736058,47.949758 L53.7453792,48.0447919 C53.7421422,48.0588649 53.7395526,48.0719445 53.737481,48.0838651 L53.7293237,48.155389 L53.7291942,52.0707754 L57.8652993,52.0707754 L57.863446,48.136006 L57.8531848,48.0690147 L57.8274641,47.9702906 C57.7439284,47.7111399 57.4765506,47.279222 56.6222076,47.279222 L56.6222076,47.279222 Z M6.1300834,47.618247 L8.7292751,48.567517 L8.3206341,49.5191009 C8.1081459,50.0185653 7.8928545,50.5339151 7.7172766,50.9768459 L7.5991917,51.2797171 L5,50.3304471 L5.1323662,49.9851438 L5.3907551,49.3459404 L5.6964662,48.617743 L6.0219537,47.8641186 C6.0581975,47.7813243 6.0942974,47.6992363 6.1300834,47.618247 L6.1300834,47.618247 Z M41.5752043,47.4748021 L38.1183604,47.4748021 L38.1183604,51.1336694 L41.5527572,51.1336694 L41.6074678,51.1082774 L41.6940662,51.0593791 L41.8088198,50.9806969 C42.1014626,50.7595521 42.5404269,50.2657172 42.5404269,49.2930122 C42.5404269,48.3203072 42.1114391,47.8364488 41.8254472,47.6219549 L41.7133017,47.5458808 L41.6286714,47.4989507 L41.5752043,47.4748021 Z M26.1325587,46.7141803 L27.7598788,48.0024754 C27.5790654,48.7076474 27.4416473,49.4128194 27.3476243,50.1179914 L27.2852437,50.6468704 L25.4545087,49.2003637 C25.6353221,48.3867037 25.8387371,47.550442 26.1325587,46.7141803 Z M30.1330538,40.4083152 L31.1501288,41.9452286 C30.7523395,42.3610993 30.3834803,42.7769699 30.0551233,43.2159847 L29.8166305,43.549947 L28.7317504,41.9226269 C29.1385804,41.4027886 29.6132155,40.8829502 30.1330538,40.4083152 L30.1330538,40.4083152 Z M13.9502602,37.0632685 L15.5549785,38.4645719 C15.1481485,38.8883531 14.754032,39.3375613 14.3821639,39.7931261 L14.0180652,40.2501036 L12.2777368,38.7583935 C12.7975751,38.1933519 13.3626168,37.6283102 13.9502602,37.0632685 L13.9502602,37.0632685 Z M36.3485123,36.9728618 L36.8457489,38.4645719 C36.3213903,38.6273039 35.7970316,38.8334311 35.2726729,39.0713814 L34.8794039,39.2556302 L34.3595655,37.6961152 C34.9246072,37.4474968 35.5800556,37.1988785 36.3485123,36.9728618 L36.3485123,36.9728618 Z M41.6373023,36.4304218 C42.215905,36.4665845 42.8089728,36.5316773 43.4165056,36.6372723 L43.8748674,36.7242435 L43.7844607,38.1255469 C43.1877767,37.9989775 42.5910927,37.9158034 41.9944087,37.8760245 L41.5468957,37.8543269 L41.6373023,36.4304218 Z M23.0813337,30.1923617 L24.0984087,31.7518767 C23.6576762,31.972243 23.2296571,32.2180361 22.7952813,32.479721 L22.3580803,32.7463501 L21.3184036,31.1642334 C21.9286486,30.8026067 22.516292,30.4861834 23.0813337,30.1923617 L23.0813337,30.1923617 Z M41.592099,30.8252084 L41.6825057,29.3334984 L42.126013,29.4640548 L42.5099933,29.58438 L42.8385391,29.6942879 L43.1157428,29.7935927 L43.4442343,29.9222617 L43.7407223,30.0549729 L43.8748674,30.1245567 L43.7844607,31.6388684 C43.3022918,31.4429873 42.8201229,31.2571514 42.3312572,31.0813606 L41.592099,30.8252084 Z M33.0486689,28 L33.5007022,29.3787017 L33.2746855,29.3787017 C32.7830993,29.3787017 32.291513,29.3914151 31.7999267,29.4263771 L31.3083405,29.4691084 L30.8789088,28.13561 C31.6247638,28.0452033 32.3480172,28 33.0486689,28 L33.0486689,28 Z" id="Shape" fill="#FFFFFF" fill-rule="nonzero"></path>
7
+ </g>
8
+ </g>
9
+ </svg>
@@ -2,6 +2,11 @@
2
2
 
3
3
  class InertiaExampleController < InertiaController
4
4
  def index
5
- render inertia: { name: params.fetch(:name, 'World') }
5
+ render inertia: {
6
+ rails_version: Rails.version,
7
+ ruby_version: RUBY_DESCRIPTION,
8
+ rack_version: Rack.release,
9
+ inertia_rails_version: InertiaRails::VERSION,
10
+ }
6
11
  end
7
12
  end
@@ -1,60 +1,56 @@
1
1
  import { Head } from '@inertiajs/react'
2
- import { useState } from 'react'
2
+ import { version as react_version } from 'react'
3
3
 
4
+ import railsSvg from '/assets/rails.svg'
4
5
  import inertiaSvg from '/assets/inertia.svg'
5
6
  import reactSvg from '/assets/react.svg'
6
- import viteRubySvg from '/assets/vite_ruby.svg'
7
7
 
8
8
  import cs from './index.module.css'
9
9
 
10
- export default function InertiaExample({ name }) {
11
- const [count, setCount] = useState(0)
12
-
10
+ export default function InertiaExample({ rails_version, ruby_version, rack_version, inertia_rails_version }) {
13
11
  return (
14
- <>
15
- <Head title="Inertia + Vite Ruby + React Example" />
16
-
17
- <div className={cs.root}>
18
- <h1 className={cs.h1}>Hello {name}!</h1>
19
-
20
- <div>
21
- <a href="https://inertia-rails.dev" target="_blank">
22
- <img className={cs.logo} src={inertiaSvg} alt="Inertia logo" />
23
- </a>
24
- <a href="https://vite-ruby.netlify.app" target="_blank">
25
- <img
26
- className={`${cs.logo} ${cs.vite}`}
27
- src={viteRubySvg}
28
- alt="Vite Ruby logo"
29
- />
30
- </a>
31
- <a href="https://react.dev" target="_blank">
32
- <img
33
- className={`${cs.logo} ${cs.react}`}
34
- src={reactSvg}
35
- alt="React logo"
36
- />
37
- </a>
38
- </div>
39
-
40
- <h2 className={cs.h2}>Inertia + Vite Ruby + React</h2>
41
-
42
- <div className="card">
43
- <button
44
- className={cs.button}
45
- onClick={() => setCount((count) => count + 1)}
46
- >
47
- count is {count}
48
- </button>
12
+ <div className={cs.root}>
13
+ <Head title="Ruby on Rails + Inertia + React" />
14
+
15
+ <nav className={cs.subNav}>
16
+ <a href="https://rubyonrails.org" target="_blank">
17
+ <img className={`${cs.logo} ${cs.rails}`} alt="Ruby on Rails Logo" src={railsSvg} />
18
+ </a>
19
+ <a href="https://inertia-rails.dev" target="_blank">
20
+ <img className={`${cs.logo} ${cs.inertia}`} src={inertiaSvg} alt="Inertia logo" />
21
+ </a>
22
+ <a href="https://react.dev" target="_blank">
23
+ <img
24
+ className={`${cs.logo} ${cs.react}`}
25
+ src={reactSvg}
26
+ alt="React logo"
27
+ />
28
+ </a>
29
+ </nav>
30
+
31
+ <div className={cs.footer}>
32
+ <div className={cs.card}>
49
33
  <p>
50
- Edit <code>app/frontend/pages/inertia_example/index.jsx</code> and save to
51
- test HMR
34
+ Edit <code><%= js_destination_path %>/pages/inertia_example/index.jsx</code> and save to test <abbr title="Hot Module Replacement">HMR</abbr>.
52
35
  </p>
53
36
  </div>
54
- <p className={cs.readTheDocs}>
55
- Click on the Inertia, Vite Ruby, and React logos to learn more
56
- </p>
37
+
38
+ <ul>
39
+ <li>
40
+ <ul>
41
+ <li><strong>Rails version:</strong> {rails_version}</li>
42
+ <li><strong>Rack version:</strong> {rack_version}</li>
43
+ </ul>
44
+ </li>
45
+ <li><strong>Ruby version:</strong> {ruby_version}</li>
46
+ <li>
47
+ <ul>
48
+ <li><strong>Inertia Rails version:</strong> {inertia_rails_version}</li>
49
+ <li><strong>React version:</strong> {react_version}</li>
50
+ </ul>
51
+ </li>
52
+ </ul>
57
53
  </div>
58
- </>
54
+ </div>
59
55
  )
60
56
  }
@@ -1,60 +1,52 @@
1
1
  .root {
2
- font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
- line-height: 1.5;
2
+ box-sizing: border-box;
3
+ margin: 0;
4
+ padding: 0;
5
+ align-items: center;
6
+ background-color: #F0E7E9;
7
+ background-image: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjEwMjQiIHZpZXdCb3g9IjAgMCAxNDQwIDEwMjQiIHdpZHRoPSIxNDQwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Im0xNDQwIDUxMC4wMDA2NDh2LTUxMC4wMDA2NDhoLTE0NDB2Mzg0LjAwMDY0OGM0MTcuMzExOTM5IDEzMS4xNDIxNzkgODkxIDE3MS41MTMgMTQ0MCAxMjZ6IiBmaWxsPSIjZmZmIi8+PC9zdmc+);
8
+ background-position: center center;
9
+ background-repeat: no-repeat;
10
+ background-size: cover;
11
+ color: #261B23;
12
+ display: flex;
13
+ flex-direction: column;
14
+ font-family: Sans-Serif;
15
+ font-size: calc(0.9em + 0.5vw);
16
+ font-style: normal;
4
17
  font-weight: 400;
5
- color: #213547;
6
- background-color: #ffffff;
7
- max-width: 1280px;
8
- margin: 0 auto;
9
- padding: 2rem;
18
+ justify-content: center;
19
+ line-height: 1.25;
20
+ min-height: 100vh;
10
21
  text-align: center;
11
22
  }
12
23
 
13
- .h1 {
14
- font-size: 3.2em;
15
- line-height: 1.1;
16
- }
17
-
18
- .h2 {
19
- font-size: 2.6em;
20
- line-height: 1.1;
21
- }
22
-
23
- .button {
24
- border-radius: 8px;
25
- border: 1px solid transparent;
26
- padding: 0.6em 1.2em;
27
- font-size: 1em;
28
- font-weight: 500;
29
- font-family: inherit;
30
- background-color: #f9f9f9;
31
- cursor: pointer;
32
- transition: border-color 0.25s;
33
- }
34
- .button:hover {
35
- border-color: #646cff;
36
- }
37
- .button:focus,
38
- .button:focus-visible {
39
- outline: 4px auto -webkit-focus-ring-color;
24
+ @media (prefers-color-scheme: dark) {
25
+ .root {
26
+ background-color: #1a1a1a;
27
+ background-image: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjEwMjQiIHZpZXdCb3g9IjAgMCAxNDQwIDEwMjQiIHdpZHRoPSIxNDQwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Im0xNDQwIDUxMC4wMDA2NDh2LTUxMC4wMDA2NDhoLTE0NDB2Mzg0LjAwMDY0OGM0MTcuMzExOTM5IDEzMS4xNDIxNzkgODkxIDE3MS41MTMgMTQ0MCAxMjZ6IiBmaWxsPSIjMzMzIi8+PC9zdmc+);
28
+ color: #e0e0e0;
29
+ }
40
30
  }
41
31
 
42
32
  .logo {
43
33
  display: inline-block;
44
- height: 6em;
34
+ height: 9.8vw;
35
+ min-height: 130px;
45
36
  padding: 1.5em;
46
37
  will-change: filter;
47
38
  transition: filter 300ms;
39
+ filter: drop-shadow(0 20px 13px rgb(0 0 0 / 0.03)) drop-shadow(0 8px 5px rgb(0 0 0 / 0.08));
48
40
  }
49
- .logo:hover {
41
+ .logo.inertia:hover {
50
42
  filter: drop-shadow(0 0 2em #646cffaa);
51
43
  }
52
- .logo.vite:hover {
53
- filter: drop-shadow(0 0 2em #e4023baa);
54
- }
55
44
  .logo.react:hover {
56
45
  filter: drop-shadow(0 0 2em #61dafbaa);
57
46
  }
47
+ .logo.rails:hover {
48
+ filter: drop-shadow(0 0 2em rgb(211 0 1 / 0.6));
49
+ }
58
50
 
59
51
  @keyframes logo-spin {
60
52
  from {
@@ -71,10 +63,40 @@
71
63
  }
72
64
  }
73
65
 
66
+ @media (prefers-color-scheme: dark) {
67
+ .logo {
68
+ filter: drop-shadow(0 20px 13px rgb(255 255 255 / 0.03)) drop-shadow(0 8px 5px rgb(255 255 255 / 0.08));
69
+ }
70
+ }
71
+
74
72
  .card {
75
73
  padding: 2em;
74
+ font-size: 0.7em;
75
+ color: #948e90;
76
+ }
77
+
78
+ .footer {
79
+ bottom: 0;
80
+ left: 0;
81
+ margin: 0 2rem 2rem 2rem;
82
+ position: absolute;
83
+ right: 0;
84
+ }
85
+
86
+ .footer ul {
87
+ list-style: none;
88
+ }
89
+
90
+ .footer ul li {
91
+ display: inline;
92
+ }
93
+
94
+ .footer ul ul li:after {
95
+ content: " | ";
96
+ font-weight: 300;
97
+ color: #948e90;
76
98
  }
77
99
 
78
- .read-the-docs {
79
- color: #888;
100
+ .footer ul ul li:last-child:after {
101
+ content: "";
80
102
  }
@@ -1,60 +1,59 @@
1
1
  import { Head } from '@inertiajs/react'
2
- import { useState } from 'react'
2
+ import { version as react_version } from 'react'
3
3
 
4
+ import railsSvg from '/assets/rails.svg'
4
5
  import inertiaSvg from '/assets/inertia.svg'
5
6
  import reactSvg from '/assets/react.svg'
6
- import viteRubySvg from '/assets/vite_ruby.svg'
7
7
 
8
8
  import cs from './index.module.css'
9
9
 
10
- export default function InertiaExample({ name }: { name: string }) {
11
- const [count, setCount] = useState(0)
12
-
10
+ export default function InertiaExample(
11
+ { rails_version, ruby_version, rack_version, inertia_rails_version }:
12
+ { rails_version: string, ruby_version: string, rack_version: string, inertia_rails_version: string }
13
+ ) {
13
14
  return (
14
- <>
15
- <Head title="Inertia + Vite Ruby + React Example" />
16
-
17
- <div className={cs.root}>
18
- <h1 className={cs.h1}>Hello {name}!</h1>
19
-
20
- <div>
21
- <a href="https://inertia-rails.dev" target="_blank">
22
- <img className={cs.logo} src={inertiaSvg} alt="Inertia logo" />
23
- </a>
24
- <a href="https://vite-ruby.netlify.app" target="_blank">
25
- <img
26
- className={`${cs.logo} ${cs.vite}`}
27
- src={viteRubySvg}
28
- alt="Vite Ruby logo"
29
- />
30
- </a>
31
- <a href="https://react.dev" target="_blank">
32
- <img
33
- className={`${cs.logo} ${cs.react}`}
34
- src={reactSvg}
35
- alt="React logo"
36
- />
37
- </a>
38
- </div>
39
-
40
- <h2 className={cs.h2}>Inertia + Vite Ruby + React</h2>
41
-
42
- <div className="card">
43
- <button
44
- className={cs.button}
45
- onClick={() => setCount((count) => count + 1)}
46
- >
47
- count is {count}
48
- </button>
15
+ <div className={cs.root}>
16
+ <Head title="Ruby on Rails + Inertia + React" />
17
+
18
+ <nav className={cs.subNav}>
19
+ <a href="https://rubyonrails.org" target="_blank">
20
+ <img className={`${cs.logo} ${cs.rails}`} alt="Ruby on Rails Logo" src={railsSvg} />
21
+ </a>
22
+ <a href="https://inertia-rails.dev" target="_blank">
23
+ <img className={`${cs.logo} ${cs.inertia}`} src={inertiaSvg} alt="Inertia logo" />
24
+ </a>
25
+ <a href="https://react.dev" target="_blank">
26
+ <img
27
+ className={`${cs.logo} ${cs.react}`}
28
+ src={reactSvg}
29
+ alt="React logo"
30
+ />
31
+ </a>
32
+ </nav>
33
+
34
+ <div className={cs.footer}>
35
+ <div className={cs.card}>
49
36
  <p>
50
- Edit <code>app/frontend/pages/inertia_example/index.tsx</code> and save to
51
- test HMR
37
+ Edit <code><%= js_destination_path %>/pages/inertia_example/index.jsx</code> and save to test <abbr title="Hot Module Replacement">HMR</abbr>.
52
38
  </p>
53
39
  </div>
54
- <p className={cs.readTheDocs}>
55
- Click on the Inertia, Vite Ruby, and React logos to learn more
56
- </p>
40
+
41
+ <ul>
42
+ <li>
43
+ <ul>
44
+ <li><strong>Rails version:</strong> {rails_version}</li>
45
+ <li><strong>Rack version:</strong> {rack_version}</li>
46
+ </ul>
47
+ </li>
48
+ <li><strong>Ruby version:</strong> {ruby_version}</li>
49
+ <li>
50
+ <ul>
51
+ <li><strong>Inertia Rails version:</strong> {inertia_rails_version}</li>
52
+ <li><strong>React version:</strong> {react_version}</li>
53
+ </ul>
54
+ </li>
55
+ </ul>
57
56
  </div>
58
- </>
57
+ </div>
59
58
  )
60
59
  }
@@ -41,7 +41,7 @@ createInertiaApp({
41
41
 
42
42
  defaults: {
43
43
  form: {
44
- forceIndicesArrayFormatInFormData: true,
44
+ forceIndicesArrayFormatInFormData: false,
45
45
  },
46
46
  future: {
47
47
  useDataInertiaHeadAttribute: true,
@@ -14,7 +14,7 @@ void createInertiaApp({
14
14
  // progress: false,
15
15
 
16
16
  resolve: (name) => {
17
- const pages = import.meta.glob<ResolvedComponent>('../pages/**/*.tsx', {
17
+ const pages = import.meta.glob<{default: ResolvedComponent}>('../pages/**/*.tsx', {
18
18
  eager: true,
19
19
  })
20
20
  const page = pages[`../pages/${name}.tsx`]
@@ -26,7 +26,7 @@ void createInertiaApp({
26
26
  // and use the following line.
27
27
  // see https://inertia-rails.dev/guide/pages#default-layouts
28
28
  //
29
- // page.default.layout ||= (page) => (<Layout>{page}</Layout>)
29
+ // page.default.layout ||= (page: ReactNode) => (<Layout>{page}</Layout>)
30
30
 
31
31
  return page
32
32
  },
@@ -41,7 +41,7 @@ void createInertiaApp({
41
41
 
42
42
  defaults: {
43
43
  form: {
44
- forceIndicesArrayFormatInFormData: true,
44
+ forceIndicesArrayFormatInFormData: false,
45
45
  },
46
46
  future: {
47
47
  useDataInertiaHeadAttribute: true,