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

Making 'is-active' css selector configurable to allow for css-only state change #89

Open
dhymik opened this issue Feb 24, 2020 · 1 comment

Comments

@dhymik
Copy link

dhymik commented Feb 24, 2020

Jonathan,

thank you for some really beautiful hamburgers! I made it work without Javascript:

I am using the squeeze variant in a hamburger menu which, instead of the proposed a tag, uses a label tag with associated hidden checkbox and :checked pseudo selector.

I replaced the &.is-active selector from the _base.scss and the _squeeze.scss file with a Sass variable $hamburger-activeClass and made it configurable like your other setting variables, and set its default to the original &.is-active value.

Here is my html:

<input class="hiddenToggle" id="toggle" type="checkbox" />
<label for="toggle" class="hamburger hamburger--squeeze">
    <span class="hamburger-box">
        <span class="hamburger-inner"></span>
    </span>
</label>
<nav>
    ....
</nav>

The scss is:

.toggleMenu {
    Nav
    {
        display: none;
    }
    .hiddenToggle
    {   // don't hide so it is still accessible
        position: absolute;
        left: -9999px;
    }
    .hiddenToggle:checked ~ nav 
    {
        display: block;
    }
}

For above use case, I set the $hamburger-activeClass variable to .hiddenToggle:checked ~ & and it works like a charm.

If you think this would be a good overall function for hamburgers, let me know and I'll prepare a pull request with all hamburger variants adjusted with the new variable.

Regards, Mikael

@bbbenjie
Copy link

bbbenjie commented Jul 4, 2020

+1 for this nice adjustment. I was searching for the same and would love to see this included in the project.

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

No branches or pull requests

2 participants