WebgrownSolutions

William J. Familia's Dev Garden

Drop-Down Menu

As part of a new UI library, I have built a multi-level drop-down (dropdown) menu feature using CSS and jQuery in a manner that follows the guidelines found in the Webgrown Solutions UI Manifesto. The drop-down menu supports the following features:

The Demo

        The menu above, in the header of this website, is the demo itself.
    

The Markup

Just some basic page elements (<nav>, <section>, <h1>, <ul>, <li>, <h2>, <h3>, and <a>), with a normal class attribute and some custom data (data-*) attributes to allow feature customization. Once the CSS and Script stuff are in place on a website, any page can implement the Drop-Down Menu by simply setting the top-level wrapping element (e.g. <nav> or <div>) of the menu markup with the class attribute to "dropDownMenu", and setting the desired optional custom data attributes. The custom data attributes are optional, so the accordion could simple have only the standard markup plus the class attribute.

That sounds like a DRY solution to me (see UI Manifesto).

<nav class="dropDownMenu"
    data-userEventToTriggerOpen="click">
    <section>
        <h1>UI Library</h1>
        <ul>
            <li><a href="/ui/library/accordion/">Accordion</a></li>
            <li>Autocomplete</li>
            ...
            <li><a href="/ui/library/datetimetextbox/">DateTime Textbox</a></li>
            <li>E-mail Textbox</li>
            <li><a href="/ui/library/grid/">Grid (data table)</a></li>
            ...
            <li>
                <h2>Menu (Drop-Down)</h2>
                <ul>
                    <li><a href="/ui/library/dropdownmenu/">Get the Menu Code</a></li>
                    <li><a href="/ui/library/dropdownmenu/#1.1">Level Two Test #1</a></li>
                    <li>
                        <h3>Level Two Test #2</h3>
                        <ul>
                            <li><a href="/ui/library/dropdownmenu/">Get the Menu Code</a></li>
                            <li><a href="/ui/library/dropdownmenu/#2.1">Level Three Test #1</a></li>
                            <li><a href="/ui/library/dropdownmenu/#2.2">Level Three Test #2</a></li>
                        </ul>
                    </li>
                    <li><a href="/ui/library/dropdownmenu/#1.3">Level Two Test #3</a></li>
                </ul>
            </li>
            ...
        </ul>
    </section>
    <section>
        <h1>Website Solutions</h1>
        <ul>
            <li>Ajax Gets</li>
            <li>Ajax Posts</li>
            <li>Authentication System</li>
            ...
        </ul>
    </section>
</nav>

The CSS

Not shown to the general public.
        

The Script

Not shown to the general public.
        
blog comments powered by Disqus

In addition to the markup, CSS, and JavaScript code samples found below the demo, the following resources/files are required:

We are processing your request.

loading...
*
Please fix the following issues and then submit again: is required. is not valid. does not match
loading...
mm/dd/yy mm/dd/yy 0 Previous Next ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'] Wk false false false h:mm tt Choose Time Time: Hour: Minute: Second: Now Done You have # character(s) remaining.