tabs.scss 15 KB

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