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 @mixin _toggle-menu-common($show-menu-id) {
20 /* common fallback style for when :target is not supported */
22 .toggle-menu__target {
26 .toggle-menu__button--show {
30 .toggle-menu__button--hide {
34 .toggle-menu__list .toggle-menu__item {
39 /* common mobile-first style for when :taget is supported */
40 body:not(:target) .toggle-menu {
41 .toggle-menu__list .toggle-menu__item {
46 .toggle-menu__button--show {
50 .toggle-menu__button--hide {
55 /* common big screen style for when :target is supported */
56 @media screen and (min-width: 48.25em) {
57 body:not(:target) .toggle-menu {
58 .toggle-menu__list .toggle-menu__item {
59 display: inline-block;
66 @mixin _toggle-menu-theme {
68 /* toggle-menu theming */
73 text-decoration: none;
76 .toggle-menu__button {
83 content: icon(hamburger);
89 .toggle-menu__button--show {
90 background-color: red;
93 .toggle-menu__button--hide {
94 background-color: darkred;
101 background-color: orange;
102 list-style-type: none;
107 .toggle-menu__list .toggle-menu__item {
115 background-color: yellow;
122 $imported-once: false !default;
123 @mixin toggle-menu-common($show-menu-id) {
124 $imported-once: $imported-once !global;
125 @if ($imported-once == false) {
126 $imported-once: true !global;
127 @include _toggle-menu-common($show-menu-id);
128 @include _toggle-menu-theme;
132 @mixin toggle-menu($show-menu-id) {
134 @include toggle-menu-common($show-menu-id);
136 /* mobile-first style for ##{$show-menu-id} when :target is supported */
137 body:not(:target) .toggle-menu {
138 ##{$show-menu-id}:target {
139 ~ .toggle-menu__list .toggle-menu__item {
141 -moz-transition: height .25s;
142 -ms-transition: height .25s;
143 -o-transition: height .25s;
144 -webkit-transition: height .25s;
145 transition: height .25s;
148 ~ .toggle-menu__button--show {
152 ~ .toggle-menu__button--hide {
158 /* big screen style for ##{$show-menu-id} when :target is supported */
159 @media screen and (min-width: 48.25em) {
160 body:not(:target) .toggle-menu {
161 ##{$show-menu-id}, ##{$show-menu-id}:target {
162 ~ .toggle-menu__list .toggle-menu__item {
166 ~ .toggle-menu__button--show {
170 ~ .toggle-menu__button--hide {