feat(): dropdown-toggle rewrite #284
Description
@bekos @pkozlowski-opensource @ajoslin, here's what I'm thinking about for a refactored dropdownToggle
directive. First, I'd propose renaming it to simply dropdown
. The markup would be very simple:
<button class="dropdown" label="Dropdown Button <span class='caret'></span>">
<ul>
<li><a href="#">Do</a></li>
<li><a href="#">Re</a></li>
<li class="divider"></li>
<li><a href="#">Mi</a></li>
</ul>
</button>
When the dropdown
directive is compiled, it would move the ul
to the outside of the button
(so it's a sibling) and set a style of display: none
, then the innerHTML
of the button
would be set to the label
attr.
When the button
is clicked, the ul
will have the display: none
style unset and the button
will receive a class of active
(could be changed via activeclass
attr, or config?)
I think this is a simple and flexible solution, and it's all self-contained. The only downside to this approach is that it assumes the dropdown element is wrapped in a relatively positioned element, e.g., a div.btn-group
.
What are your thoughts?