rails_onboarding 0.8.14 → 0.8.16
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/app/assets/stylesheets/rails_onboarding/flash_messages.css +34 -7
- data/app/models/concerns/rails_onboarding/onboardable.rb +11 -1
- data/app/views/layouts/rails_onboarding/application.html.erb +14 -0
- data/app/views/rails_onboarding/shared/_flash.html.erb +23 -22
- data/lib/generators/rails_onboarding/templates/rails_onboarding.rb +6 -0
- data/lib/rails_onboarding/configuration.rb +6 -0
- data/lib/rails_onboarding/configuration_validator.rb +1 -0
- data/lib/rails_onboarding/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f79e357fe7c8d557e953c0c0b531e255b81b79ab2a23fe468c9c3c5d71769dd1
|
|
4
|
+
data.tar.gz: 98f0008fca60f449ae12e3d7cef03717ceb5069f91cb0038f98ccd502a87cc85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ab29b9cb21add6000d90cc9656c7ae70f31c67417c3921f1e895b1d478006c581954e4ce6b8b201b7521b64f1f22acae8a310902821392569c9926e28ad9883
|
|
7
|
+
data.tar.gz: 73564d4673ff3a1ba775153b563e45f2e78345162d0cdaa6ade4cdee2f57fc00bec13b189ab7ec92c4a1b1382a16c847aff8163b34ada2fd38017f9e0d66b597
|
|
@@ -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
|
-
/*
|
|
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: #
|
|
59
|
+
background-color: #047857;
|
|
36
60
|
color: white;
|
|
37
|
-
border-left: 4px solid #
|
|
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:
|
|
44
|
-
border-left: 4px solid #
|
|
67
|
+
color: #451a03;
|
|
68
|
+
border-left: 4px solid #b45309;
|
|
45
69
|
}
|
|
46
70
|
|
|
47
71
|
.flash-error {
|
|
48
|
-
background-color: #
|
|
72
|
+
background-color: #b91c1c;
|
|
49
73
|
color: white;
|
|
50
|
-
border-left: 4px solid #
|
|
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)
|
|
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)
|
|
@@ -48,9 +48,23 @@
|
|
|
48
48
|
<% end %>
|
|
49
49
|
|
|
50
50
|
<%= javascript_include_tag "rails_onboarding/application", "data-turbo-track": "reload", defer: true %>
|
|
51
|
+
|
|
52
|
+
<%# Host-supplied script, loaded after the engine's. Nothing else on these pages
|
|
53
|
+
loads the host's JavaScript, so without it a host whose pages need Turbo or
|
|
54
|
+
Stimulus loses both here - and a Hotwire Native app, which requires Turbo on
|
|
55
|
+
every page it shows, refuses the page outright with "Turbo is not present".
|
|
56
|
+
Deferred like the engine's, so the two run in this order. %>
|
|
57
|
+
<% if RailsOnboarding.configuration.custom_js_path.present? %>
|
|
58
|
+
<%= javascript_include_tag RailsOnboarding.configuration.custom_js_path, "data-turbo-track": "reload", defer: true %>
|
|
59
|
+
<% end %>
|
|
51
60
|
</head>
|
|
52
61
|
<body>
|
|
53
62
|
|
|
63
|
+
<%# Without this, a message on the way to onboarding was lost: a host's redirect_to with an alert,
|
|
64
|
+
the engine's own redirect_to onboarding_path, alert:, and the Turbo Stream errors, which replace
|
|
65
|
+
#flash-messages and found nothing to replace. Fixed-position, so it sits over the page. %>
|
|
66
|
+
<%= render "rails_onboarding/shared/flash" %>
|
|
67
|
+
|
|
54
68
|
<%# .onboarding-container/.onboarding-content provide the page-level
|
|
55
69
|
min-height/centering/responsive padding that the stylesheets (see
|
|
56
70
|
application.css and mobile.css) already define for every onboarding
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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>
|
|
@@ -21,6 +21,12 @@ RailsOnboarding.configure do |config|
|
|
|
21
21
|
# --onboarding-* tokens in that file rather than overriding rules.
|
|
22
22
|
# config.custom_css_path = "rails_onboarding_custom"
|
|
23
23
|
|
|
24
|
+
# Asset name of a script loaded after the engine's own on onboarding pages.
|
|
25
|
+
# Nothing else loads your JavaScript there, so name your application bundle
|
|
26
|
+
# if those pages need Turbo or Stimulus - a Hotwire Native app always does,
|
|
27
|
+
# and shows "Turbo is not present" instead of the page without it.
|
|
28
|
+
# config.custom_js_path = "application"
|
|
29
|
+
|
|
24
30
|
# Feature toggles
|
|
25
31
|
config.enable_tooltips = true
|
|
26
32
|
config.enable_milestones = true
|
|
@@ -59,6 +59,12 @@ module RailsOnboarding
|
|
|
59
59
|
# app/assets/stylesheets/rails_onboarding_custom.css; set this to
|
|
60
60
|
# "rails_onboarding_custom" to actually load it. nil = load nothing.
|
|
61
61
|
@custom_css_path = nil
|
|
62
|
+
|
|
63
|
+
# Asset name of a host script to load after the engine's own on onboarding
|
|
64
|
+
# pages - typically the host's "application" bundle, which is what brings
|
|
65
|
+
# Turbo and Stimulus. Required for a Hotwire Native app, which refuses any
|
|
66
|
+
# page without Turbo. nil = load nothing.
|
|
67
|
+
@custom_js_path = nil
|
|
62
68
|
@redirect_after_completion = :root_path
|
|
63
69
|
@redirect_after_skip = :root_path
|
|
64
70
|
@welcome_heading = "We're excited to have you here!"
|
|
@@ -55,6 +55,7 @@ module RailsOnboarding
|
|
|
55
55
|
validate_type(:user_class_name, [ String ], "user_class_name must be a String")
|
|
56
56
|
validate_type(:include_host_styles, [ TrueClass, FalseClass ], "include_host_styles must be a Boolean")
|
|
57
57
|
validate_type(:custom_css_path, [ String ], "custom_css_path must be a String")
|
|
58
|
+
validate_type(:custom_js_path, [ String ], "custom_js_path must be a String")
|
|
58
59
|
validate_type(:enable_tooltips, [ TrueClass, FalseClass ], "enable_tooltips must be a Boolean")
|
|
59
60
|
validate_type(:enable_milestones, [ TrueClass, FalseClass ], "enable_milestones must be a Boolean")
|
|
60
61
|
validate_type(:enable_analytics, [ TrueClass, FalseClass ], "enable_analytics must be a Boolean")
|
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.
|
|
4
|
+
version: 0.8.16
|
|
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.
|
|
286
|
+
source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.16
|
|
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.
|
|
302
|
+
rubygems_version: 4.0.22
|
|
303
303
|
specification_version: 4
|
|
304
304
|
summary: Flexible onboarding engine for Rails applications
|
|
305
305
|
test_files: []
|