-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d41e19f
commit 0b0320c
Showing
5 changed files
with
276 additions
and
63 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,52 @@ | ||
import { Component, linkEvent } from "inferno"; | ||
|
||
interface DropdownProps { | ||
button: any | ||
children: any | ||
} | ||
|
||
interface DropdownState { | ||
showDropdown : boolean | ||
} | ||
|
||
export class Dropdown extends Component<DropdownProps, DropdownState> { | ||
private emptyState: DropdownState = { | ||
showDropdown: false, | ||
}; | ||
|
||
constructor(props: any, context: any) { | ||
super(props, context); | ||
this.state = this.emptyState; | ||
} | ||
|
||
render() { | ||
return ( | ||
<> | ||
<span className="dropdown"> | ||
<button className="btn btn-link dropdown-toggle" | ||
onClick={linkEvent(this, this.handleToggleDropdown)} | ||
role="button" | ||
type="button" | ||
aria-expanded="false">{this.props.button}</button> | ||
{this.state.showDropdown && ( | ||
<div | ||
class="dropdown-content navbar-nav" | ||
onMouseLeave={linkEvent( | ||
this, | ||
this.handleToggleDropdown | ||
)} | ||
> | ||
{this.props.children} | ||
</div> | ||
)} | ||
</span> | ||
</> | ||
); | ||
} | ||
|
||
handleToggleDropdown(i: Dropdown, event: any) { | ||
event.preventDefault(); | ||
i.state.showDropdown = !i.state.showDropdown; | ||
i.setState(i.state); | ||
} | ||
} |
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
Oops, something went wrong.