rails_onboarding 0.8.14 → 0.8.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92019b01af432fe5d1e17c6f116c224d6123f15aeda35798193a3d2a6eb46b3d
4
- data.tar.gz: ddb5d7f350286ab8512626eae34967b524dfa5284547794b801ca4d1b11fdcbc
3
+ metadata.gz: df859b74947576d40a44a8a6ce1e37ceb1c9b92297875ac06faa3926f19489cc
4
+ data.tar.gz: 360a0d59bece71c30df19f549bea51cba322b7d0abf0e657d2e77d8b4b9e9d3b
5
5
  SHA512:
6
- metadata.gz: da8ba6db11ce280647bee31ad9a718f63cb251d420d2c65d86412363db586d8d16d9c09c95e0ddd128b72bb3cbdd3903f7559391dc271339e6db32451f40405c
7
- data.tar.gz: ef5428f53020a250d118eb58316ec24dffaa06cc0e364d91fe40bf23c78f97ca56ec7ae15b928e93be7e2e3dfb4d093d2ccd3e8e6957d118df775e7285f27b6f
6
+ metadata.gz: 0fce05257f5c3f4af31cd191dc961ea151e2b753988758e53315e9914f6db67d4d22f1759ae81562b60b8bbe177a2cd3b59ddeb0f840f42ff46b0834f32b63fe
7
+ data.tar.gz: 83404bc6ac100510474a792a1ff245dbb09f53166df47325117b4f3551cacdeca9bf60dc54550d6c07794c8f371a93f9c2779dc1c48d6d1ffae01d0c4a9ef16e
@@ -8,6 +8,9 @@
8
8
  max-width: 500px;
9
9
  width: 100%;
10
10
  pointer-events: none;
11
+ /* Outside .onboarding-container, which is where the engine sets its font, so it would otherwise
12
+ take the browser's serif default. */
13
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
11
14
  }
12
15
 
13
16
  .onboarding-flash {
@@ -29,25 +32,46 @@
29
32
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
30
33
  }
31
34
 
32
- /* Flash types */
35
+ /* Each message is an open <dialog> (see shared/_flash), so it closes without JavaScript. Undo
36
+ what the browser gives a dialog - centred, absolutely placed, bordered all round - leaving the
37
+ coloured left border from the type rules below. */
38
+ dialog.onboarding-flash {
39
+ inset: auto;
40
+ margin: 0 0 12px;
41
+ width: auto;
42
+ max-width: none;
43
+ max-height: none;
44
+ border-top: 0;
45
+ border-right: 0;
46
+ border-bottom: 0;
47
+ }
48
+
49
+ /* The close form is only there for method="dialog"; its button is the flex item. */
50
+ .onboarding-flash form {
51
+ display: contents;
52
+ }
53
+
54
+ /* Flash types. Each pair is at least 4.5:1 (WCAG AA): white on the 500-weight greens, ambers and
55
+ reds these used was 2-4:1, unreadable on amber in particular. Amber keeps its colour and takes
56
+ dark text instead. */
33
57
  .flash-notice,
34
58
  .flash-success {
35
- background-color: #10b981;
59
+ background-color: #047857;
36
60
  color: white;
37
- border-left: 4px solid #059669;
61
+ border-left: 4px solid #065f46;
38
62
  }
39
63
 
40
64
  .flash-alert,
41
65
  .flash-warning {
42
66
  background-color: #f59e0b;
43
- color: white;
44
- border-left: 4px solid #d97706;
67
+ color: #451a03;
68
+ border-left: 4px solid #b45309;
45
69
  }
46
70
 
47
71
  .flash-error {
48
- background-color: #ef4444;
72
+ background-color: #b91c1c;
49
73
  color: white;
50
- border-left: 4px solid #dc2626;
74
+ border-left: 4px solid #7f1d1d;
51
75
  }
52
76
 
53
77
  .flash-info {
@@ -152,6 +176,9 @@
152
176
  right: 10px;
153
177
  left: 10px;
154
178
  max-width: none;
179
+ /* Not 100%: with both left and right set, a width overrides right, and the message ran 10px
180
+ off the screen. */
181
+ width: auto;
155
182
  }
156
183
 
157
184
  .onboarding-flash {
@@ -730,8 +730,18 @@ module RailsOnboarding
730
730
  { onboarding_replay_started_at: nil, onboarding_replay_steps: [] }
731
731
  end
732
732
 
733
+ # column_names queries the database like the rest, so it takes the same
734
+ # guard -- but purely for symmetry: this one cannot actually be reached
735
+ # with the table missing. It is an instance method, and ActiveRecord cannot
736
+ # instantiate a model whose table is absent (`new` raises while building
737
+ # attribute types), so the guard can never fire. Kept so every column query
738
+ # in this file reads the same way, and it costs nothing: table_exists?
739
+ # reads the schema cache.
733
740
  def onboarding_column?(name)
734
- self.class.respond_to?(:column_names) && self.class.column_names.include?(name)
741
+ return false unless self.class.respond_to?(:column_names)
742
+ return false unless RailsOnboarding::SchemaGuard.columns_queryable?(self.class)
743
+
744
+ self.class.column_names.include?(name)
735
745
  end
736
746
 
737
747
  def persist_and_track!(attributes = nil)
@@ -51,6 +51,11 @@
51
51
  </head>
52
52
  <body>
53
53
 
54
+ <%# Without this, a message on the way to onboarding was lost: a host's redirect_to with an alert,
55
+ the engine's own redirect_to onboarding_path, alert:, and the Turbo Stream errors, which replace
56
+ #flash-messages and found nothing to replace. Fixed-position, so it sits over the page. %>
57
+ <%= render "rails_onboarding/shared/flash" %>
58
+
54
59
  <%# .onboarding-container/.onboarding-content provide the page-level
55
60
  min-height/centering/responsive padding that the stylesheets (see
56
61
  application.css and mobile.css) already define for every onboarding
@@ -1,25 +1,26 @@
1
- <div id="flash-messages" class="flash-container">
2
- <% if defined?(notice) && notice %>
3
- <div class="onboarding-flash flash-notice" role="alert">
4
- <span class="flash-icon">✓</span>
5
- <span class="flash-message"><%= notice %></span>
6
- <button class="flash-close" onclick="this.parentElement.remove()" aria-label="Dismiss">×</button>
7
- </div>
8
- <% end %>
1
+ <%# The flash, on every page of the engine layout, and the target the onboarding controller's
2
+ Turbo Stream errors replace (#flash-messages). Each message comes from a local when one is
3
+ given - those streams pass the message they want shown - and from the flash otherwise.
9
4
 
10
- <% if defined?(alert) && alert %>
11
- <div class="onboarding-flash flash-alert" role="alert">
12
- <span class="flash-icon">⚠</span>
13
- <span class="flash-message"><%= alert %></span>
14
- <button class="flash-close" onclick="this.parentElement.remove()" aria-label="Dismiss">×</button>
15
- </div>
16
- <% end %>
17
-
18
- <% if defined?(error) && error %>
19
- <div class="onboarding-flash flash-error" role="alert">
20
- <span class="flash-icon">✕</span>
21
- <span class="flash-message"><%= error %></span>
22
- <button class="flash-close" onclick="this.parentElement.remove()" aria-label="Dismiss">×</button>
23
- </div>
5
+ Each message is an open <dialog> closed by a form with method="dialog", which the browser
6
+ handles itself: no JavaScript, so nothing for a strict Content Security Policy to refuse. The
7
+ close buttons were onclick= attributes, which such a policy blocks without a word. Turbo
8
+ leaves method="dialog" forms alone. %>
9
+ <% messages = {
10
+ notice: local_assigns.fetch(:notice) { flash[:notice] },
11
+ alert: local_assigns.fetch(:alert) { flash[:alert] },
12
+ error: local_assigns.fetch(:error) { flash[:error] }
13
+ } %>
14
+ <% icons = { notice: "✓", alert: "⚠", error: "✕" } %>
15
+ <div id="flash-messages" class="flash-container">
16
+ <% messages.each do |type, message| %>
17
+ <% next if message.blank? %>
18
+ <dialog open class="onboarding-flash flash-<%= type %>">
19
+ <span class="flash-icon" aria-hidden="true"><%= icons[type] %></span>
20
+ <span class="flash-message" role="alert"><%= message %></span>
21
+ <form method="dialog">
22
+ <button class="flash-close" aria-label="Dismiss">×</button>
23
+ </form>
24
+ </dialog>
24
25
  <% end %>
25
26
  </div>
@@ -1,3 +1,3 @@
1
1
  module RailsOnboarding
2
- VERSION = "0.8.14"
2
+ VERSION = "0.8.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_onboarding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.14
4
+ version: 0.8.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lewis
@@ -283,7 +283,7 @@ licenses:
283
283
  metadata:
284
284
  allowed_push_host: https://rubygems.org
285
285
  homepage_uri: https://github.com/bunnahabhain/rails_onboarding
286
- source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.14
286
+ source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.15
287
287
  changelog_uri: https://github.com/bunnahabhain/rails_onboarding/blob/master/docs/CHANGELOG.md
288
288
  rdoc_options: []
289
289
  require_paths:
@@ -299,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
299
299
  - !ruby/object:Gem::Version
300
300
  version: '0'
301
301
  requirements: []
302
- rubygems_version: 4.0.19
302
+ rubygems_version: 4.0.22
303
303
  specification_version: 4
304
304
  summary: Flexible onboarding engine for Rails applications
305
305
  test_files: []