Skip to content

Commit

Permalink
adds show method to dropdown component (#80)
Browse files Browse the repository at this point in the history
* adds show method to dropdown component.

* adds descriptions for using show and hide with dropdown
  • Loading branch information
rockwellll authored Apr 30, 2021
1 parent 9ea8912 commit 65895e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ If you want a dropdown to be opened on page load you can set the ```data-dropdow
</div>
```

the code above will toggle the dropdown component, if you needed to only perform a single action, such as `show` or `hide`. the dropdown component exposes such method.

```html
data-action="click->dropdown#show"
data-action="click->dropdown#hide"
```

Animations for the dropdown menu (like the TailwindUI dropdowns) can be applied using these data attributes:

```html
Expand Down
4 changes: 4 additions & 0 deletions src/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export default class extends Controller {
this.toggle()
}
}

show(){
this.openValue = true;
}

hide(event) {
if (this.element.contains(event.target) === false && this.openValue) {
Expand Down

0 comments on commit 65895e2

Please sign in to comment.