_offcanvas.scss 17 KB

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