1 // toggle-menu - An SCSS mixin for pure CSS responsive toggle menus
3 // Copyright (C) 2017 Antonio Ospite <ao2@ao2.it>
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 $toggle-menu-transition-delay: .25s;
20 @mixin _toggle-menu-common($show-menu-id) {
22 /* common fallback style for when :target is not supported */
24 .toggle-menu__target {
28 .toggle-menu__button--show {
32 .toggle-menu__button--hide {
36 .toggle-menu__list .toggle-menu__item {
41 /* common mobile-first style for when :taget is supported */
42 body:not(:target) .toggle-menu {
43 .toggle-menu__list .toggle-menu__item {
46 -moz-transition: height $toggle-menu-transition-delay;
47 -ms-transition: height $toggle-menu-transition-delay;
48 -o-transition: height $toggle-menu-transition-delay;
49 -webkit-transition: height $toggle-menu-transition-delay;
50 transition: height $toggle-menu-transition-delay;
53 .toggle-menu__button--show {
57 .toggle-menu__button--hide {
62 /* common big screen style for when :target is supported */
63 @media screen and (min-width: 48.25em) {
64 body:not(:target) .toggle-menu {
65 .toggle-menu__list .toggle-menu__item {
66 display: inline-block;
73 @mixin _toggle-menu-theme {
75 /* toggle-menu theming */
80 text-decoration: none;
83 .toggle-menu__button {
90 content: icon(hamburger);
96 .toggle-menu__button--show {
97 background-color: red;
100 .toggle-menu__button--hide {
101 background-color: darkred;
103 content: icon(cross);
108 background-color: orange;
109 list-style-type: none;
114 .toggle-menu__list .toggle-menu__item {
122 background-color: yellow;
129 $imported-once: false !default;
130 @mixin toggle-menu-common($show-menu-id) {
131 $imported-once: $imported-once !global;
132 @if ($imported-once == false) {
133 $imported-once: true !global;
134 @include _toggle-menu-common($show-menu-id);
135 @include _toggle-menu-theme;
139 @mixin toggle-menu($show-menu-id) {
141 @include toggle-menu-common($show-menu-id);
143 /* mobile-first style for ##{$show-menu-id} when :target is supported */
144 body:not(:target) .toggle-menu {
145 ##{$show-menu-id}:target {
146 ~ .toggle-menu__list .toggle-menu__item {
147 // NOTE: for the transition animation to work 'height' cannot be auto.
149 -moz-transition: height $toggle-menu-transition-delay;
150 -ms-transition: height $toggle-menu-transition-delay;
151 -o-transition: height $toggle-menu-transition-delay;
152 -webkit-transition: height $toggle-menu-transition-delay;
153 transition: height $toggle-menu-transition-delay;
156 ~ .toggle-menu__button--show {
160 ~ .toggle-menu__button--hide {
166 /* big screen style for ##{$show-menu-id} when :target is supported */
167 @media screen and (min-width: 48.25em) {
168 body:not(:target) .toggle-menu {
169 ##{$show-menu-id}, ##{$show-menu-id}:target {
170 ~ .toggle-menu__list .toggle-menu__item {
174 ~ .toggle-menu__button--show {
178 ~ .toggle-menu__button--hide {