Skip to content

Commit

Permalink
Option to change active classname through variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoko committed Jan 4, 2021
1 parent 09edd42 commit 72185c6
Show file tree
Hide file tree
Showing 23 changed files with 24 additions and 22 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ $hamburger-bar-spacing: round($hamburger-size / 5); // How f
$hamburger-animation-speed: 1; // The timings of the animations are carefully chosen. But you
// can use this factor variable to slow down or speed up the animations.
// Use .5 for twice as slow, 2 for twice as fast etc.
$hamburger-class-name: 'hamburger' // The main class and prefixes of the animation classes
$hamburger-class-name: 'hamburger'; // The main class and prefixes of the animation classes
// can be changed. This allows for different styled buttons on the
// same page.
$hamburger-active-class-name: 'active'; // Change the classname that triggers the animation
$hamburger-extra-transition-rules: &; // = null. If you need extra transition rules on the base element
// you can set this variable and it gets appended. This way you don't
// need to overwrite the plugin transition rules. Example:
Expand Down
2 changes: 1 addition & 1 deletion scss/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ div.#{$hamburger-class-name} {
}
}

&.active {
&.#{$hamburger-active-class-name} {
background-color: $hamburger-background-active;

span.bar {
Expand Down
1 change: 1 addition & 0 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// Variables
$hamburger-class-name: 'hamburger' !default;
$hamburger-active-class-name: 'active' !default;
$hamburger-size: 50px !default;
$hamburger-thickness: 2px !default;
$hamburger-color: #000 !default;
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_apple.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
> .inner {
transform: rotate(90deg) translate3d($hamburger-thickness / 2, -$hamburger-thickness / 2, 0);
transition: transform 0.35s / $hamburger-animation-speed $hamburger-easing;
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_arrow-right.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
> .inner {
transform: rotate(-180deg) translate3d(0, -$hamburger-thickness, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_arrow.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
> .inner {
transform: rotate(180deg) translate3d(0, -$hamburger-thickness, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_chop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
top: 0;

Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_collapse.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
transition: transform 0.25s / $hamburger-animation-speed $hamburger-easing,
opacity 0.25s / $hamburger-animation-speed $hamburger-easing;
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_converge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
top: 0;

Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_criss-cross.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
> .inner {
&::before,
&::after {
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@if index($hamburger-animations, default) {
.#{$hamburger-class-name}--default {
&.active {
&.#{$hamburger-active-class-name} {
span.bar {
top: 0;

Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_dive.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
&:nth-child(1) {
transform: rotate(135deg);
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_flatten.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
transition: transform 0.3s / $hamburger-animation-speed $hamburger-easing;
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
&:nth-child(1) {
transform: translate3d(0, $hamburger-bar-spacing, 0);
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_magnetic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
transition: transform 0.2s / $hamburger-animation-speed $hamburger-easing;

Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_minimal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
transition:
transform 0.4s / $hamburger-animation-speed $hamburger-easing,
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_parallel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
top: 0;
transition:
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_push.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
> .inner {
transform: translate3d(0, $hamburger-size * 1.1, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_shelf.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
transition:
transform 0.3s / $hamburger-animation-speed $hamburger-easing,
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_simple.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
&:nth-child(1) {
transform: rotate(-45deg) translate3d(0, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_spin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
> .inner {
transform: rotate(180deg) translate3d(0, -$hamburger-thickness, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_stack.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
transition: transform 0.25s / $hamburger-animation-speed $hamburger-easing,
opacity 0.25s / $hamburger-animation-speed $hamburger-easing;
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_twist.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
span.bar {
&:nth-child(1) {
transform: rotate(45deg);
Expand Down
2 changes: 1 addition & 1 deletion scss/animations/_vertical.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}
}

&.active {
&.#{$hamburger-active-class-name} {
> .inner {
transform: rotate(90deg) translate3d($hamburger-thickness / 2, -$hamburger-thickness / 2, 0);
transition: transform 0.4s / $hamburger-animation-speed $hamburger-easing-out;
Expand Down

0 comments on commit 72185c6

Please sign in to comment.