5c81efba80394bd34444c8e03faa971d5af0f6a7da9ec13a09ca1efdff6cb0fbd1ea87b365b2b96132065c82489fe2a865b18f993f63e2579930a7ab75372d 15 KB

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