diff --git a/assets/controllers/hamburger_controller.js b/assets/controllers/hamburger_controller.js new file mode 100644 index 0000000..a6bec13 --- /dev/null +++ b/assets/controllers/hamburger_controller.js @@ -0,0 +1,48 @@ +import { Controller } from '@hotwired/stimulus'; + +/* +* The following line makes this controller "lazy": it won't be downloaded until needed +* See https://symfony.com/bundles/StimulusBundle/current/index.html#lazy-stimulus-controllers +*/ + +/* stimulusFetch: 'lazy' */ +export default class extends Controller { + static outlets = ['navbar'] + + initialize() { + // Called once when the controller is first instantiated (per element) + + // Here you can initialize variables, create scoped callables for event + // listeners, instantiate external libraries, etc. + // this._fooBar = this.fooBar.bind(this) + } + + connect() { + // Called every time the controller is connected to the DOM + // (on page load, when it's added to the DOM, moved in the DOM, etc.) + + // Here you can add event listeners on the element or target elements, + // add or remove classes, attributes, dispatch custom events, etc. + // this.fooTarget.addEventListener('click', this._fooBar) + } + + navbarOutletConnected(outlet) { + console.log(outlet) + } + + toggleMenu() { + console.log(this.navbarOutlet); + this.navbarOutlet.toggle(); + } + + // Add custom controller actions here + // fooBar() { this.fooTarget.classList.toggle(this.bazClass) } + + disconnect() { + // Called anytime its element is disconnected from the DOM + // (on page change, when it's removed from or moved in the DOM, etc.) + + // Here you should remove all event listeners added in "connect()" + // this.fooTarget.removeEventListener('click', this._fooBar) + } +} diff --git a/assets/controllers/navbar_controller.js b/assets/controllers/navbar_controller.js index 08e6df2..e12e217 100644 --- a/assets/controllers/navbar_controller.js +++ b/assets/controllers/navbar_controller.js @@ -17,9 +17,15 @@ export default class extends Controller { link.className = this.activeStyles; } }); + + window.addEventListener("resize", (event) => { + + }); } - setActive() { - + toggle() { + this.element.parentElement.classList.toggle('hidden'); + this.element.classList.toggle('fixed'); + this.element.classList.toggle('z-20'); } } diff --git a/importmap.php b/importmap.php index 3db9e68..1024843 100644 --- a/importmap.php +++ b/importmap.php @@ -40,4 +40,11 @@ return [ 'stimulus-use' => [ 'version' => '0.52.2', ], + 'animate.css' => [ + 'version' => '4.1.1', + ], + 'animate.css/animate.min.css' => [ + 'version' => '4.1.1', + 'type' => 'css', + ], ]; diff --git a/templates/components/Header.html.twig b/templates/components/Header.html.twig index 4b218bb..511e00e 100644 --- a/templates/components/Header.html.twig +++ b/templates/components/Header.html.twig @@ -13,7 +13,11 @@ -
  • +
  • diff --git a/templates/components/NavBar.html.twig b/templates/components/NavBar.html.twig index b3ec522..ee63d4b 100644 --- a/templates/components/NavBar.html.twig +++ b/templates/components/NavBar.html.twig @@ -1,4 +1,4 @@ -