_offcanvas.scss 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. // Foundation by ZURB
  2. // foundation.zurb.com
  3. // Licensed under MIT Open Source
  4. @import 'global';
  5. @import 'type';
  6. // Off Canvas Tab Bar Variables
  7. $include-html-off-canvas-classes: $include-html-classes !default;
  8. $tabbar-bg: $oil !default;
  9. $tabbar-height: rem-calc(45) !default;
  10. $tabbar-icon-width: $tabbar-height !default;
  11. $tabbar-line-height: $tabbar-height !default;
  12. $tabbar-color: $white !default;
  13. $tabbar-middle-padding: 0 rem-calc(10) !default;
  14. // Off Canvas Divider Styles
  15. $tabbar-left-section-border: solid 1px scale-color($tabbar-bg, $lightness: -50%) !default;
  16. $tabbar-right-section-border: $tabbar-left-section-border;
  17. // Off Canvas Tab Bar Headers
  18. $tabbar-header-color: $white !default;
  19. $tabbar-header-weight: $font-weight-bold !default;
  20. $tabbar-header-line-height: $tabbar-height !default;
  21. $tabbar-header-margin: 0 !default;
  22. // Off Canvas Menu Variables
  23. $off-canvas-width: rem-calc(250) !default;
  24. $off-canvas-bg: $oil !default;
  25. $off-canvas-bg-hover: scale-color($tabbar-bg, $lightness: -30%) !default;
  26. $off-canvas-bg-active: scale-color($tabbar-bg, $lightness: -30%) !default;
  27. // Off Canvas Menu List Variables
  28. $off-canvas-label-padding: .3rem rem-calc(15) !default;
  29. $off-canvas-label-color: $aluminum !default;
  30. $off-canvas-label-text-transform: uppercase !default;
  31. $off-canvas-label-font-size: rem-calc(12) !default;
  32. $off-canvas-label-font-weight: $font-weight-bold !default;
  33. $off-canvas-label-bg: $tuatara !default;
  34. $off-canvas-label-border-top: 1px solid scale-color($off-canvas-label-bg, $lightness: 14%) !default;
  35. $off-canvas-label-border-bottom: none !default;
  36. $off-canvas-label-margin:0 !default;
  37. $off-canvas-link-padding: rem-calc(10, 15) !default;
  38. $off-canvas-link-color: rgba($white, .7) !default;
  39. $off-canvas-link-border-bottom: 1px solid scale-color($off-canvas-bg, $lightness: -25%) !default;
  40. $off-canvas-back-bg: #444 !default;
  41. $off-canvas-back-border-top: $off-canvas-label-border-top !default;
  42. $off-canvas-back-border-bottom: $off-canvas-label-border-bottom !default;
  43. $off-canvas-back-hover-bg: scale-color($off-canvas-back-bg, $lightness: -30%) !default;
  44. $off-canvas-back-hover-border-top: 1px solid scale-color($off-canvas-label-bg, $lightness: 14%) !default;
  45. $off-canvas-back-hover-border-bottom: none !default;
  46. // Off Canvas Menu Icon Variables
  47. $tabbar-menu-icon-color: $white !default;
  48. $tabbar-menu-icon-hover: scale-color($tabbar-menu-icon-color, $lightness: -30%) !default;
  49. $tabbar-menu-icon-text-indent: rem-calc(35) !default;
  50. $tabbar-menu-icon-width: $tabbar-icon-width !default;
  51. $tabbar-menu-icon-height: $tabbar-height !default;
  52. $tabbar-menu-icon-padding: 0 !default;
  53. $tabbar-hamburger-icon-width: rem-calc(16) !default;
  54. $tabbar-hamburger-icon-left: false !default;
  55. $tabbar-hamburger-icon-top: false !default;
  56. $tabbar-hamburger-icon-thickness: 1px !default;
  57. $tabbar-hamburger-icon-gap: 6px !default;
  58. // Off Canvas Back-Link Overlay
  59. $off-canvas-overlay-transition: background 300ms ease !default;
  60. $off-canvas-overlay-cursor: pointer !default;
  61. $off-canvas-overlay-box-shadow: -4px 0 4px rgba($black, .5), 4px 0 4px rgba($black, .5) !default;
  62. $off-canvas-overlay-background: rgba($white, .2) !default;
  63. $off-canvas-overlay-background-hover: rgba($white, .05) !default;
  64. // Transition Variables
  65. $menu-slide: "transform 500ms ease" !default;
  66. // MIXINS
  67. // Remove transition flicker on phones
  68. @mixin kill-flicker {
  69. // -webkit-transform: translateZ(0x);
  70. -webkit-backface-visibility: hidden;
  71. }
  72. // Basic properties for the content wraps
  73. @mixin wrap-base {
  74. position: relative;
  75. width: 100%;
  76. }
  77. @mixin translate3d($tx, $ty, $tz) {
  78. -webkit-transform: translate3d($tx, $ty, $tz);
  79. -moz-transform: translate3d($tx, $ty, $tz);
  80. -ms-transform: translate($tx, $ty);
  81. -ms-transform: translate3d($tx, $ty, $tz);
  82. -o-transform: translate3d($tx, $ty, $tz);
  83. transform: translate3d($tx, $ty, $tz)
  84. }
  85. // basic styles for off-canvas menu container
  86. @mixin off-canvas-menu($position) {
  87. @include kill-flicker;
  88. * { @include kill-flicker; }
  89. background: $off-canvas-bg;
  90. bottom: 0;
  91. box-sizing: content-box;
  92. -webkit-overflow-scrolling: touch;
  93. -ms-overflow-style: -ms-autohiding-scrollbar;
  94. overflow-x: hidden;
  95. overflow-y: auto;
  96. position: absolute;
  97. top: 0;
  98. transition: transform 500ms ease 0s;
  99. width: $off-canvas-width;
  100. z-index: 1001;
  101. @if $position == left {
  102. @include translate3d(-100%,0,0);
  103. left: 0;
  104. }
  105. @if $position == right {
  106. @include translate3d(100%,0,0);
  107. right: 0;
  108. }
  109. }
  110. // OFF CANVAS WRAP
  111. // Wrap visible content and prevent scroll bars
  112. @mixin off-canvas-wrap {
  113. @include kill-flicker;
  114. @include wrap-base;
  115. overflow: hidden;
  116. &.move-right,
  117. &.move-left { min-height: 100%; -webkit-overflow-scrolling: touch; }
  118. }
  119. // INNER WRAP
  120. // Main content area that moves to reveal the off-canvas nav
  121. @mixin inner-wrap {
  122. // @include kill-flicker;
  123. // removed for now till chrome fixes backface issue
  124. @include wrap-base;
  125. @include clearfix;
  126. -webkit-transition: -webkit-#{$menu-slide};
  127. -moz-transition: -moz-#{$menu-slide};
  128. -ms-transition: -ms-#{$menu-slide};
  129. -o-transition: -o-#{$menu-slide};
  130. transition: #{$menu-slide};
  131. }
  132. // TAB BAR
  133. // This is the tab bar base
  134. @mixin tab-bar-base {
  135. @include kill-flicker;
  136. // base styles
  137. background: $tabbar-bg;
  138. color: $tabbar-color;
  139. height: $tabbar-height;
  140. line-height: $tabbar-line-height;
  141. // make sure it's below the .exit-off-canvas link
  142. position: relative;
  143. // z-index: 999;
  144. // Typography
  145. h1, h2, h3, h4, h5, h6 {
  146. color: $tabbar-header-color;
  147. font-weight: $tabbar-header-weight;
  148. line-height: $tabbar-header-line-height;
  149. margin: $tabbar-header-margin;
  150. }
  151. h1, h2, h3, h4 { font-size: $h5-font-size; }
  152. }
  153. // SMALL SECTIONS
  154. // These are small sections on the left and right that contain the off-canvas toggle buttons;
  155. @mixin tabbar-small-section($position) {
  156. height: $tabbar-height;
  157. position: absolute;
  158. top: 0;
  159. width: $tabbar-icon-width;
  160. @if $position == left {
  161. border-right: $tabbar-left-section-border;
  162. // box-shadow: 1px 0 0 scale-color($tabbar-bg, $lightness: 13%);
  163. left: 0;
  164. }
  165. @if $position == right {
  166. border-left: $tabbar-right-section-border;
  167. // box-shadow: -1px 0 0 scale-color($tabbar-bg, $lightness: -50%);
  168. right:0;
  169. }
  170. }
  171. @mixin tab-bar-section {
  172. height: $tabbar-height;
  173. padding: $tabbar-middle-padding;
  174. position: absolute;
  175. text-align: center;
  176. top: 0;
  177. &.left { text-align: left; }
  178. &.right { text-align: right; }
  179. // still need to make these non-presentational
  180. &.left {
  181. left: 0;
  182. right: $tabbar-icon-width;
  183. }
  184. &.right {
  185. left: $tabbar-icon-width;
  186. right: 0;
  187. }
  188. &.middle {
  189. left: $tabbar-icon-width;
  190. right: $tabbar-icon-width;
  191. }
  192. }
  193. // OFF CANVAS LIST
  194. // This is the list of links in the off-canvas menu
  195. @mixin off-canvas-list {
  196. list-style-type: none;
  197. margin:0;
  198. padding:0;
  199. li {
  200. label {
  201. background: $off-canvas-label-bg;
  202. border-bottom: $off-canvas-label-border-bottom;
  203. border-top: $off-canvas-label-border-top;
  204. color: $off-canvas-label-color;
  205. display: block;
  206. font-size: $off-canvas-label-font-size;
  207. font-weight: $off-canvas-label-font-weight;
  208. margin: $off-canvas-label-margin;
  209. padding: $off-canvas-label-padding;
  210. text-transform: $off-canvas-label-text-transform;
  211. }
  212. a {
  213. border-bottom: $off-canvas-link-border-bottom;
  214. color: $off-canvas-link-color;
  215. display: block;
  216. padding: $off-canvas-link-padding;
  217. transition: background 300ms ease;
  218. &:hover {
  219. background: $off-canvas-bg-hover;
  220. }
  221. &:active {
  222. background: $off-canvas-bg-active;
  223. }
  224. }
  225. }
  226. }
  227. // BACK LINK
  228. // This is an overlay that, when clicked, will toggle off the off canvas menu
  229. @mixin back-link {
  230. @include kill-flicker;
  231. box-shadow: $off-canvas-overlay-box-shadow;
  232. cursor: $off-canvas-overlay-cursor;
  233. transition: $off-canvas-overlay-transition;
  234. // fill the screen
  235. -webkit-tap-highlight-color: rgba(0,0,0,0);
  236. background: $off-canvas-overlay-background;
  237. bottom: 0;
  238. display: block;
  239. left: 0;
  240. position: absolute;
  241. right: 0;
  242. top: 0;
  243. z-index: 1002;
  244. @media #{$medium-up} {
  245. &:hover {
  246. background: $off-canvas-overlay-background-hover;
  247. }
  248. }
  249. }
  250. //
  251. // Off-Canvas Submenu Classes
  252. //
  253. @mixin off-canvas-submenu($position) {
  254. @include kill-flicker;
  255. * { @include kill-flicker; }
  256. -webkit-overflow-scrolling: touch;
  257. background: $off-canvas-bg;
  258. bottom: 0;
  259. box-sizing: content-box;
  260. margin: 0;
  261. overflow-x: hidden;
  262. overflow-y: auto;
  263. position: absolute;
  264. top: 0;
  265. width: $off-canvas-width;
  266. z-index: 1002;
  267. @if $position == left {
  268. @include translate3d(-100%,0,0);
  269. left: 0;
  270. }
  271. @if $position == right {
  272. @include translate3d(100%,0,0);
  273. right: 0;
  274. }
  275. -webkit-transition: -webkit-#{$menu-slide};
  276. -moz-transition: -moz-#{$menu-slide};
  277. -ms-transition: -ms-#{$menu-slide};
  278. -o-transition: -o-#{$menu-slide};
  279. transition: #{$menu-slide};
  280. //back button style like label
  281. .back > a {
  282. background: $off-canvas-back-bg;
  283. border-bottom: $off-canvas-back-border-bottom;
  284. border-top: $off-canvas-back-border-top;
  285. color: $off-canvas-label-color;
  286. font-weight: $off-canvas-label-font-weight;
  287. padding: $off-canvas-label-padding;
  288. text-transform: $off-canvas-label-text-transform;
  289. &:hover {
  290. background: $off-canvas-back-hover-bg;
  291. border-bottom: $off-canvas-back-hover-border-bottom;
  292. border-top: $off-canvas-back-hover-border-top;
  293. }
  294. margin: $off-canvas-label-margin;
  295. @if $position == right {
  296. @if $text-direction == rtl {
  297. &:before {
  298. @include icon-double-arrows($position: left);
  299. }
  300. } @else {
  301. &:after {
  302. @include icon-double-arrows($position: right);
  303. }
  304. }
  305. }
  306. @if $position == left {
  307. @if $text-direction == rtl {
  308. &:after {
  309. @include icon-double-arrows($position: right);
  310. }
  311. } @else {
  312. &:before {
  313. @include icon-double-arrows($position: left);
  314. }
  315. }
  316. }
  317. }
  318. }
  319. //Left double angle quote or Right double angle quote chars
  320. @mixin icon-double-arrows ($position) {
  321. @if $position == left {
  322. content: "\AB";
  323. @if $text-direction == rtl {
  324. margin-left: .5rem;
  325. } @else {
  326. margin-right: .5rem;
  327. }
  328. }
  329. @if $position == right {
  330. content: "\BB";
  331. @if $text-direction == rtl {
  332. margin-right: .5rem;
  333. } @else {
  334. margin-left: .5rem;
  335. }
  336. }
  337. display: inline;
  338. }
  339. //
  340. // DEFAULT CLASSES
  341. //
  342. @include exports("offcanvas") {
  343. @if $include-html-off-canvas-classes {
  344. .off-canvas-wrap { @include off-canvas-wrap; }
  345. .inner-wrap { @include inner-wrap; }
  346. .tab-bar { @include tab-bar-base; }
  347. .left-small { @include tabbar-small-section($position: left); }
  348. .right-small { @include tabbar-small-section($position: right); }
  349. .tab-bar-section { @include tab-bar-section; }
  350. // MENU BUTTON
  351. // This is a little bonus. You don't need it for off canvas to work. Mixins to be written in the future.
  352. .tab-bar .menu-icon {
  353. color: $tabbar-menu-icon-color;
  354. display: block;
  355. height: $tabbar-menu-icon-height;
  356. padding: $tabbar-menu-icon-padding;
  357. position: relative;
  358. text-indent: $tabbar-menu-icon-text-indent;
  359. transform: translate3d(0,0,0);
  360. width: $tabbar-menu-icon-width;
  361. // @include for the hamburger menu-icon
  362. //
  363. // Arguments as follows: ($width, $left, $top, $thickness, $gap, $color, $hover-color)
  364. // $width - Width of hamburger icon in rem Default: $tabbar-hamburger-icon-width.
  365. // $left - If false, icon will be centered horizontally || explicitly set value in rem Default: $tabbar-hamburger-icon-left= False
  366. // $top - If false, icon will be centered vertically || explicitly set value in rem Default: = False
  367. // $thickness - thickness of lines in hamburger icon, set value in px Default: $tabbar-hamburger-icon-thickness = 1px
  368. // $gap - spacing between the lines in hamburger icon, set value in px Default: $tabbar-hamburger-icon-gap = 6px
  369. // $color - icon color Default: $tabbar-menu-icon-color
  370. // $hover-color - icon color when hovered Default: $tabbar-menu-icon-hover
  371. // $offcanvas - Set to true
  372. @include hamburger($tabbar-hamburger-icon-width, $tabbar-hamburger-icon-left, $tabbar-hamburger-icon-top, $tabbar-hamburger-icon-thickness, $tabbar-hamburger-icon-gap, $tabbar-menu-icon-color, $tabbar-menu-icon-hover, true)
  373. }
  374. .left-off-canvas-menu { @include off-canvas-menu($position: left); }
  375. .right-off-canvas-menu { @include off-canvas-menu($position: right); }
  376. ul.off-canvas-list { @include off-canvas-list; }
  377. // ANIMATION CLASSES
  378. // These classes are added with JS and trigger the actual animation.
  379. .move-right {
  380. > .inner-wrap {
  381. @include translate3d($off-canvas-width,0,0);
  382. }
  383. .exit-off-canvas { @include back-link;}
  384. }
  385. .move-left {
  386. > .inner-wrap {
  387. @include translate3d(-($off-canvas-width),0,0);
  388. }
  389. .exit-off-canvas { @include back-link; }
  390. }
  391. .offcanvas-overlap {
  392. .left-off-canvas-menu, .right-off-canvas-menu {
  393. -ms-transform: none;
  394. -webkit-transform: none;
  395. -moz-transform: none;
  396. -o-transform: none;
  397. transform: none;
  398. z-index: 1003;
  399. }
  400. .exit-off-canvas { @include back-link; }
  401. }
  402. .offcanvas-overlap-left {
  403. .right-off-canvas-menu {
  404. -ms-transform: none;
  405. -webkit-transform: none;
  406. -moz-transform: none;
  407. -o-transform: none;
  408. transform: none;
  409. z-index: 1003;
  410. }
  411. .exit-off-canvas { @include back-link; }
  412. }
  413. .offcanvas-overlap-right {
  414. .left-off-canvas-menu {
  415. -ms-transform: none;
  416. -webkit-transform: none;
  417. -moz-transform: none;
  418. -o-transform: none;
  419. transform: none;
  420. z-index: 1003;
  421. }
  422. .exit-off-canvas { @include back-link; }
  423. }
  424. // Older browsers
  425. .no-csstransforms {
  426. .left-off-canvas-menu { left: -($off-canvas-width); }
  427. .right-off-canvas-menu { right: -($off-canvas-width); }
  428. .move-left > .inner-wrap { right: $off-canvas-width; }
  429. .move-right > .inner-wrap { left: $off-canvas-width; }
  430. }
  431. .left-submenu {
  432. @include off-canvas-submenu($position: left);
  433. &.move-right, &.offcanvas-overlap-right, &.offcanvas-overlap {
  434. @include translate3d(0%,0,0);
  435. }
  436. }
  437. .right-submenu {
  438. @include off-canvas-submenu($position: right);
  439. &.move-left, &.offcanvas-overlap-left, &.offcanvas-overlap {
  440. @include translate3d(0%,0,0);
  441. }
  442. }
  443. @if $text-direction == rtl {
  444. .left-off-canvas-menu ul.off-canvas-list li.has-submenu > a:before {
  445. @include icon-double-arrows($position: left);
  446. }
  447. .right-off-canvas-menu ul.off-canvas-list li.has-submenu > a:after {
  448. @include icon-double-arrows($position: right);
  449. }
  450. } @else {
  451. .left-off-canvas-menu ul.off-canvas-list li.has-submenu > a:after {
  452. @include icon-double-arrows($position: right);
  453. }
  454. .right-off-canvas-menu ul.off-canvas-list li.has-submenu > a:before {
  455. @include icon-double-arrows($position: left);
  456. }
  457. }
  458. }
  459. }