tabs.scss 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. @use 'mixins/mixins' as *;
  2. @use 'common/var' as *;
  3. @include b(tabs) {
  4. @include set-component-css-var('tabs', $tabs);
  5. @include e(header) {
  6. padding: 0;
  7. position: relative;
  8. margin: 0 0 15px;
  9. }
  10. @include e(active-bar) {
  11. position: absolute;
  12. bottom: 0;
  13. left: 0;
  14. height: 2px;
  15. background-color: getCssVar('color-primary');
  16. z-index: 1;
  17. transition: width getCssVar('transition-duration')
  18. getCssVar('transition-function-ease-in-out-bezier'),
  19. transform getCssVar('transition-duration')
  20. getCssVar('transition-function-ease-in-out-bezier');
  21. list-style: none;
  22. }
  23. @include e(new-tab) {
  24. display: flex;
  25. align-items: center;
  26. justify-content: center;
  27. float: right;
  28. border: 1px solid getCssVar('border-color');
  29. height: 20px;
  30. width: 20px;
  31. line-height: 20px;
  32. margin: 10px 0 10px 10px;
  33. border-radius: 3px;
  34. text-align: center;
  35. font-size: 12px;
  36. color: getCssVar('text-color', 'primary');
  37. cursor: pointer;
  38. transition: all 0.15s;
  39. .is-icon-plus {
  40. height: inherit;
  41. width: inherit;
  42. transform: scale(0.8, 0.8);
  43. svg {
  44. vertical-align: middle;
  45. }
  46. }
  47. &:hover {
  48. color: getCssVar('color-primary');
  49. }
  50. }
  51. @include e(nav-wrap) {
  52. overflow: hidden;
  53. margin-bottom: -1px;
  54. position: relative;
  55. &::after {
  56. content: '';
  57. position: absolute;
  58. left: 0;
  59. bottom: 0;
  60. width: 100%;
  61. height: 2px;
  62. background-color: getCssVar('border-color-light');
  63. z-index: getCssVar('index-normal');
  64. }
  65. @include when(scrollable) {
  66. padding: 0 20px;
  67. box-sizing: border-box;
  68. }
  69. }
  70. @include e(nav-scroll) {
  71. overflow: hidden;
  72. }
  73. @include e((nav-next, nav-prev)) {
  74. position: absolute;
  75. cursor: pointer;
  76. line-height: 44px;
  77. font-size: 12px;
  78. color: getCssVar('text-color', 'secondary');
  79. width: 20px;
  80. text-align: center;
  81. }
  82. @include e(nav-next) {
  83. right: 0;
  84. }
  85. @include e(nav-prev) {
  86. left: 0;
  87. }
  88. @include e(nav) {
  89. display: flex;
  90. white-space: nowrap;
  91. position: relative;
  92. transition: transform getCssVar('transition-duration');
  93. float: left;
  94. z-index: calc(#{getCssVar('index-normal')} + 1);
  95. @include when(stretch) {
  96. min-width: 100%;
  97. display: flex;
  98. & > * {
  99. flex: 1;
  100. text-align: center;
  101. }
  102. }
  103. }
  104. @include e(item) {
  105. padding: 0 20px;
  106. height: getCssVar('tabs', 'header-height');
  107. box-sizing: border-box;
  108. display: flex;
  109. align-items: center;
  110. justify-content: center;
  111. list-style: none;
  112. font-size: getCssVar('font-size-base');
  113. font-weight: 500;
  114. color: getCssVar('text-color', 'primary');
  115. position: relative;
  116. &:focus,
  117. &:focus:active {
  118. outline: none;
  119. }
  120. &:focus-visible {
  121. box-shadow: 0 0 2px 2px getCssVar('color-primary') inset;
  122. border-radius: 3px;
  123. }
  124. & .is-icon-close {
  125. border-radius: 50%;
  126. text-align: center;
  127. transition: all getCssVar('transition-duration')
  128. getCssVar('transition-function-ease-in-out-bezier');
  129. margin-left: 5px;
  130. &:before {
  131. transform: scale(0.9);
  132. display: inline-block;
  133. }
  134. &:hover {
  135. background-color: getCssVar('text-color', 'placeholder');
  136. color: $color-white;
  137. }
  138. }
  139. @include when(active) {
  140. color: getCssVar('color-primary');
  141. }
  142. &:hover {
  143. color: getCssVar('color-primary');
  144. cursor: pointer;
  145. }
  146. @include when(disabled) {
  147. color: getCssVar('disabled-text-color');
  148. cursor: not-allowed;
  149. }
  150. }
  151. @include e(content) {
  152. overflow: hidden;
  153. position: relative;
  154. }
  155. @include m(card) {
  156. > .#{$namespace}-tabs__header {
  157. border-bottom: 1px solid getCssVar('border-color-light');
  158. height: getCssVar('tabs', 'header-height');
  159. }
  160. > .#{$namespace}-tabs__header .#{$namespace}-tabs__nav-wrap::after {
  161. content: none;
  162. }
  163. > .#{$namespace}-tabs__header .#{$namespace}-tabs__nav {
  164. border: 1px solid getCssVar('border-color-light');
  165. border-bottom: none;
  166. border-radius: 4px 4px 0 0;
  167. box-sizing: border-box;
  168. }
  169. > .#{$namespace}-tabs__header .#{$namespace}-tabs__active-bar {
  170. display: none;
  171. }
  172. > .#{$namespace}-tabs__header .#{$namespace}-tabs__item .is-icon-close {
  173. position: relative;
  174. font-size: 12px;
  175. width: 0;
  176. height: 14px;
  177. overflow: hidden;
  178. right: -2px;
  179. transform-origin: 100% 50%;
  180. }
  181. > .#{$namespace}-tabs__header .#{$namespace}-tabs__item {
  182. border-bottom: 1px solid transparent;
  183. border-left: 1px solid getCssVar('border-color-light');
  184. transition: color getCssVar('transition-duration')
  185. getCssVar('transition-function-ease-in-out-bezier'),
  186. padding getCssVar('transition-duration')
  187. getCssVar('transition-function-ease-in-out-bezier');
  188. &:first-child {
  189. border-left: none;
  190. }
  191. &.is-closable {
  192. &:hover {
  193. padding-left: 13px;
  194. padding-right: 13px;
  195. & .is-icon-close {
  196. width: 14px;
  197. }
  198. }
  199. }
  200. &.is-active {
  201. border-bottom-color: getCssVar('bg-color');
  202. &.is-closable {
  203. padding-left: 20px;
  204. padding-right: 20px;
  205. .is-icon-close {
  206. width: 14px;
  207. }
  208. }
  209. }
  210. }
  211. }
  212. @include m(border-card) {
  213. background: getCssVar('bg-color', 'overlay');
  214. border: 1px solid getCssVar('border-color');
  215. > .#{$namespace}-tabs__content {
  216. padding: 15px;
  217. }
  218. > .#{$namespace}-tabs__header {
  219. background-color: getCssVar('fill-color', 'light');
  220. border-bottom: 1px solid getCssVar('border-color-light');
  221. margin: 0;
  222. }
  223. > .#{$namespace}-tabs__header .#{$namespace}-tabs__nav-wrap::after {
  224. content: none;
  225. }
  226. > .#{$namespace}-tabs__header .#{$namespace}-tabs__item {
  227. transition: all getCssVar('transition-duration')
  228. getCssVar('transition-function-ease-in-out-bezier');
  229. border: 1px solid transparent;
  230. margin-top: -1px;
  231. color: getCssVar('text-color', 'secondary');
  232. &:first-child {
  233. margin-left: -1px;
  234. }
  235. & + .#{$namespace}-tabs__item {
  236. margin-left: -1px;
  237. }
  238. &.is-active {
  239. color: getCssVar('color-primary');
  240. background-color: getCssVar('bg-color', 'overlay');
  241. border-right-color: getCssVar('border-color');
  242. border-left-color: getCssVar('border-color');
  243. }
  244. &:not(.is-disabled):hover {
  245. color: getCssVar('color-primary');
  246. }
  247. &.is-disabled {
  248. color: getCssVar('disabled-text-color');
  249. }
  250. }
  251. > .#{$namespace}-tabs__header
  252. .is-scrollable
  253. .#{$namespace}-tabs__item:first-child {
  254. margin-left: 0;
  255. }
  256. }
  257. @include m((top, bottom)) {
  258. .#{$namespace}-tabs__item.is-top:nth-child(2),
  259. .#{$namespace}-tabs__item.is-bottom:nth-child(2) {
  260. padding-left: 0;
  261. }
  262. .#{$namespace}-tabs__item.is-top:last-child,
  263. .#{$namespace}-tabs__item.is-bottom:last-child {
  264. padding-right: 0;
  265. }
  266. &.#{$namespace}-tabs--border-card,
  267. &.#{$namespace}-tabs--card,
  268. .#{$namespace}-tabs--left,
  269. .#{$namespace}-tabs--right {
  270. > .#{$namespace}-tabs__header {
  271. .#{$namespace}-tabs__item:nth-child(2) {
  272. padding-left: 20px;
  273. &:not(.is-active).is-closable:hover {
  274. padding-left: 13px;
  275. }
  276. }
  277. .#{$namespace}-tabs__item:last-child {
  278. padding-right: 20px;
  279. &:not(.is-active).is-closable:hover {
  280. padding-right: 13px;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. @include m(bottom) {
  287. .#{$namespace}-tabs__header.is-bottom {
  288. margin-bottom: 0;
  289. margin-top: 10px;
  290. }
  291. &.#{$namespace}-tabs--border-card {
  292. .#{$namespace}-tabs__header.is-bottom {
  293. border-bottom: 0;
  294. border-top: 1px solid getCssVar('border-color');
  295. }
  296. .#{$namespace}-tabs__nav-wrap.is-bottom {
  297. margin-top: -1px;
  298. margin-bottom: 0;
  299. }
  300. .#{$namespace}-tabs__item.is-bottom:not(.is-active) {
  301. border: 1px solid transparent;
  302. }
  303. .#{$namespace}-tabs__item.is-bottom {
  304. margin: 0 -1px -1px;
  305. }
  306. }
  307. }
  308. @include m((left, right)) {
  309. overflow: hidden;
  310. .#{$namespace}-tabs__header.is-left,
  311. .#{$namespace}-tabs__header.is-right,
  312. .#{$namespace}-tabs__nav-wrap.is-left,
  313. .#{$namespace}-tabs__nav-wrap.is-right,
  314. .#{$namespace}-tabs__nav-scroll {
  315. height: 100%;
  316. }
  317. .#{$namespace}-tabs__active-bar.is-left,
  318. .#{$namespace}-tabs__active-bar.is-right {
  319. top: 0;
  320. bottom: auto;
  321. width: 2px;
  322. height: auto;
  323. }
  324. .#{$namespace}-tabs__nav-wrap.is-left,
  325. .#{$namespace}-tabs__nav-wrap.is-right {
  326. margin-bottom: 0;
  327. > .#{$namespace}-tabs__nav-prev,
  328. > .#{$namespace}-tabs__nav-next {
  329. height: 30px;
  330. line-height: 30px;
  331. width: 100%;
  332. text-align: center;
  333. cursor: pointer;
  334. i {
  335. transform: rotateZ(90deg);
  336. }
  337. }
  338. > .#{$namespace}-tabs__nav-prev {
  339. left: auto;
  340. top: 0;
  341. }
  342. > .#{$namespace}-tabs__nav-next {
  343. right: auto;
  344. bottom: 0;
  345. }
  346. &.is-scrollable {
  347. padding: 30px 0;
  348. }
  349. &::after {
  350. height: 100%;
  351. width: 2px;
  352. bottom: auto;
  353. top: 0;
  354. }
  355. }
  356. .#{$namespace}-tabs__nav.is-left,
  357. .#{$namespace}-tabs__nav.is-right {
  358. flex-direction: column;
  359. }
  360. .#{$namespace}-tabs__item.is-left {
  361. justify-content: flex-end;
  362. }
  363. .#{$namespace}-tabs__item.is-right {
  364. justify-content: flex-start;
  365. }
  366. }
  367. @include m(left) {
  368. .#{$namespace}-tabs__header.is-left {
  369. float: left;
  370. margin-bottom: 0;
  371. margin-right: 10px;
  372. }
  373. .#{$namespace}-tabs__nav-wrap.is-left {
  374. margin-right: -1px;
  375. &::after {
  376. left: auto;
  377. right: 0;
  378. }
  379. }
  380. .#{$namespace}-tabs__active-bar.is-left {
  381. right: 0;
  382. left: auto;
  383. }
  384. .#{$namespace}-tabs__item.is-left {
  385. text-align: right;
  386. }
  387. &.#{$namespace}-tabs--card {
  388. .#{$namespace}-tabs__active-bar.is-left {
  389. display: none;
  390. }
  391. .#{$namespace}-tabs__item.is-left {
  392. border-left: none;
  393. border-right: 1px solid getCssVar('border-color-light');
  394. border-bottom: none;
  395. border-top: 1px solid getCssVar('border-color-light');
  396. text-align: left;
  397. }
  398. .#{$namespace}-tabs__item.is-left:first-child {
  399. border-right: 1px solid getCssVar('border-color-light');
  400. border-top: none;
  401. }
  402. .#{$namespace}-tabs__item.is-left.is-active {
  403. border: 1px solid getCssVar('border-color-light');
  404. border-right-color: #fff;
  405. border-left: none;
  406. border-bottom: none;
  407. &:first-child {
  408. border-top: none;
  409. }
  410. &:last-child {
  411. border-bottom: none;
  412. }
  413. }
  414. .#{$namespace}-tabs__nav {
  415. border-radius: 4px 0 0 4px;
  416. border-bottom: 1px solid getCssVar('border-color-light');
  417. border-right: none;
  418. }
  419. .#{$namespace}-tabs__new-tab {
  420. float: none;
  421. }
  422. }
  423. &.#{$namespace}-tabs--border-card {
  424. .#{$namespace}-tabs__header.is-left {
  425. border-right: 1px solid getCssVar('border-color');
  426. }
  427. .#{$namespace}-tabs__item.is-left {
  428. border: 1px solid transparent;
  429. margin: -1px 0 -1px -1px;
  430. &.is-active {
  431. border-color: transparent;
  432. border-top-color: rgb(209, 219, 229);
  433. border-bottom-color: rgb(209, 219, 229);
  434. }
  435. }
  436. }
  437. }
  438. @include m(right) {
  439. .#{$namespace}-tabs__header.is-right {
  440. float: right;
  441. margin-bottom: 0;
  442. margin-left: 10px;
  443. }
  444. .#{$namespace}-tabs__nav-wrap.is-right {
  445. margin-left: -1px;
  446. &::after {
  447. left: 0;
  448. right: auto;
  449. }
  450. }
  451. .#{$namespace}-tabs__active-bar.is-right {
  452. left: 0;
  453. }
  454. &.#{$namespace}-tabs--card {
  455. .#{$namespace}-tabs__active-bar.is-right {
  456. display: none;
  457. }
  458. .#{$namespace}-tabs__item.is-right {
  459. border-bottom: none;
  460. border-top: 1px solid getCssVar('border-color-light');
  461. }
  462. .#{$namespace}-tabs__item.is-right:first-child {
  463. border-left: 1px solid getCssVar('border-color-light');
  464. border-top: none;
  465. }
  466. .#{$namespace}-tabs__item.is-right.is-active {
  467. border: 1px solid getCssVar('border-color-light');
  468. border-left-color: #fff;
  469. border-right: none;
  470. border-bottom: none;
  471. &:first-child {
  472. border-top: none;
  473. }
  474. &:last-child {
  475. border-bottom: none;
  476. }
  477. }
  478. .#{$namespace}-tabs__nav {
  479. border-radius: 0 4px 4px 0;
  480. border-bottom: 1px solid getCssVar('border-color-light');
  481. border-left: none;
  482. }
  483. }
  484. &.#{$namespace}-tabs--border-card {
  485. .#{$namespace}-tabs__header.is-right {
  486. border-left: 1px solid getCssVar('border-color');
  487. }
  488. .#{$namespace}-tabs__item.is-right {
  489. border: 1px solid transparent;
  490. margin: -1px -1px -1px 0;
  491. &.is-active {
  492. border-color: transparent;
  493. border-top-color: rgb(209, 219, 229);
  494. border-bottom-color: rgb(209, 219, 229);
  495. }
  496. }
  497. }
  498. }
  499. }
  500. .slideInRight-transition,
  501. .slideInLeft-transition {
  502. display: inline-block;
  503. }
  504. .slideInRight-enter {
  505. animation: slideInRight-enter getCssVar('transition-duration');
  506. }
  507. .slideInRight-leave {
  508. position: absolute;
  509. left: 0;
  510. right: 0;
  511. animation: slideInRight-leave getCssVar('transition-duration');
  512. }
  513. .slideInLeft-enter {
  514. animation: slideInLeft-enter getCssVar('transition-duration');
  515. }
  516. .slideInLeft-leave {
  517. position: absolute;
  518. left: 0;
  519. right: 0;
  520. animation: slideInLeft-leave getCssVar('transition-duration');
  521. }
  522. @keyframes slideInRight-enter {
  523. 0% {
  524. opacity: 0;
  525. transform-origin: 0 0;
  526. transform: translateX(100%);
  527. }
  528. to {
  529. opacity: 1;
  530. transform-origin: 0 0;
  531. transform: translateX(0);
  532. }
  533. }
  534. @keyframes slideInRight-leave {
  535. 0% {
  536. transform-origin: 0 0;
  537. transform: translateX(0);
  538. opacity: 1;
  539. }
  540. 100% {
  541. transform-origin: 0 0;
  542. transform: translateX(100%);
  543. opacity: 0;
  544. }
  545. }
  546. @keyframes slideInLeft-enter {
  547. 0% {
  548. opacity: 0;
  549. transform-origin: 0 0;
  550. transform: translateX(-100%);
  551. }
  552. to {
  553. opacity: 1;
  554. transform-origin: 0 0;
  555. transform: translateX(0);
  556. }
  557. }
  558. @keyframes slideInLeft-leave {
  559. 0% {
  560. transform-origin: 0 0;
  561. transform: translateX(0);
  562. opacity: 1;
  563. }
  564. 100% {
  565. transform-origin: 0 0;
  566. transform: translateX(-100%);
  567. opacity: 0;
  568. }
  569. }