From 65e8456775d6bb38c2ce7cef2c9730ad432ec6f6 Mon Sep 17 00:00:00 2001 From: Claude Ayitey Date: Wed, 3 Jan 2024 19:47:49 +0000 Subject: [PATCH] Functions to show, hide, and handle menu. --- app/javascript/controllers/toggle_controller.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/javascript/controllers/toggle_controller.js b/app/javascript/controllers/toggle_controller.js index 071e9c3d..1849197d 100644 --- a/app/javascript/controllers/toggle_controller.js +++ b/app/javascript/controllers/toggle_controller.js @@ -4,3 +4,19 @@ export default class extends Controller { static targets = [ "menu" ] static values = {isOpen: { type: Boolean, default: false }} + connect(){} + + menu() { + this.isOpenValue ? this.hide() : this.show() + this.isOpenValue = !this.isOpenValue + } + + show() { + this.menuTarget.style.display = "block" + } + + hide() { + this.menuTarget.style.display = "none" + } + +}