guided_tour 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 34caeb0b7eb9107de61ce073bc57113b2a78b1c814845e37f60dc20a2d695b33
4
+ data.tar.gz: 14cb5604d87c7c09e3c69b51aaa5cc3cc6a89d446662ff76269f56be05d13713
5
+ SHA512:
6
+ metadata.gz: ba8083446e4a314a2d4a7385f4813e5a2149ef3c0e6adf12212c611c9c722ae7ae1115d641da821008b5c11e629b602c9ec73421a0d77703d4c3b7cf1a78d9c9
7
+ data.tar.gz: bdd249f0f7dad550a40ec913fba847cc88c3839319f3752b7ead1e41272b93e1894825e82fc4bbdab1a4c7c092470882924c946d01fd3385455c9d086100ddf1
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright Benjamin Deutscher
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # GuidedTour
2
+
3
+ A simple Stimulus controller and a helper that enables you to show a guided tour overlay on your website. It requires Bootstrap to be installed and have Popover loaded.
4
+
5
+ This gem comes with the npm package [@itsbede/guided-tour](https://www.npmjs.com/package/@itsbede/guided-tour) that is installed and included into your apps `app/javascript/controller/application.js` by running the installer.
6
+
7
+ ## Requirements
8
+
9
+ - Rails >= 7.1
10
+ - stimulus-rails
11
+ - jsbundling-rails with esbuild
12
+ - Node.js & Yarn
13
+
14
+ ## Installation
15
+
16
+ 1. Add to your Gemfile:
17
+ ```ruby
18
+ gem 'guided_tour'
19
+ ```
20
+ 2. Run installer
21
+ ```bash
22
+ ./bin/rails guided_tour:install
23
+ ```
24
+
25
+ ## Usage
26
+ In your view
27
+ ```html
28
+ <!-- this is the example markup of you page that you want to guide the user through -->
29
+ <ul>
30
+ <li id="foo">Foo</li>
31
+ <li id="bar">Bar</li>
32
+ <li id="baz">Baz</li>
33
+ </ul>
34
+
35
+ <!-- this is the gems helper code -->
36
+ <%= guide_through(t('home.guide')) %>
37
+
38
+ <!-- if you like to go hardcoded you can hand in the map directly -->
39
+ <%= guide_through(
40
+ { foo: "This is explanation for the element with the html id foo",
41
+ bar: "This is explanation for the element with the html id bar",
42
+ baz: "This is explanation for the element with the html id baz" }
43
+ ) %>
44
+ ```
45
+
46
+ In your locale .yml
47
+ ```yaml
48
+ # config/locales/en.yml
49
+ ---
50
+ en:
51
+ # ...
52
+ home:
53
+ guide:
54
+ foo: This is explanation for the element with the html id foo
55
+ bar: This is explanation for the element with the html id bar
56
+ baz: This is explanation for the element with the html id baz
57
+ # ...
58
+ ```
59
+
60
+ ## Customization
61
+
62
+ You can customize the header and the navigation buttons of the popover by defining this keys in your locale .yml
63
+
64
+ ```yaml
65
+ en:
66
+ guided-tour:
67
+ next-btn-text: "Your custom Next button text"
68
+ prev-btn-text: "Your custom Back button text"
69
+ done-btn-text: "Your custom Done button text"
70
+ step-line: "Step {{current}} of {{total}}"
71
+
72
+ de:
73
+ guided-tour:
74
+ next-btn-text: "Weiter"
75
+ prev-btn-text: "Zurück"
76
+ done-btn-text: "Fertig"
77
+ step-line: "Erklärung {{current}} von {{total}}"
78
+ ```
79
+
80
+ Make sure to include `{{current}}` and `{{total}}` in your `step-line` key to have the progress of the tour shown.
81
+
82
+ ## License
83
+
84
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuidedTour
4
+ class ApplicationController < ActionController::Base
5
+ end
6
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuidedTour
4
+ module ApplicationHelper
5
+ # Generate guided tour markup
6
+ # @param map [Hash] target element ids as keys, explantions as values
7
+ # @return [String] the html markups as html_safe
8
+ def guide_through(map)
9
+ tag.div(class: 'guided-tour--wrapper', data: {
10
+ controller: 'guided-tour--tour',
11
+ guided_tour__tour_next_btn_text_value: t('guided-tour.next-btn-text'),
12
+ guided_tour__tour_prev_btn_text_value: t('guided-tour.prev-btn-text'),
13
+ guided_tour__tour_done_btn_text_value: t('guided-tour.done-btn-text'),
14
+ guided_tour__tour_step_line_text_value: t('guided-tour.step-line')
15
+ }) do
16
+ safe_join([
17
+ tag.div(class: 'guided-tour--starter-btn-wrapper') do
18
+ safe_join([
19
+ tag.button(type: 'button', class: 'btn btn-primary ms-auto', id: 'guidedTourStarterBtn') do
20
+ safe_join([
21
+ tag.i(class: 'bi bi-lightbulb'),
22
+ '&nbsp;'.html_safe,
23
+ t('guided-tour.starter-button-text')
24
+ ])
25
+ end
26
+ ])
27
+ end,
28
+ tag.div(class: 'guided-tour--overlay', data: {
29
+ guided_tour__tour_target: 'overlay',
30
+ bs_container: 'body',
31
+ bs_toggle: 'popover',
32
+ bs_placement: 'bottom',
33
+ bs_content: ''
34
+ }),
35
+ tag.ol(class: 'd-none') do
36
+ safe_join(
37
+ map.map do |id, guide_text|
38
+ tag.li(guide_text, data: {
39
+ guided_tour__tour_target: 'explanation',
40
+ target_element: id
41
+ })
42
+ end
43
+ )
44
+ end
45
+ ])
46
+ end.html_safe
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ de:
3
+ guided-tour:
4
+ next-btn-text: "Weiter"
5
+ prev-btn-text: "Zurück"
6
+ done-btn-text: "Fertig"
7
+ step-line: "Erklärung {{current}} von {{total}}"
@@ -0,0 +1,7 @@
1
+ ---
2
+ en:
3
+ guided-tour:
4
+ next-btn-text: "Next"
5
+ prev-btn-text: "Back"
6
+ done-btn-text: "Done"
7
+ step-line: "Step {{current}} of {{total}}"
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/generators/guided_tour/install/install_generator.rb
4
+ module GuidedTour
5
+ module Generators
6
+ class InstallGenerator < Rails::Generators::Base
7
+
8
+ def check_dependencies
9
+ unless File.exist?("app/javascript/controllers/index.js")
10
+ say "Installing stimulus-rails...", :green
11
+ run "rails stimulus:install"
12
+ end
13
+ end
14
+
15
+ def add_javascript
16
+ if File.exist?("config/importmap.rb")
17
+ append_to_file "config/importmap.rb" do
18
+ 'pin "@itsbede/guided-tour"'
19
+ end
20
+ end
21
+
22
+ if File.exist?("package.json")
23
+ run "yarn add @itsbede/guided-tour"
24
+ end
25
+ end
26
+
27
+ def add_controller_to_application_js
28
+ inject_into_file "app/javascript/controllers/application.js",
29
+ before: "export { application }" do
30
+ <<~JAVASCRIPT
31
+ import GuidedTourController from "@itsbede/guided-tour"
32
+ application.register('guided-tour--tour', GuidedTourController)
33
+
34
+ JAVASCRIPT
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/guided_tour/engine.rb
4
+ module GuidedTour
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace GuidedTour
7
+
8
+ # Verify dependencies are installed
9
+ config.after_initialize do |_app|
10
+ begin
11
+ require "stimulus-rails"
12
+ rescue LoadError
13
+ raise "GuidedTour requires stimulus-rails to be installed. Add `gem 'stimulus-rails'` to your Gemfile."
14
+ end
15
+
16
+ # Only check for package.json in non-test environments
17
+ unless Rails.env.test?
18
+ unless File.exist?(Rails.root.join("package.json"))
19
+ raise "GuidedTour requires jsbundling-rails to be installed. Run `rails javascript:install:esbuild`"
20
+ end
21
+ end
22
+ end
23
+
24
+ # Initialize locales
25
+ initializer "guided_tour.locales" do |app|
26
+ app.config.i18n.load_path += Dir[
27
+ Engine.root.join("config", "locales", "**", "*.{rb,yml}").to_s
28
+ ]
29
+ end
30
+
31
+ initializer 'guided_tour.action_controller' do
32
+ ActiveSupport.on_load :action_controller do
33
+ helper GuidedTour::ApplicationHelper
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuidedTour
4
+ # update this version number when the used Rails version changes
5
+ MAJOR = 1
6
+ MINOR = 0
7
+ TINY = 0
8
+ PRE = nil
9
+
10
+ VERSION = [MAJOR, MINOR, TINY, PRE].compact.join(".")
11
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "guided_tour/version"
4
+ require "guided_tour/engine"
5
+
6
+ module GuidedTour
7
+ # Your code goes here...
8
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guided_tour
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin Deutscher
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '7.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionview
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '7.1'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '8.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '7.1'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '8.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: activesupport
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '7.1'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '8.0'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '7.1'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '8.0'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rails-i18n
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '7.0'
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '8.0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '7.0'
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: '8.0'
87
+ - !ruby/object:Gem::Dependency
88
+ name: stimulus-rails
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ type: :runtime
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ - !ruby/object:Gem::Dependency
102
+ name: minitest
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '5.0'
108
+ type: :development
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: '5.0'
115
+ - !ruby/object:Gem::Dependency
116
+ name: sqlite3
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ - !ruby/object:Gem::Dependency
130
+ name: jsbundling-rails
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ description: When building UIs for 'non tech people' things tend to get difficult
144
+ to explain since some people do not know terms like button, select, etc. guided-tour
145
+ helps with that.
146
+ email:
147
+ - ben@bdeutscher.org
148
+ executables: []
149
+ extensions: []
150
+ extra_rdoc_files: []
151
+ files:
152
+ - MIT-LICENSE
153
+ - README.md
154
+ - Rakefile
155
+ - app/controllers/guided_tour/application_controller.rb
156
+ - app/helpers/guided_tour/application_helper.rb
157
+ - config/locales/de.yml
158
+ - config/locales/en.yml
159
+ - lib/generators/guided_tour/install/install_generator.rb
160
+ - lib/guided_tour.rb
161
+ - lib/guided_tour/engine.rb
162
+ - lib/guided_tour/version.rb
163
+ homepage: https://github.com/its-bede/guided-tour
164
+ licenses:
165
+ - MIT
166
+ metadata:
167
+ homepage_uri: https://github.com/its-bede/guided-tour
168
+ source_code_uri: https://github.com/its-bede/guided-tour
169
+ changelog_uri: https://github.com/its-bede/guided-tourblob/main/CHANGELOG.md
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ requirements: []
185
+ rubygems_version: 3.5.21
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Gem to guide users through the UI and explain things.
189
+ test_files: []