_tabs.scss 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /**
  2. * Tabs
  3. * --------------------------------------------------
  4. * A navigation bar with any number of tab items supported.
  5. */
  6. .tabs {
  7. @include display-flex();
  8. @include flex-direction(horizontal);
  9. @include justify-content(center);
  10. @include translate3d(0,0,0);
  11. @include tab-style($tabs-default-bg, $tabs-default-border, $tabs-default-text);
  12. @include tab-badge-style($tabs-default-text, $tabs-default-bg);
  13. position: absolute;
  14. bottom: 0;
  15. z-index: $z-index-tabs;
  16. width: 100%;
  17. height: $tabs-height;
  18. border-style: solid;
  19. border-top-width: 1px;
  20. background-size: 0;
  21. line-height: $tabs-height;
  22. @media (min--moz-device-pixel-ratio: 1.5),
  23. (-webkit-min-device-pixel-ratio: 1.5),
  24. (min-device-pixel-ratio: 1.5),
  25. (min-resolution: 144dpi),
  26. (min-resolution: 1.5dppx) {
  27. padding-top: 2px;
  28. border-top: none !important;
  29. border-bottom: none;
  30. background-position: top;
  31. background-size: 100% 1px;
  32. background-repeat: no-repeat;
  33. }
  34. }
  35. /* Allow parent element of tabs to define color, or just the tab itself */
  36. .tabs-light > .tabs,
  37. .tabs.tabs-light {
  38. @include tab-style($tabs-light-bg, $tabs-light-border, $tabs-light-text);
  39. @include tab-badge-style($tabs-light-text, $tabs-light-bg);
  40. }
  41. .tabs-stable > .tabs,
  42. .tabs.tabs-stable {
  43. @include tab-style($tabs-stable-bg, $tabs-stable-border, $tabs-stable-text);
  44. @include tab-badge-style($tabs-stable-text, $tabs-stable-bg);
  45. }
  46. .tabs-positive > .tabs,
  47. .tabs.tabs-positive {
  48. @include tab-style($tabs-positive-bg, $tabs-positive-border, $tabs-positive-text);
  49. @include tab-badge-style($tabs-positive-text, $tabs-positive-bg);
  50. }
  51. .tabs-calm > .tabs,
  52. .tabs.tabs-calm {
  53. @include tab-style($tabs-calm-bg, $tabs-calm-border, $tabs-calm-text);
  54. @include tab-badge-style($tabs-calm-text, $tabs-calm-bg);
  55. }
  56. .tabs-assertive > .tabs,
  57. .tabs.tabs-assertive {
  58. @include tab-style($tabs-assertive-bg, $tabs-assertive-border, $tabs-assertive-text);
  59. @include tab-badge-style($tabs-assertive-text, $tabs-assertive-bg);
  60. }
  61. .tabs-balanced > .tabs,
  62. .tabs.tabs-balanced {
  63. @include tab-style($tabs-balanced-bg, $tabs-balanced-border, $tabs-balanced-text);
  64. @include tab-badge-style($tabs-balanced-text, $tabs-balanced-bg);
  65. }
  66. .tabs-energized > .tabs,
  67. .tabs.tabs-energized {
  68. @include tab-style($tabs-energized-bg, $tabs-energized-border, $tabs-energized-text);
  69. @include tab-badge-style($tabs-energized-text, $tabs-energized-bg);
  70. }
  71. .tabs-royal > .tabs,
  72. .tabs.tabs-royal {
  73. @include tab-style($tabs-royal-bg, $tabs-royal-border, $tabs-royal-text);
  74. @include tab-badge-style($tabs-royal-text, $tabs-royal-bg);
  75. }
  76. .tabs-dark > .tabs,
  77. .tabs.tabs-dark {
  78. @include tab-style($tabs-dark-bg, $tabs-dark-border, $tabs-dark-text);
  79. @include tab-badge-style($tabs-dark-text, $tabs-dark-bg);
  80. }
  81. @mixin tabs-striped($style, $color, $background) {
  82. &.#{$style} {
  83. .tabs{
  84. background-color: $background;
  85. }
  86. .tab-item {
  87. color: rgba($color, $tabs-striped-off-opacity);
  88. opacity: 1;
  89. .badge{
  90. opacity:$tabs-striped-off-opacity;
  91. }
  92. &.tab-item-active,
  93. &.active,
  94. &.activated {
  95. margin-top: -$tabs-striped-border-width;
  96. color: $color;
  97. border-style: solid;
  98. border-width: $tabs-striped-border-width 0 0 0;
  99. border-color: $color;
  100. }
  101. }
  102. }
  103. &.tabs-top{
  104. .tab-item {
  105. &.tab-item-active,
  106. &.active,
  107. &.activated {
  108. .badge {
  109. top: 4%;
  110. }
  111. }
  112. }
  113. }
  114. }
  115. @mixin tabs-background($style, $color, $border-color) {
  116. .#{$style} {
  117. .tabs,
  118. &> .tabs{
  119. background-color: $color;
  120. background-image: linear-gradient(0deg, $border-color, $border-color 50%, transparent 50%);
  121. border-color: $border-color;
  122. }
  123. }
  124. }
  125. @mixin tabs-striped-background($style, $color) {
  126. &.#{$style} {
  127. .tabs {
  128. background-color: $color;
  129. background-image:none;
  130. }
  131. }
  132. }
  133. @mixin tabs-color($style, $color) {
  134. .#{$style} {
  135. .tab-item {
  136. color: rgba($color, $tabs-off-opacity);
  137. opacity: 1;
  138. .badge{
  139. opacity:$tabs-off-opacity;
  140. }
  141. &.tab-item-active,
  142. &.active,
  143. &.activated {
  144. color: $color;
  145. border: 0 solid $color;
  146. .badge{
  147. opacity: 1;
  148. }
  149. }
  150. }
  151. }
  152. }
  153. @mixin tabs-striped-color($style, $color) {
  154. &.#{$style} {
  155. .tab-item {
  156. color: rgba($color, $tabs-striped-off-opacity);
  157. opacity: 1;
  158. .badge{
  159. opacity:$tabs-striped-off-opacity;
  160. }
  161. &.tab-item-active,
  162. &.active,
  163. &.activated {
  164. margin-top: -$tabs-striped-border-width;
  165. color: $color;
  166. border: 0 solid $color;
  167. border-top-width: $tabs-striped-border-width;
  168. .badge{
  169. top:$tabs-striped-border-width;
  170. opacity: 1;
  171. }
  172. }
  173. }
  174. }
  175. }
  176. .tabs-striped {
  177. .tabs {
  178. background-color: white;
  179. background-image: none;
  180. border: none;
  181. border-bottom: 1px solid #ddd;
  182. padding-top: $tabs-striped-border-width;
  183. }
  184. .tab-item {
  185. // default android tab style
  186. &.tab-item-active,
  187. &.active,
  188. &.activated {
  189. margin-top: -$tabs-striped-border-width;
  190. border-style: solid;
  191. border-width: $tabs-striped-border-width 0 0 0;
  192. border-color: $dark;
  193. .badge{
  194. top:$tabs-striped-border-width;
  195. opacity: 1;
  196. }
  197. }
  198. }
  199. @include tabs-striped('tabs-light', $dark, $light);
  200. @include tabs-striped('tabs-stable', $dark, $stable);
  201. @include tabs-striped('tabs-positive', $light, $positive);
  202. @include tabs-striped('tabs-calm', $light, $calm);
  203. @include tabs-striped('tabs-assertive', $light, $assertive);
  204. @include tabs-striped('tabs-balanced', $light, $balanced);
  205. @include tabs-striped('tabs-energized', $light, $energized);
  206. @include tabs-striped('tabs-royal', $light, $royal);
  207. @include tabs-striped('tabs-dark', $light, $dark);
  208. // doing this twice so striped tabs styles don't override specific bg and color vals
  209. @include tabs-striped-background('tabs-background-light', $light);
  210. @include tabs-striped-background('tabs-background-stable', $stable);
  211. @include tabs-striped-background('tabs-background-positive', $positive);
  212. @include tabs-striped-background('tabs-background-calm', $calm);
  213. @include tabs-striped-background('tabs-background-assertive', $assertive);
  214. @include tabs-striped-background('tabs-background-balanced', $balanced);
  215. @include tabs-striped-background('tabs-background-energized',$energized);
  216. @include tabs-striped-background('tabs-background-royal', $royal);
  217. @include tabs-striped-background('tabs-background-dark', $dark);
  218. @include tabs-striped-color('tabs-color-light', $light);
  219. @include tabs-striped-color('tabs-color-stable', $stable);
  220. @include tabs-striped-color('tabs-color-positive', $positive);
  221. @include tabs-striped-color('tabs-color-calm', $calm);
  222. @include tabs-striped-color('tabs-color-assertive', $assertive);
  223. @include tabs-striped-color('tabs-color-balanced', $balanced);
  224. @include tabs-striped-color('tabs-color-energized',$energized);
  225. @include tabs-striped-color('tabs-color-royal', $royal);
  226. @include tabs-striped-color('tabs-color-dark', $dark);
  227. }
  228. @include tabs-background('tabs-background-light', $light, $bar-light-border);
  229. @include tabs-background('tabs-background-stable', $stable, $bar-stable-border);
  230. @include tabs-background('tabs-background-positive', $positive, $bar-positive-border);
  231. @include tabs-background('tabs-background-calm', $calm, $bar-calm-border);
  232. @include tabs-background('tabs-background-assertive', $assertive, $bar-assertive-border);
  233. @include tabs-background('tabs-background-balanced', $balanced, $bar-balanced-border);
  234. @include tabs-background('tabs-background-energized',$energized, $bar-energized-border);
  235. @include tabs-background('tabs-background-royal', $royal, $bar-royal-border);
  236. @include tabs-background('tabs-background-dark', $dark, $bar-dark-border);
  237. @include tabs-color('tabs-color-light', $light);
  238. @include tabs-color('tabs-color-stable', $stable);
  239. @include tabs-color('tabs-color-positive', $positive);
  240. @include tabs-color('tabs-color-calm', $calm);
  241. @include tabs-color('tabs-color-assertive', $assertive);
  242. @include tabs-color('tabs-color-balanced', $balanced);
  243. @include tabs-color('tabs-color-energized',$energized);
  244. @include tabs-color('tabs-color-royal', $royal);
  245. @include tabs-color('tabs-color-dark', $dark);
  246. @mixin tabs-standard-color($style, $color, $off-color:$dark) {
  247. &.#{$style} {
  248. .tab-item {
  249. color: $off-color;
  250. &.tab-item-active,
  251. &.active,
  252. &.activated {
  253. color: $color;
  254. }
  255. }
  256. }
  257. &.tabs-striped.#{$style} {
  258. .tab-item {
  259. &.tab-item-active,
  260. &.active,
  261. &.activated {
  262. border-color: $color;
  263. color: $color;
  264. }
  265. }
  266. }
  267. }
  268. ion-tabs {
  269. @include tabs-standard-color('tabs-color-active-light', $light, $dark);
  270. @include tabs-standard-color('tabs-color-active-stable', $stable, $dark);
  271. @include tabs-standard-color('tabs-color-active-positive', $positive, $dark);
  272. @include tabs-standard-color('tabs-color-active-calm', $calm, $dark);
  273. @include tabs-standard-color('tabs-color-active-assertive', $assertive, $dark);
  274. @include tabs-standard-color('tabs-color-active-balanced', $balanced, $dark);
  275. @include tabs-standard-color('tabs-color-active-energized',$energized, $dark);
  276. @include tabs-standard-color('tabs-color-active-royal', $royal, $dark);
  277. @include tabs-standard-color('tabs-color-active-dark', $dark, $light);
  278. }
  279. .tabs-top {
  280. &.tabs-striped {
  281. padding-bottom:0;
  282. .tab-item{
  283. background: transparent;
  284. // animate the top bar, leave bottom for platform consistency
  285. -webkit-transition: color .1s ease;
  286. -moz-transition: color .1s ease;
  287. -ms-transition: color .1s ease;
  288. -o-transition: color .1s ease;
  289. transition: color .1s ease;
  290. &.tab-item-active,
  291. &.active,
  292. &.activated {
  293. margin-top: $tabs-striped-border-width - 1px;
  294. border-width: 0px 0px $tabs-striped-border-width 0px !important;
  295. border-style: solid;
  296. > .badge, > i{
  297. margin-top: -$tabs-striped-border-width + 1px;
  298. }
  299. }
  300. .badge{
  301. -webkit-transition: color .2s ease;
  302. -moz-transition: color .2s ease;
  303. -ms-transition: color .2s ease;
  304. -o-transition: color .2s ease;
  305. transition: color .2s ease;
  306. }
  307. }
  308. &:not(.tabs-icon-left):not(.tabs-icon-top){
  309. .tab-item{
  310. &.tab-item-active,
  311. &.active,
  312. &.activated {
  313. .tab-title, i{
  314. display:block;
  315. margin-top: -$tabs-striped-border-width + 1px;
  316. }
  317. }
  318. }
  319. }
  320. &.tabs-icon-left{
  321. .tab-item{
  322. margin-top: 1px;
  323. &.tab-item-active,
  324. &.active,
  325. &.activated {
  326. .tab-title, i {
  327. margin-top: -0.1em;
  328. }
  329. }
  330. }
  331. }
  332. }
  333. }
  334. /* Allow parent element to have tabs-top */
  335. /* If you change this, change platform.scss as well */
  336. .tabs-top > .tabs,
  337. .tabs.tabs-top {
  338. top: $bar-height;
  339. padding-top: 0;
  340. background-position: bottom;
  341. border-top-width: 0;
  342. border-bottom-width: 1px;
  343. .tab-item {
  344. &.tab-item-active,
  345. &.active,
  346. &.activated {
  347. .badge {
  348. top: 4%;
  349. }
  350. }
  351. }
  352. }
  353. .tabs-top ~ .bar-header {
  354. border-bottom-width: 0;
  355. }
  356. .tab-item {
  357. @include flex(1);
  358. display: block;
  359. overflow: hidden;
  360. max-width: $tab-item-max-width;
  361. height: 100%;
  362. color: inherit;
  363. text-align: center;
  364. text-decoration: none;
  365. text-overflow: ellipsis;
  366. white-space: nowrap;
  367. font-weight: 400;
  368. font-size: $tabs-text-font-size;
  369. font-family: $font-family-sans-serif;
  370. opacity: 0.7;
  371. &:hover {
  372. cursor: pointer;
  373. }
  374. &.tab-hidden{
  375. display:none;
  376. }
  377. }
  378. .tabs-item-hide > .tabs,
  379. .tabs.tabs-item-hide {
  380. display: none;
  381. }
  382. .tabs-icon-top > .tabs .tab-item,
  383. .tabs-icon-top.tabs .tab-item,
  384. .tabs-icon-bottom > .tabs .tab-item,
  385. .tabs-icon-bottom.tabs .tab-item {
  386. font-size: $tabs-text-font-size-side-icon;
  387. line-height: $tabs-text-font-size;
  388. }
  389. .tab-item .icon {
  390. display: block;
  391. margin: 0 auto;
  392. height: $tabs-icon-size;
  393. font-size: $tabs-icon-size;
  394. }
  395. .tabs-icon-left.tabs .tab-item,
  396. .tabs-icon-left > .tabs .tab-item,
  397. .tabs-icon-right.tabs .tab-item,
  398. .tabs-icon-right > .tabs .tab-item {
  399. font-size: $tabs-text-font-size-side-icon;
  400. .icon, .tab-title {
  401. display: inline-block;
  402. vertical-align: top;
  403. margin-top: -.1em;
  404. &:before {
  405. font-size: $tabs-icon-size - 8;
  406. line-height: $tabs-height;
  407. }
  408. }
  409. }
  410. .tabs-icon-left > .tabs .tab-item .icon,
  411. .tabs-icon-left.tabs .tab-item .icon {
  412. padding-right: 3px;
  413. }
  414. .tabs-icon-right > .tabs .tab-item .icon,
  415. .tabs-icon-right.tabs .tab-item .icon {
  416. padding-left: 3px;
  417. }
  418. .tabs-icon-only > .tabs .icon,
  419. .tabs-icon-only.tabs .icon {
  420. line-height: inherit;
  421. }
  422. .tab-item.has-badge {
  423. position: relative;
  424. }
  425. .tab-item .badge {
  426. position: absolute;
  427. top: 4%;
  428. right: 33%; // fallback
  429. right: calc(50% - 26px);
  430. padding: $tabs-badge-padding;
  431. height: auto;
  432. font-size: $tabs-badge-font-size;
  433. line-height: $tabs-badge-font-size + 4;
  434. }
  435. /* Navigational tab */
  436. /* Active state for tab */
  437. .tab-item.tab-item-active,
  438. .tab-item.active,
  439. .tab-item.activated {
  440. opacity: 1;
  441. &.tab-item-light {
  442. color: $light;
  443. }
  444. &.tab-item-stable {
  445. color: $stable;
  446. }
  447. &.tab-item-positive {
  448. color: $positive;
  449. }
  450. &.tab-item-calm {
  451. color: $calm;
  452. }
  453. &.tab-item-assertive {
  454. color: $assertive;
  455. }
  456. &.tab-item-balanced {
  457. color: $balanced;
  458. }
  459. &.tab-item-energized {
  460. color: $energized;
  461. }
  462. &.tab-item-royal {
  463. color: $royal;
  464. }
  465. &.tab-item-dark {
  466. color: $dark;
  467. }
  468. }
  469. .item.tabs {
  470. @include display-flex();
  471. padding: 0;
  472. .icon:before {
  473. position: relative;
  474. }
  475. }
  476. .tab-item.disabled,
  477. .tab-item[disabled] {
  478. opacity: .4;
  479. cursor: default;
  480. pointer-events: none;
  481. }
  482. .nav-bar-tabs-top.hide ~ .view-container .tabs-top .tabs{
  483. top: 0
  484. }
  485. .pane[hide-nav-bar="true"] .has-tabs-top{
  486. top:$tabs-height
  487. }