・ Ruby: 2.5.7 Rails: 5.2.4 ・ Vagrant: 2.2.7 -VirtualBox: 6.1 ・ OS: macOS Catalina
The following has been implemented.
・ Slim introduction ・ Implementation of posting function
Code
.Terminal
$ git clone [email protected]:usablica/intro.js.git
and ʻintrojs.css
in the cloned directory into the application.Gemfile
#Postscript
gem 'jquery-rails'
Terminal
$ bundle
application.js
//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require jquery //Postscript
//= require_tree .
Terminal
touch app/assets/javascripts/tutorial.js
tutorial.js
$(function() {
$('#tutorial').click(function() {
introJs()
.setOptions({
nextLabel: 'Next →',
prevLabel: '← Previous',
skipLabel: 'skip',
doneLabel: 'End',
exitOnOverlayClick: false,
showStepNumbers: false,
steps: [
{
intro:
'<b>Welcome to Bookers!</b><br>I will briefly introduce how to use Books!',
},
{
element: '#introjs-step1',
intro: 'Please enter a title',
},
{
element: '#introjs-step2',
intro: 'Please enter the text',
},
{
element: '#introjs-step3',
intro: 'You can post a book by pressing the "Post" button.',
},
],
})
.start();
});
});
tutorial
.$('#tutorial').click(function() {}
.setOptions({})
nextLabel: 'Next →',
prevLabel: '← Previous',
skipLabel: 'skip',
doneLabel: 'End',
exitOnOverlayClick: false,
showStepNumbers: false,
steps: []
** ◎ When ʻelement` is not set **
{
intro: 'This is a tutorial.',
}
It is displayed in the center of the screen.
** ◎ When element is set **
{
element: '#introjs-step1',
intro: 'Please enter a title.',
}
It is displayed focusing on the HTML corresponding to the set ID.
~html.slim
button id='tutorial'
|Tutorial start
~html.slim
= f.text_field :title, class:'form-control', id: 'introjs-step1'
DEMO
, and if you want to implement it, press SOURCE
to see the sample code.Recommended Posts