Last active
August 29, 2015 14:12
-
-
Save tkrugg/7ecce8199d8576e97937 to your computer and use it in GitHub Desktop.
Different option for implementing dropdown
This file contains hidden or 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
| <!-- option 1 | |
| currently implemented --> | |
| <d-dropdown> | |
| <button is=d-toggle-button>Menu ⏷ </d-toggle-button> | |
| <d-dropdown-menu> | |
| <a href="#entry-1" is=d-dropdown-entry>entry 1</a> | |
| <a href="#entry-2" is=d-dropdown-entry>entry 2</a> | |
| </d-dropdown-menu> | |
| </d-dropdown> | |
| <!-- option 2 | |
| There are a few use cases where this is not very comfortable to work with, namely | |
| - the position of the dropdown will depend of the padding/border-width of the button; | |
| - it might be bad practice to have menu aria-roles inside a button element. I'll have to check that | |
| --> | |
| <button is=d-dropdown-button>Menu ⏷ | |
| <d-dropdown-menu> | |
| <a href="#entry-1" is=d-dropdown-entry>entry 1</a> | |
| <a href="#entry-2" is=d-dropdown-entry>entry 2</a> | |
| </d-dropdown-menu> | |
| </button> | |
| <!-- option 3 | |
| same as option 1 but without the wrapper. The button and the menu are associated when they are adjacent siblings. | |
| If a d-dropdown-menu has been declared without a button before it, then it won't be associated with any button automatically, | |
| and users will have to do it in their own code. | |
| **Not sure how much of a bad idea this is**. having some sort of a binding library will certainly make this unecessary--> | |
| <button is=d-toggle-button>Menu ⏷ </d-toggle-button> | |
| <d-dropdown-menu> | |
| <a href="#entry-1" is=d-dropdown-entry>entry 1</a> | |
| <a href="#entry-2" is=d-dropdown-entry>entry 2</a> | |
| </d-dropdown-menu> | |
| <!-- option 4 | |
| This is (sort of) what we'd have to do with a binding library around of it all. | |
| chrome automatically creates a window.menu that references the DOM element. If it's the new standard way to make | |
| widgets interact with each other, this doesn't look so silly, though you'll need to declare an id for each | |
| of theses menus. | |
| --> | |
| <button is=d-toggle-button onclick="menu.toggle()">Menu ⏷ </d-toggle-button> | |
| <d-dropdown-menu id="menu"> | |
| <a href="#entry-1" is=d-dropdown-entry>entry 1</a> | |
| <a href="#entry-2" is=d-dropdown-entry>entry 2</a> | |
| </d-dropdown-menu> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm lost. I don't understand why you are trying to create a "dropdown widget" at all.
Dijit intentionally didn't have any widgets specifically designed as drop downs, but rather general widgets that could be used as dropdowns. That still seems like a good design to me, and it's how delite/HasDropDown is intended to work.