diff --git a/assets/controllers/utility/show_more_controller.js b/assets/controllers/utility/show_more_controller.js new file mode 100644 index 0000000..f7510bc --- /dev/null +++ b/assets/controllers/utility/show_more_controller.js @@ -0,0 +1,19 @@ +import { Controller } from "@hotwired/stimulus"; + +export default class extends Controller { + static targets = ["preview", "full", "button"]; + + toggle(event) { + event?.preventDefault?.(); + if (this.fullTarget.style.display === "none") { + this.fullTarget.style.display = ""; + this.previewTarget.style.display = "none"; + this.buttonTarget.textContent = "Show less"; + } else { + this.fullTarget.style.display = "none"; + this.previewTarget.style.display = ""; + this.buttonTarget.textContent = "Show more"; + } + } +} + diff --git a/templates/pages/article.html.twig b/templates/pages/article.html.twig index 803c2e1..2c5e396 100644 --- a/templates/pages/article.html.twig +++ b/templates/pages/article.html.twig @@ -234,21 +234,37 @@ {{ highlight.created_at|date('M j') }} -