tabs.scss 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  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. }
  193. > .#{$namespace}-tabs__header .#{$namespace}-tabs__nav-wrap::after {
  194. content: none;
  195. }
  196. > .#{$namespace}-tabs__header .#{$namespace}-tabs__nav {
  197. border: 1px solid getCssVar('border-color-light');
  198. border-bottom: none;
  199. border-radius: 4px 4px 0 0;
  200. box-sizing: border-box;
  201. }
  202. > .#{$namespace}-tabs__header .#{$namespace}-tabs__active-bar {
  203. display: none;
  204. }
  205. > .#{$namespace}-tabs__header .#{$namespace}-tabs__item .is-icon-close {
  206. position: relative;
  207. font-size: 12px;
  208. width: 0;
  209. height: 14px;
  210. overflow: hidden;
  211. right: -2px;
  212. transform-origin: 100% 50%;
  213. }
  214. > .#{$namespace}-tabs__header .#{$namespace}-tabs__item {
  215. border-bottom: 1px solid transparent;
  216. border-left: 1px solid getCssVar('border-color-light');
  217. transition: color getCssVar('transition-duration')
  218. getCssVar('transition-function-ease-in-out-bezier'),
  219. padding getCssVar('transition-duration')
  220. getCssVar('transition-function-ease-in-out-bezier');
  221. &:first-child {
  222. border-left: none;
  223. }
  224. &.is-closable {
  225. &:hover {
  226. padding-left: 13px;
  227. padding-right: 13px;
  228. & .is-icon-close {
  229. width: 14px;
  230. }
  231. }
  232. }
  233. &.is-active {
  234. border-bottom-color: getCssVar('bg-color');
  235. &.is-closable {
  236. padding-left: 20px;
  237. padding-right: 20px;
  238. .is-icon-close {
  239. width: 14px;
  240. }
  241. }
  242. }
  243. }
  244. }
  245. @include m(border-card) {
  246. background: getCssVar('bg-color', 'overlay');
  247. border: 1px solid getCssVar('border-color');
  248. > .#{$namespace}-tabs__content {
  249. padding: 15px;
  250. }
  251. > .#{$namespace}-tabs__header {
  252. background-color: getCssVar('fill-color', 'light');
  253. border-bottom: 1px solid getCssVar('border-color-light');
  254. margin: 0;
  255. }
  256. > .#{$namespace}-tabs__header .#{$namespace}-tabs__nav-wrap::after {
  257. content: none;
  258. }
  259. > .#{$namespace}-tabs__header .#{$namespace}-tabs__item {
  260. transition: all getCssVar('transition-duration')
  261. getCssVar('transition-function-ease-in-out-bezier');
  262. border: 1px solid transparent;
  263. margin-top: -1px;
  264. color: getCssVar('text-color', 'secondary');
  265. &:first-child {
  266. margin-left: -1px;
  267. }
  268. & + .#{$namespace}-tabs__item {
  269. margin-left: -1px;
  270. }
  271. &.is-active {
  272. color: getCssVar('color-primary');
  273. background-color: getCssVar('bg-color', 'overlay');
  274. border-right-color: getCssVar('border-color');
  275. border-left-color: getCssVar('border-color');
  276. }
  277. &:not(.is-disabled):hover {
  278. color: getCssVar('color-primary');
  279. }
  280. &.is-disabled {
  281. color: getCssVar('disabled-text-color');
  282. }
  283. }
  284. > .#{$namespace}-tabs__header
  285. .is-scrollable
  286. .#{$namespace}-tabs__item:first-child {
  287. margin-left: 0;
  288. }
  289. }
  290. @include m(bottom) {
  291. flex-direction: column;
  292. .#{$namespace}-tabs__header.is-bottom {
  293. margin-bottom: 0;
  294. margin-top: 10px;
  295. }
  296. &.#{$namespace}-tabs--border-card {
  297. .#{$namespace}-tabs__header.is-bottom {
  298. border-bottom: 0;
  299. border-top: 1px solid getCssVar('border-color');
  300. }
  301. .#{$namespace}-tabs__nav-wrap.is-bottom {
  302. margin-top: -1px;
  303. margin-bottom: 0;
  304. }
  305. .#{$namespace}-tabs__item.is-bottom:not(.is-active) {
  306. border: 1px solid transparent;
  307. }
  308. .#{$namespace}-tabs__item.is-bottom {
  309. margin: 0 -1px -1px;
  310. }
  311. }
  312. }
  313. @include m((left, right)) {
  314. overflow: hidden;
  315. .#{$namespace}-tabs__header.is-left,
  316. .#{$namespace}-tabs__header.is-right,
  317. .#{$namespace}-tabs__nav-wrap.is-left,
  318. .#{$namespace}-tabs__nav-wrap.is-right,
  319. .#{$namespace}-tabs__nav-scroll {
  320. height: 100%;
  321. }
  322. .#{$namespace}-tabs__active-bar.is-left,
  323. .#{$namespace}-tabs__active-bar.is-right {
  324. top: 0;
  325. bottom: auto;
  326. width: 2px;
  327. height: auto;
  328. }
  329. .#{$namespace}-tabs__nav-wrap.is-left,
  330. .#{$namespace}-tabs__nav-wrap.is-right {
  331. margin-bottom: 0;
  332. > .#{$namespace}-tabs__nav-prev,
  333. > .#{$namespace}-tabs__nav-next {
  334. height: 30px;
  335. line-height: 30px;
  336. width: 100%;
  337. text-align: center;
  338. cursor: pointer;
  339. i {
  340. transform: rotateZ(90deg);
  341. }
  342. }
  343. > .#{$namespace}-tabs__nav-prev {
  344. left: auto;
  345. top: 0;
  346. }
  347. > .#{$namespace}-tabs__nav-next {
  348. right: auto;
  349. bottom: 0;
  350. }
  351. &.is-scrollable {
  352. padding: 30px 0;
  353. }
  354. &::after {
  355. height: 100%;
  356. width: 2px;
  357. bottom: auto;
  358. top: 0;
  359. }
  360. }
  361. .#{$namespace}-tabs__nav.is-left,
  362. .#{$namespace}-tabs__nav.is-right {
  363. flex-direction: column;
  364. }
  365. .#{$namespace}-tabs__item.is-left {
  366. justify-content: flex-end;
  367. }
  368. .#{$namespace}-tabs__item.is-right {
  369. justify-content: flex-start;
  370. }
  371. }
  372. @include m(left) {
  373. flex-direction: row-reverse;
  374. .#{$namespace}-tabs__header.is-left {
  375. margin-bottom: 0;
  376. margin-right: 10px;
  377. }
  378. .#{$namespace}-tabs__nav-wrap.is-left {
  379. margin-right: -1px;
  380. &::after {
  381. left: auto;
  382. right: 0;
  383. }
  384. }
  385. .#{$namespace}-tabs__active-bar.is-left {
  386. right: 0;
  387. left: auto;
  388. }
  389. .#{$namespace}-tabs__item.is-left {
  390. text-align: right;
  391. }
  392. &.#{$namespace}-tabs--card {
  393. .#{$namespace}-tabs__active-bar.is-left {
  394. display: none;
  395. }
  396. .#{$namespace}-tabs__item.is-left {
  397. border-left: none;
  398. border-right: 1px solid getCssVar('border-color-light');
  399. border-bottom: none;
  400. border-top: 1px solid getCssVar('border-color-light');
  401. text-align: left;
  402. }
  403. .#{$namespace}-tabs__item.is-left:first-child {
  404. border-right: 1px solid getCssVar('border-color-light');
  405. border-top: none;
  406. }
  407. .#{$namespace}-tabs__item.is-left.is-active {
  408. border: 1px solid getCssVar('border-color-light');
  409. border-right-color: #fff;
  410. border-left: none;
  411. border-bottom: none;
  412. &:first-child {
  413. border-top: none;
  414. }
  415. &:last-child {
  416. border-bottom: none;
  417. }
  418. }
  419. .#{$namespace}-tabs__nav {
  420. border-radius: 4px 0 0 4px;
  421. border-bottom: 1px solid getCssVar('border-color-light');
  422. border-right: none;
  423. }
  424. .#{$namespace}-tabs__new-tab {
  425. float: none;
  426. }
  427. }
  428. &.#{$namespace}-tabs--border-card {
  429. .#{$namespace}-tabs__header.is-left {
  430. border-right: 1px solid getCssVar('border-color');
  431. }
  432. .#{$namespace}-tabs__item.is-left {
  433. border: 1px solid transparent;
  434. margin: -1px 0 -1px -1px;
  435. &.is-active {
  436. border-color: transparent;
  437. border-top-color: rgb(209, 219, 229);
  438. border-bottom-color: rgb(209, 219, 229);
  439. }
  440. }
  441. }
  442. }
  443. @include m(right) {
  444. .#{$namespace}-tabs__header.is-right {
  445. margin-bottom: 0;
  446. margin-left: 10px;
  447. }
  448. .#{$namespace}-tabs__nav-wrap.is-right {
  449. margin-left: -1px;
  450. &::after {
  451. left: 0;
  452. right: auto;
  453. }
  454. }
  455. .#{$namespace}-tabs__active-bar.is-right {
  456. left: 0;
  457. }
  458. &.#{$namespace}-tabs--card {
  459. .#{$namespace}-tabs__active-bar.is-right {
  460. display: none;
  461. }
  462. .#{$namespace}-tabs__item.is-right {
  463. border-bottom: none;
  464. border-top: 1px solid getCssVar('border-color-light');
  465. }
  466. .#{$namespace}-tabs__item.is-right:first-child {
  467. border-left: 1px solid getCssVar('border-color-light');
  468. border-top: none;
  469. }
  470. .#{$namespace}-tabs__item.is-right.is-active {
  471. border: 1px solid getCssVar('border-color-light');
  472. border-left-color: #fff;
  473. border-right: none;
  474. border-bottom: none;
  475. &:first-child {
  476. border-top: none;
  477. }
  478. &:last-child {
  479. border-bottom: none;
  480. }
  481. }
  482. .#{$namespace}-tabs__nav {
  483. border-radius: 0 4px 4px 0;
  484. border-bottom: 1px solid getCssVar('border-color-light');
  485. border-left: none;
  486. }
  487. }
  488. &.#{$namespace}-tabs--border-card {
  489. .#{$namespace}-tabs__header.is-right {
  490. border-left: 1px solid getCssVar('border-color');
  491. }
  492. .#{$namespace}-tabs__item.is-right {
  493. border: 1px solid transparent;
  494. margin: -1px -1px -1px 0;
  495. &.is-active {
  496. border-color: transparent;
  497. border-top-color: rgb(209, 219, 229);
  498. border-bottom-color: rgb(209, 219, 229);
  499. }
  500. }
  501. }
  502. }
  503. @include m(top) {
  504. flex-direction: column-reverse;
  505. }
  506. }
  507. .slideInRight-transition,
  508. .slideInLeft-transition {
  509. display: inline-block;
  510. }
  511. .slideInRight-enter {
  512. animation: slideInRight-enter getCssVar('transition-duration');
  513. }
  514. .slideInRight-leave {
  515. position: absolute;
  516. left: 0;
  517. right: 0;
  518. animation: slideInRight-leave getCssVar('transition-duration');
  519. }
  520. .slideInLeft-enter {
  521. animation: slideInLeft-enter getCssVar('transition-duration');
  522. }
  523. .slideInLeft-leave {
  524. position: absolute;
  525. left: 0;
  526. right: 0;
  527. animation: slideInLeft-leave getCssVar('transition-duration');
  528. }
  529. @keyframes slideInRight-enter {
  530. 0% {
  531. opacity: 0;
  532. transform-origin: 0 0;
  533. transform: translateX(100%);
  534. }
  535. to {
  536. opacity: 1;
  537. transform-origin: 0 0;
  538. transform: translateX(0);
  539. }
  540. }
  541. @keyframes slideInRight-leave {
  542. 0% {
  543. transform-origin: 0 0;
  544. transform: translateX(0);
  545. opacity: 1;
  546. }
  547. 100% {
  548. transform-origin: 0 0;
  549. transform: translateX(100%);
  550. opacity: 0;
  551. }
  552. }
  553. @keyframes slideInLeft-enter {
  554. 0% {
  555. opacity: 0;
  556. transform-origin: 0 0;
  557. transform: translateX(-100%);
  558. }
  559. to {
  560. opacity: 1;
  561. transform-origin: 0 0;
  562. transform: translateX(0);
  563. }
  564. }
  565. @keyframes slideInLeft-leave {
  566. 0% {
  567. transform-origin: 0 0;
  568. transform: translateX(0);
  569. opacity: 1;
  570. }
  571. 100% {
  572. transform-origin: 0 0;
  573. transform: translateX(-100%);
  574. opacity: 0;
  575. }
  576. }