Skip to content

Commit 91dd343

Browse files
authored
Merge pull request #255 from ruby/claude/busy-cannon-91a92b
Disable Back and Next at the ends of the tutorial
2 parents 281add8 + 4ded389 commit 91dd343

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎app/try_ruby.rb‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ def update_screen(item)
381381
step = item.step.to_s
382382
$document.at_css("#tryruby-index").value = step
383383

384+
# Disable the buttons that have no step to go to
385+
$document.at_css('#btn_back').disabled = !@items.has_key?(item.step - 1)
386+
$document.at_css('#btn_next').disabled = !@items.has_key?(item.step + 1)
387+
384388
# Set session cookie to store progress
385389
set_cookie('tryruby_step', step)
386390

‎source/stylesheets/application.css.scss‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,13 @@ h3 {
125125
.btn-primary {
126126
border-radius: 1rem;
127127
font-family: sans-serif;
128-
color: var(--button-primary-text-color);
129-
background-color: var(--button-primary-color);
130-
border-color: var(--button-primary-color);
128+
129+
&,
130+
&:disabled {
131+
color: var(--button-primary-text-color);
132+
background-color: var(--button-primary-color);
133+
border-color: var(--button-primary-color);
134+
}
131135

132136
&:focus,
133137
&:focus:not(:focus-visible),

‎spec/tutorial_spec.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
special = steps[step] || {}
5151

5252
find(:css, "h1").text.should be == data["title"]
53+
page.should have_button("Back", disabled: step == 1)
54+
page.should have_button("Next", disabled: step == 56)
5355

5456
unless special[:pass]
5557
case special[:code]

0 commit comments

Comments
 (0)