- On click, it should open the dropdown menu
- Second click should close it
- Bonus - Optional only: Clicking outside of the button, should also close it
-
Make it look as close as possible to the expected result.
-
You need to have 4 components:
Dropdown- Wraps everythingDropdownButton- The button that opens/closes the dropdown menuDropdownMenu- The white box that appears when clickingDropdownButtonDropdownItem- An item in theDropdownMenu
The structure should look like:
<Dropdown>
<DropdownButton>Dropdown button</DropdownButton>
<DropdownMenu>
<DropdownItem>Action</DropdownItem>
<DropdownItem>Another action</DropdownItem>
<DropdownItem>Something else</DropdownItem>
</DropdownMenu>
</Dropdown>- Make it generic! The user might want to have several dropdown across his app. Take in consideration that every dropdown may contain different items.
-
Fork this repository (click on the Fork button at the top of the screen).
-
Clone this repository:
$ git clone <url> $ cd react-dropdown -
Install dependencies:
npm install -
After that's done, run this to start development:
npm start
Good luck!
