Converted to a Go app
This commit is contained in:
parent
543c1790de
commit
d4b3322077
28 changed files with 302 additions and 1 deletions
31
public/scripts/controllers/picker.js
Normal file
31
public/scripts/controllers/picker.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { Controller } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js";
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["radio", "answerDetails"];
|
||||
|
||||
static values = {
|
||||
answer: String
|
||||
};
|
||||
|
||||
connect() {
|
||||
}
|
||||
|
||||
submitAnswer(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
this.element.classList.add("reveal");
|
||||
|
||||
window.setTimeout(() => {
|
||||
this.radioTargets.forEach(e => {
|
||||
e.disabled = true;
|
||||
if (e.value === this.answerValue) {
|
||||
e.classList.add("answer");
|
||||
} else {
|
||||
e.classList.add("wrong");
|
||||
}
|
||||
});
|
||||
}, 1);
|
||||
|
||||
this.answerDetailsTarget.classList.remove("hidden");
|
||||
}
|
||||
};
|
||||
7
public/scripts/main.js
Normal file
7
public/scripts/main.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { Application } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js";
|
||||
|
||||
import PickerController from "./controllers/picker.js";
|
||||
|
||||
window.Stimulus = Application.start();
|
||||
|
||||
Stimulus.register("picker", PickerController);
|
||||
Loading…
Add table
Add a link
Reference in a new issue