_offcanvas.scss 15 KB

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