-
-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor stimulus nav controllers to follow stimulus best practices. (#…
…4422) Remove unused javascript from nav.
- Loading branch information
1 parent
551149a
commit 11c620b
Showing
7 changed files
with
81 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
// I tested the stimulus-dropdown component but it has too many deps. | ||
// This mimics the basic stimulus-dropdown api, so we could swap it in later. | ||
export default class extends Controller { | ||
static targets = ["menu"] | ||
|
||
hide(e) { | ||
!this.element.contains(e.target) && | ||
!this.menuTarget.classList.contains("hidden") && | ||
this.menuTarget.classList.add('hidden'); | ||
} | ||
|
||
toggle(e) { | ||
e.preventDefault(); | ||
this.menuTarget.classList.toggle('hidden'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters