tabs.scss 15 KB

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