Skip to content

Commit ad13755

Browse files
committed
Initial implementation of next button
1 parent b539a50 commit ad13755

File tree

3 files changed

+36
-29
lines changed

3 files changed

+36
-29
lines changed

src/haz3lweb/app/editors/mode/TutorialsMode.re

+2
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ module Update = {
208208
let update =
209209
(~globals: Globals.t, ~schedule_action, action: t, model: Model.t) => {
210210
switch (action) {
211+
| Tutorial(TutorialMode.Update.MoveToNextExercise) =>
212+
Model.{current: model.current + 1, exercises: model.exercises} |> return
211213
| Tutorial(action) =>
212214
let current = List.nth(model.exercises, model.current);
213215
let* new_current =

src/haz3lweb/view/TutorialMode.re

+17-19
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,16 @@ module Update = {
8888
: Updated.t(Model.t) => {
8989
let instructor_mode = settings.instructor_mode;
9090
switch (action) {
91+
// This MoveToNextExercise is only here so that Tutorial(TutorialMode.Update.MoveToNextExercise)
92+
// is called in TutorialsMode. This is a dummy update because this function requires Updated(Model.t)
9193
| MoveToNextExercise =>
92-
let total_exercises = List.length(TutorialSettings.exercises);
93-
94-
/* Prevent division by zero */
95-
let next_index =
96-
if (total_exercises == 0) {
97-
0;
98-
} else {
99-
(model.spec.version + 1) mod total_exercises;
100-
};
101-
let updated_spec = {...model.spec, version: next_index};
102-
103-
/* Return the properly wrapped model */
104-
return(
105-
~is_edit=true,
106-
~recalculate=true, /* Forces UI to refresh */
107-
~scroll_active=true,
108-
~logged=true,
109-
{...model, spec: updated_spec} /* Update spec with new version */
110-
);
94+
Updated.return_quiet({
95+
...model,
96+
editors: {
97+
...model.editors,
98+
show_report: model.editors.show_report,
99+
},
100+
})
111101
| Editor(pos, MainEditor(action))
112102
when Tutorial.visible_in(pos, ~instructor_mode) =>
113103
// Redirect to editors
@@ -461,6 +451,14 @@ module View = {
461451
),
462452
],
463453
),
454+
div(
455+
~attrs=[Attr.class_("next-button")],
456+
[
457+
Widgets.button(Icons.forward, _ =>
458+
inject(MoveToNextExercise)
459+
),
460+
],
461+
),
464462
],
465463
);
466464
} else {

src/haz3lweb/www/style/tutorial-mode.css

+17-10
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@
329329

330330
#main.Tutorial .title-cell {
331331
display: flex;
332-
align-items: flex-start; /* Align to the left */
332+
align-items: flex-start;
333+
/* Align to the left */
333334
justify-content: flex-start;
334335
width: 100%;
335336
padding: 0 !important;
@@ -363,10 +364,11 @@
363364
margin-bottom: 2em !important;
364365
padding: 0 !important;
365366
}
367+
366368
#main.Tutorial .tutorial-content {
367369
display: flex;
368370
flex-direction: column;
369-
gap: 2em;
371+
gap: 2em;
370372
}
371373

372374
/* .cross {
@@ -382,7 +384,8 @@
382384
width: 80px;
383385
height: 80px;
384386
color: black;
385-
background-color: #838282;;
387+
background-color: #838282;
388+
;
386389
border-radius: 50%;
387390
display: flex;
388391
justify-content: center;
@@ -426,29 +429,32 @@
426429
}
427430

428431
.cross:hover::after {
429-
opacity: 1; /* Show on hover */
432+
opacity: 1;
433+
/* Show on hover */
430434
}
431435

432436
.cross {
433-
position: relative;
437+
position: relative;
434438
}
435439

436440
.your-impl-wrapper {
437-
margin-bottom: 1em; /* or try 1.5em for bigger space */
441+
margin-bottom: 1em;
442+
/* or try 1.5em for bigger space */
438443
}
439444

440445
.hint-with-icon {
441446
display: flex;
442447
align-items: center;
443-
gap: 0.4em; /* space between text and icon */
448+
gap: 0.4em;
449+
/* space between text and icon */
444450
font-size: 0.9em;
445451
color: #333;
446452
align-content: right;
447453
/* margin-top: 0.5em; */
448454
}
449455

450456
.highlight-icon svg {
451-
fill: var(--ci-icon-bkg) !important;
457+
fill: var(--ci-icon-bkg) !important;
452458
}
453459

454460
/* .highlight-icon {
@@ -458,10 +464,11 @@
458464
} */
459465

460466
.hint-content code {
461-
font-size: 0.75em; /* Smaller font for code blocks */
467+
font-size: 0.75em;
468+
/* Smaller font for code blocks */
462469
font-family: monospace;
463470
background-color: #f5f5f5;
464471
padding: 1px 1px;
465472
/* border-radius: 3px; */
466-
line-height: 0;
473+
line-height: 0;
467474
}

0 commit comments

Comments
 (0)