Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp Pure Menu #142

Closed
wants to merge 10 commits into from
Closed

Revamp Pure Menu #142

wants to merge 10 commits into from

Conversation

tilomitra
Copy link
Contributor

This commit makes Pure Menu smaller, more responsive, and easier to customize. This change does break back-compatibility, as I have removed some classnames and some functionality.

What's in this PR

  • Remove the close relationship with YUI's Y.Menu. This helps to get rid of a lot of CSS which wasn't needed 80% of the time.
  • Remove .pure-menu-open: This also helps to get rid of adjoining class selectors, which makes it easier to customize menus.
  • Add .pure-menu-responsive and .pure-menu-responsive-toggle to make responsive horizontal menus: Yay!
  • CSS-only dropdown support: This only supports one level of nesting but I think that should be fine for most use cases.
  • Make pure menus really easy to customize: More on this below

Responsive Horizontal Menu

This is something that I've been wanting for a while. You can now make responsive menus that can show and hide their links on small screens. Doing this is really easy, and the site will have JS snippets that you can copy/paste in to achieve the necessary behavior.

This is done by adding two new classnames, .pure-menu-responsive and .pure-menu-responsive-toggle. Since you may not want every horizontal menu to be responsive, you have to add the .pure-menu-responsive class name. Responsive menus also need an <a> element with the .pure-menu-responsive-toggle class name so that it can show/hide menu items on small screens.

HTML

Here's the HTML for a responsive menu:

    <div class="pure-menu pure-menu-horizontal pure-menu-responsive">
        <a href="#" class="pure-menu-link pure-menu-heading">Title</a>
        <a href="#" class="pure-menu-responsive-toggle">Toggle</a>
        <ul class="pure-menu-list">
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">Home</a></li>
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">About</a></li>
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">Blog</a></li>
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">Contact</a></li>
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">GitHub</a></li>
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">Twitter</a></li>
        </ul>
    </div>

That'll give you something that looks like this on small screens:

menu closed

Open State:

menu open

Dropdown Menu

Here's the HTML for a dropdown menu:

    <div class="pure-menu pure-menu-horizontal pure-menu-responsive">
        <a href="#" class="pure-menu-link pure-menu-heading">Title</a>
        <a href="#" class="pure-menu-responsive-toggle">Toggle</a>
        <ul class="pure-menu-list">
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">Home</a></li>
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">About</a></li>
            <li class="pure-menu-item pure-menu-has-children">
                <a href="#" class="pure-menu-link">Blog</a>
                <ul class="pure-menu-children">
                    <li class="pure-menu-item"><a class="pure-menu-link" href="/handlebars">Handlebars Helpers</a></li>
                    <li class="pure-menu-item"><a class="pure-menu-link" href="/dust">Dust Helpers</a></li>
                    <li class="pure-menu-item"><a class="pure-menu-link" href="/react">React Mixins</a></li>
                    <li class="pure-menu-item"><a class="pure-menu-link" href="/javascript">Intl Message Format</a></li>
                </ul>
            </li>
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">Contact</a></li>
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">GitHub</a></li>
            <li class="pure-menu-item"><a href="#" class="pure-menu-link">Twitter</a></li>
        </ul>
    </div>

Here's what it looks like:

Customizing the menu

The menu now has various child classes that you can hook into. Here they are:

  1. .pure-menu: Hook into this to style the menu's bounding box.
  2. .pure-menu-list: All <ul> tags within a menu should have this class.
  3. .pure-menu-item: All <li> tags within a menu should have this class.
  4. .pure-menu-link: All <a> tags within a menu should have this class.
  5. .pure-menu-has-children: A <li.pure-menu-item> tag that has a nested menu should have this class.
  6. .pure-menu-children: A <ul.pure-menu-list> tag that is a child of an <li.pure-menu-item> tag (nested menu) has this class.
  7. .pure-menu-heading: A <a> tag that is outside the <ul.pure-menu-list> and is the heading for the menu has this class.
  8. .pure-menu-responsive-toggle: A <a> tag in a responsive menu that sits outside the <ul.pure-menu-list> and is responsible for showing/hiding the toggle button has this class.
  9. .pure-menu-is-active: In a responsive menu, this class signifies when a menu is "open" (ie: showing its submenus).

Menus were probably the hardest part of the library to customize. You would have to write a ton of messy CSS to do it. Not anymore! This is how you customize a menu now:

HTML

Here's the HTML for a responsive horizontal menu. I've added some classes with the -custom suffix to base my styles off of. I recommend doing the same when customizing any Pure component.

    <div class="menu-custom pure-menu pure-menu-horizontal pure-menu-responsive">
        <a href="#" class="heading-custom pure-menu-link pure-menu-heading">Title</a>
        <a href="#" class="toggle-custom pure-menu-responsive-toggle">Toggle</a>
        <ul class="list-custom pure-menu-list">
            <li class="item-custom pure-menu-item"><a href="#" class="link-custom pure-menu-link">Home</a></li>
            <li class="item-custom pure-menu-item"><a href="#" class="link-custom pure-menu-link">About</a></li>
            <li class="item-custom pure-menu-item"><a href="#" class="link-custom pure-menu-link">Blog</a></li>
            <li class="item-custom pure-menu-item"><a href="#" class="link-custom pure-menu-link">Contact</a></li>
            <li class="item-custom pure-menu-item"><a href="#" class="link-custom pure-menu-link">GitHub</a></li>
            <li class="item-custom pure-menu-item"><a href="#" class="link-custom pure-menu-link">Twitter</a></li>
        </ul>
    </div>

CSS

Here's what the CSS would look like. Notice how I've added my own class to the menu above to make it easier to style. However, I don't have to use any descendent selectors anymore.

        /* Update background on menu. */        
        .menu-custom {
            background: #111;
            padding: 0.8em;
            border-radius: 5px;
        }

        /* Make the heading white */
        .heading-custom {
            color: white;
        }

        /* Make links light-gray with a transition */
        .link-custom {
            color: #ddd;
            transition: color 0.5s;
        }

        /* Color links blue on hover and focus */
        .link-custom:hover,
        .link-custom:focus {
            color: #40a4ff;
        }

        /* Update the positioning of the toggle button 
        because we are modifying the menu's padding, and change its color. */
        .toggle-custom {
            margin-top: 6px;
            margin-right: 15px;
            color: white;
        }

Looks like this:

Responsive Behavior and overriding Media Queries

To add the responsive behavior to menus, we obviously need to have a media query. I recommend doing the same thing that we did with Grids. Have pure-menu-responsive.min.css available on the CDN, with a sane media query default (I recommend 48em), but allow people to override this by not getting that file from the CDN, and instead adding the following CSS inside their app.css:

@media (min-width: 48em) {
    /*At 48em and higher, the list becomes display:inline-block (from display:none)*/
    .pure-menu-responsive .pure-menu-list {
        display: inline-block;
    }
    /*At 48em and higher, we hide the toggle, because we just showed the .pure-menu-list*/
    .pure-menu-responsive-toggle {
        display: none;
    }
}

Responsive Behavior and JavaScript

You need to have some JS on the page to toggle the responsive menu. This would be something that users can copy/paste from the Pure site.

Example using YUI:

        YUI().use('node', function (Y) {
            //When you click on a .pure-menu-responsive-toggle, toggle the associated menu
            Y.one('document').delegate('click', function (e) {
                e.preventDefault();
                e.target.get('parentNode').toggleClass('pure-menu-is-active');
            }, '.pure-menu-responsive-toggle');
        });

Tests

I've tested this on Latest Chrome/FF/Safari, and iOS 7. Haven't tested this on Android or IE yet, so I'll do that and report back here (help would be appreciated 😄 ). The manual test page has been updated with the new menu.

Next Steps

  • Verify tests in IE
  • Verify tests in Android 4.x

This commit makes .pure-menu smaller, more responsive, and easier to customize.

- Remove `.pure-menu-open`
- Remove dropdown menu CSS
- Add `.pure-menu-responsive` and `.pure-menu-toggle` to
  make responsive horizontal menus.
- Make pure menus *really* easy to customize
@tilomitra
Copy link
Contributor Author

@ericf Thoughts on dropdown menu?

@AurelioDeRosa
Copy link
Contributor

My two cents: I'd like to see dropdown menus in Pure

fixedMenu.toggleClass('pure-menu-open');
});

}).use('node-base', function (Y) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the simple JavaScript code. So I'd like to test with the pure JavaScript that doesn't use YUI if possible, but is this possible? I expect to be able to present a drop-down menu that doesn't depend on YUI in the example of pure-site on the end, make sense?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okuryu You should have no problem with that.

With pure 0.1 and 0.2.* I wrote a small jQuery function for example and it's working perfectly (you can find it here, for the usage just go back and read the README of that repo)

When I have some time I check if it works with this code and eventually update it but I bet it will be pretty straightforward.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mseri I don't care what library Pure's users use (of course jQuery is ok). My goal is lower the barriers for Pure newbies by leave any libraries at purecss.io. It may also be nice to provide some examples of drop-down menu by a few JS libraries. Anyway, perhaps we should test the drop-down menu with pure JS?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okuryu of course! I was just pointing out that it is not that hard to make it work without YUI. In the future I could write the code for some different frameworks (and a priori my code works with many different replacements of jQuery like zepto) and it can probably be translated to pure js easily, I just have no time at the moment to do it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mseri

In the future I could write the code for some different frameworks

Yes. That'll be fine, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we add this to the website, we'll have snippets using vanilla JS, jQuery and YUI.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tilomitra Thanks!

@oskarrough
Copy link

Agree completely on the dropdowns, it will be more useful when it isn't tied to a specific module. How can I help get this live?

@tilomitra
Copy link
Contributor Author

@oskarrough I haven't started work on the dropdowns. The first thing we would need is some CSS and a tiny bit of JS that toggles classes and works in all of our supported environments.

I was thinking something like this for the HTML (subject to change, of course):

<!-- this would probably be an inline-block element to work with menus and buttons well -->
<div class="pure-dropdown">
  <!-- this could also be a .pure-button or a pure menu item -->
  <a class="pure-dropdown-toggle" href="#">A dropdown link</a>
  <ul class="pure-dropdown-menu">
    <li>...</li>
    <li>...</li>
  </ul>
</div>

If we can reduce the number of HTML elements while still following SMACSS and being able to support all of our required environments, then that would be ideal.

@oskarrough
Copy link

If we could come up with a solution that works out of the box with the proposed markup but also allows the dropdown-toggle to define a custom target, it would be great. This way it could be used for navigation toggles, panels, anything really.

<button class="pure-dropdown-toggle" data-target="pure-custom-panel">Toggle panel</button>
<div id="pure-custom-panel"></div>

Regarding supported environments and JS, is jQuery assumed?

@pspeter3
Copy link

This looks like an awesome improvement. I would be happy to test on my Android 4.x phone and tablet

@Thomas-Persson
Copy link

Awesome improvements. When can we except to see it in master?

@tilomitra
Copy link
Contributor Author

We're aiming to get this in for Pure 0.4.0, provided there aren't any
hiccups between now and then.

On Fri, Aug 30, 2013 at 8:47 AM, Thomas Persson notifications@github.comwrote:

Awesome improvements. When can we except to see it in master?


Reply to this email directly or view it on GitHubhttps://github.com//pull/142#issuecomment-23558607
.

Tilo Mitra
@tilomitra http://www.twitter.com/tilomitra //
tilomitra.comhttp://www.tilomitra.com

@pspeter3
Copy link

Can you build 0.4.0 or 0.3.0 right now or is it now in a good state?

@tilomitra
Copy link
Contributor Author

@pspeter3 We just released 0.3.0-rc-2, so we should be releasing 0.3.0 next week if everything checks out. It'll be another few weeks before 0.4.0. If you want to use this version of the Menu now, I recommend just pulling the menu-*.css files from my new-menu branch and building a local version of Pure based on that + what's off master (merge new-menu into master).

@ghost
Copy link

ghost commented Sep 4, 2013

What dependencies does this need, exactly? Is it supposed to work with only http://yui.yahooapis.com/pure/0.3.0-rc-2/pure-min.css?

@tilomitra
Copy link
Contributor Author

@zetalevel This has no dependencies other than Normalize, and so it will work with any version of Pure. There is an example of a menu that uses responsive grids, and that depends on this proposed grid system. However, you could just not use those classnames, and still get the rest of the new menu to work. That example just demonstrates that menus play nice with grids.

@ghost
Copy link

ghost commented Sep 4, 2013

OK. What am I doing wrong, then? (Thank you for the wonderful Pure.)

<!doctype html>
<html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pure menu exp</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.3.0-rc-2/pure-min.css">
</head><body>

<div class="pure-g-r"><div class="pure-u-1">

<div class="pure-menu pure-menu-horizontal pure-menu-responsive">
    <a href="#" class="pure-menu-heading">Site Title</a>
    <a href="#" class="pure-menu-toggle">Open</a>
    <ul>
        <li class="pure-menu-selected"><a href="#">Home</a></li>
        <li><a href="#">Flickr</a></li>
        <li><a href="#">Messenger</a></li>
        <li class="pure-menu-separator">&nbsp;</li>
        <li class="pure-menu-disabled"><a href="#">Sports</a></li>
        <li><a href="#">Finance</a></li>
    </ul>
</div>

<div style="padding: 20px">
<h1>My headline</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p></div>
</div></div></body></html>

@iangordon
Copy link

I would like to see Dropdown's continue to be supported but, the way Bootstrap implements it is nice.

@cy137
Copy link

cy137 commented Nov 5, 2013

This is an awesome change and I love what you've done with the framework. Do we have a ETA on when the responsive menus will be supported? No worries if not. Thanks!

@ericf
Copy link
Collaborator

ericf commented Nov 6, 2013

@cy137 we recently had a great discussion on how we want to handle responsive features in Pure: http://blog.purecss.io/post/65656116532/last-weeks-yui-open-roundtable-featured-an

@testbird
Copy link

Would you see dropdown menus could be done as pure css, without requireing javascript?

This actually seems to present a pure css solution even for mobile menus:
http://www.creativebloq.com/css3/build-smart-mobile-navigation-without-hacks-6122800

The solution is live on: http://gps.nichols.edu

@ItsAsbreuk
Copy link

I find myself overriding this css for horizontal menus:

.pure-menu.pure-menu-horizontal > ul {
    height: auto; /* reset pure's value */
    top: auto; /* reset pure's value */
    min-height: 2.4em;
    bottom: 0;
}

this way the buttons stay within their container when small screensizes makes them divided across multiple rows.

@sethlivingston
Copy link

I propose moving the dropdown menu question to a separate issue; there are too many badly needed components in this issue to hold it up. Let's get it out sooner than 0.40.

@okuryu okuryu mentioned this pull request Jan 8, 2014
@l4zl0w
Copy link

l4zl0w commented Feb 13, 2014

Are menus actually working at the moment?
Can't make drop-downs work.
Can't make menu to get minimised when resizing browser.

@kwando
Copy link
Contributor

kwando commented Feb 14, 2014

@l4zl0w are you adding the required javascripts?

@ghost
Copy link

ghost commented Aug 25, 2014

Tilo thank you for continuing to address such issues. We are
considering moving to Pure for new web projects. Will check out the new
menu.

@media (max-width: 480px) {
.pure-menu-horizontal {
width: 100%;
@media (min-width: 48em) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole file should be killed, since it has media queries in it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way for this to work for people since we have no idea how many items are in the menu, and that's a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericf Read the section Responsive Menus and Overriding Media Queries in the PR Description.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I read that. So if people are going to have to add media queries anyways, we should remove this. If I have a menu with two–three items in it, it might not need to collapse on an iPad in portrait, or an larger screen phone, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should still provide the option of linking to this file from the CDN. I am cool with excluding it from the build roll-ups, so it has to be pulled in separately.

@roydekleijn
Copy link

any working example?

desktop browser: normal horizontal menu with dropdowns
Mobile browser: toggle button that opens a menu layer

@tilomitra
Copy link
Contributor Author

@roydekleijn:

  • Pull in the code in this pull request
  • run grunt
  • open src/menus/tests/manual/menus.html in your browser.

You'll see the example that you are referring to on that page. For an HTML snippet, check the Responsive Menus section in the PR description.

@roydekleijn
Copy link

cool!

but if you resize the browser window till the toggle is display and toggle it, it shows the submenu items (vertical ul)
then resize the browserwindow again, the vertical ul remains displayed.

isn't that an issue?

@tilomitra
Copy link
Contributor Author

@roydekleijn Good catch. I'll add in a fix for that. Apart from that, waiting for @ericf to sign off on this stuff, or to propose a list of changes so we can get this into core.

@ericf
Copy link
Collaborator

ericf commented Aug 28, 2014

waiting for @ericf to sign off on this stuff, or to propose a list of changes so we can get this into core.

@tilomitra I'll review this sometime next week after the long weekend.

@roydekleijn
Copy link

Awesome! I have another question:
Is there also a way to collapse and expand the dropdown-options in a mobile browser?

Ps. Is there a roadmap somewhere? I like to contribute as well to this awesome project.

@tilomitra
Copy link
Contributor Author

@roydekleijn Do you mean collapsing and expanding sub-menu items? Because in this PR, you can collapse and expand the primary menu items.

@roydekleijn
Copy link

Yes you can. But that won't work on smaller mobile screens..

Do you have any idea when you will commit the fix? I'm keen on to continue with the implementation of this great feature.

@tilomitra
Copy link
Contributor Author

@roydekleijn Sorry, still not sure exactly what feature you're referring to. Can you give me an example, or clarify it a bit? What won't work on smaller mobile screens?

@roydekleijn
Copy link

Ok, let me elaborate the possible issues:

Issue1: if you resize your browser window to a smaller screen, then the toggle will appear. When you click on it the menu will appear. That's fine! But if you resize your browser window again to a bigger screen then the toggle will disappear but also the vertical menu remains displayed

Issue2: imagine you have a menu with dropdowns. On a smaller screen the vertical menu will appear with the dropdowns in expanded state. Question was if it is possible to display it the first time in collapse state, but only if you click on it it will be expanded.

Does it make more sense?
Roy

Verstuurd vanaf mijn iPhone

Op 30 Aug 2014 om 09:58 heeft Tilo notifications@github.com het volgende geschreven:

@roydekleijn Sorry, still not sure exactly what feature you're referring to. Can you give me an example, or clarify it a bit? What won't work on smaller mobile screens?


Reply to this email directly or view it on GitHub.

@tilomitra
Copy link
Contributor Author

Yep, that makes sense. Issue #1 will be fixed. I'll propose a solution for issue #2 as well but that will mostly be a JS solution, since you'll need to hook onto the sub-menus. I'll try to get this in by Tuesday/Wednesday.

@jamesalley
Copy link
Contributor

  1. I prefer to keep markup minimal; the recommendation here is rather verbose with all the classnames being inserted. I don't mind slightly "messy" CSS if it keeps the markup clean. It's nice to have flat CSS, but it's also nice to have clean, efficient markup.
  2. The customizing recommendation seems so obvious; I don't understand its purpose. Of course anyone can add their own custom classes at any time. That doesn't need to be documented. Besides, I would prefer to just add a differentiator class to the parent element and then hook into the existing markup structure and classnames. But perhaps I don't appreciate how complex that can get for some users. It may be that this flatter, but more verbose, approach is easier for users to apply, and that ease-of-use trumps markup elegance.
  3. Javascript triggers: I would like to see Pure adopt some sort of .js/.nojs conventions. With those in place, I would add menu behaviors that work with JS off, using hover as a trigger. Hover does work on mobile, albeit it's a bit clunky: the first tap reveals the hover state, a second tap clicks through, which makes it subject to accidental click-throughs. But this clunky interaction would only be there if JS is off. A corner case. At least it would work with no js!
  4. In one product I worked on, I developed a horizontal responsive menu whereby if the menu items wouldn't fit within the available width, I would create a "More..." menu item and push the outliers into the More menu. Perhaps we could consider such an approach in the future.
  5. Regarding backwards compatibility, perhaps we should consider namespacing/prefixing Pure rule sets. That would provide a nice migration path and the ability to mix two versions at the same time if absolutely necessary.

@roydekleijn
Copy link

Cool, really looking forward to it :)

On Sun, Aug 31, 2014 at 6:37 AM, Tilo notifications@github.com wrote:

Yep, that makes sense. Issue #1 #1
will be fixed. I'll propose a solution for issue #2
#2 as well but that will mostly be a
JS solution, since you'll need to hook onto the sub-menus. I'll try to get
this in by Tuesday/Wednesday.


Reply to this email directly or view it on GitHub
#142 (comment).

@tilomitra
Copy link
Contributor Author

@jamesalley I used to agree that child items shouldn't have a classname in order to keep markup efficient and small, but the truth is that I'd rather have more classnames than increased CSS specificity.

For example, if I wrote this:

<div class="pure-menu">
  <ul>...
     <li>...
...
</div>

Then my CSS has to be triggered off .pure-menu ul and .pure-menu li, which has increased specificity than just a classname. Imagine that I had a style like this:

.pure-menu li a { color: red; }

The above has a specificity of 12. Even if I give the a element a classname, it would have a lower specificity (classname = specificity of 10). As a result, if I want to over-ride that color, I would have to do .pure-menu .myclass, which now is adding even more specificity.

As you can see, once we get into a specificity battle, it's a lot harder understand what CSS rules will be applied. It's much easier to give everything their own classname, which makes it simple for developers to over-ride those classes when needed.

This was the logic that went into the HTML for this release.

Re JS/noJS styles, I agree with you, and we need to figure that out. Menus are probably one of the only places where we would need such a thing.

@tilomitra
Copy link
Contributor Author

@ericf Let me know when you get a chance to go through this.

@tilomitra tilomitra added this to the 0.6.0 milestone Sep 4, 2014
@roydekleijn
Copy link

Let me know if I can help you with testing both fixes. Thanks, Roy

@tilomitra
Copy link
Contributor Author

Thanks Roy. Been a little swamped here, but I'll try to get in those fixes asap.

@roydekleijn
Copy link

I fixed the issues mentioned earlier.
We have to change two thing:
CSS:
.pure-menu-item:hover > .pure-menu-children, .pure-menu-item:focus > .pure-menu-children {
/display: block;/ REMOVE THIS
top: 0;
left: 100%;
width: 100%
}

.pure-menu-is-active .pure-menu-children {
/display: block;/ REMOVE THIS
position: static
}

jQuery: (sorry for the formatting)

$( document ).ready(function() {
$( ".pure-menu-responsive-toggle" ).click(function(e) {
$(this).parent().toggleClass('pure-menu-is-active');
});
$( ".pure-menu-has-children > .pure-menu-link" ).click(function(e) {
$(this).next().toggle();
});
$( window ).resize(function() {
if ($( window ).width() > 768) {
$('.menu-custom').removeClass('pure-menu-is-active');
}
});
});

@jamesalley
Copy link
Contributor

I pulled this PR into a branch and I'm using it with the pure-site. This gives me some idea of what it would be like for someone to upgrade to 0.6 at which point they'll have to deal with menus since this is not backwards-compatible.

I'm listing the changes I'm noticing which were not described in this PR which may impact users:

  1. .pure-menu-heading has had properties removed, e.g., text-transform: uppercase. My take: this opinionated style doesn't belong in Pure as a default.
  2. .pure-menu-list is set to display: inline-block. My take: This breaks the menu in pure-site, but it's easily overridden, so I don't object to this.
  3. .pure-menu-selected has been removed. My take: all this did was make a link black. I do approve of monochromatic colors being employed as defaults to make UI understandable, but perhaps this doesn't belong in Pure but in a customization layer.

These doesn't affect users per se, but I wonder if they are important:

  1. .pure-menu-fixed no longer has an example in the tests file.
  2. .pure-paginator has been completely removed. Why?

@deeve007
Copy link

You shouldn't need to add anything apart from a class name to the parent UL to make a menu become a "pure" menu.

@jamesalley
Copy link
Contributor

I'm moving forward with work on this PR. There are some good ideas and features that folks seem to want. Real concerns are addressed. The PR is not perfect, however; I'm going to have to make more than a few changes before it's ready for prime-time. But I will not be changing the heart of this PR, just fixing bugs and improving some of the default styling, which was stripped to the bone by this PR.

As for pagination being removed, I eventually learned that Tilo and Eric had been planning to remove it for quite some time, so he removed it along the way.

@jamesalley jamesalley mentioned this pull request Jan 21, 2015
@jamesalley
Copy link
Contributor

Closing this PR, as I have a new PR going in its stead, with some refinements.

@jamesalley jamesalley closed this Jan 21, 2015
@jharaphula
Copy link

This is a beautiful example of Responsive horizontal menu using pure CSS http://jharaphula.com/responsive-horizontal-menu-using-pure-css

@jamesalley
Copy link
Contributor

@jharaphula I was checking that link out and it didn't appear to be using pure...but it's your site, so you should know. Can you explain? (Might want to move this chat topic to Gitter so as not to pollute this issue.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet