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 @media screen and (min-width: 48.25em) {
56 body:not(:target) .toggle-menu {
57 .toggle-menu__list .toggle-menu__item {
58 display: inline-block;
65 @mixin _toggle-menu-theme {
71 text-decoration: none;
74 .toggle-menu__button {
81 content: icon(hamburger);
87 .toggle-menu__button--show {
88 background-color: red;
91 .toggle-menu__button--hide {
92 background-color: darkred;
99 background-color: orange;
100 list-style-type: none;
105 .toggle-menu__list .toggle-menu__item {
113 background-color: yellow;
120 $imported-once: false !default;
121 @mixin toggle-menu-common($show-menu-id) {
122 $imported-once: $imported-once !global;
123 @if ($imported-once == false) {
124 $imported-once: true !global;
125 @include _toggle-menu-common($show-menu-id);
126 @include _toggle-menu-theme;
130 @mixin toggle-menu($show-menu-id) {
132 @include toggle-menu-common($show-menu-id);
134 /* mobile-first style for ##{$show-menu-id} when :target is supported */
135 body:not(:target) .toggle-menu {
136 ##{$show-menu-id}:target {
137 ~ .toggle-menu__list .toggle-menu__item {
139 -moz-transition: height .25s, line-height .25s;
140 -ms-transition: height .25s, line-height .25s;
141 -o-transition: height .25s, line-height .25s;
142 -webkit-transition: height .25s, line-height .25s;
143 transition: height .25s, line-height .25s;
146 ~ .toggle-menu__button--show {
150 ~ .toggle-menu__button--hide {
156 /* big screen style for ##{$show-menu-id} when :target is supported */
157 @media screen and (min-width: 48.25em) {
158 body:not(:target) .toggle-menu {
159 ##{$show-menu-id}, ##{$show-menu-id}:target {
160 ~ .toggle-menu__list .toggle-menu__item {
164 ~ .toggle-menu__button--show {
168 ~ .toggle-menu__button--hide {