panel.less 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. @picker-cell-inner-cls: ~'@{picker-prefix-cls}-cell-inner';
  2. .@{picker-prefix-cls} {
  3. @picker-arrow-size: 7px;
  4. @picker-year-month-cell-width: 60px;
  5. @picker-panel-width: @picker-panel-cell-width * 7 + @padding-sm * 2 + 4;
  6. &-panel {
  7. display: inline-flex;
  8. flex-direction: column;
  9. text-align: center;
  10. background: @calendar-bg;
  11. border: @border-width-base @border-style-base @picker-border-color;
  12. border-radius: @border-radius-base;
  13. outline: none;
  14. &-focused {
  15. border-color: @primary-color;
  16. }
  17. }
  18. // ========================================================
  19. // = Shared Panel =
  20. // ========================================================
  21. &-decade-panel,
  22. &-year-panel,
  23. &-quarter-panel,
  24. &-month-panel,
  25. &-week-panel,
  26. &-date-panel,
  27. &-time-panel {
  28. display: flex;
  29. flex-direction: column;
  30. width: @picker-panel-width;
  31. }
  32. // ======================= Header =======================
  33. &-header {
  34. display: flex;
  35. padding: 0 @padding-xs;
  36. color: @heading-color;
  37. border-bottom: @border-width-base @border-style-base @picker-border-color;
  38. > * {
  39. flex: none;
  40. }
  41. button {
  42. padding: 0;
  43. color: @disabled-color;
  44. line-height: @picker-text-height;
  45. background: transparent;
  46. border: 0;
  47. cursor: pointer;
  48. transition: color @animation-duration-slow;
  49. }
  50. > button {
  51. min-width: 1.6em;
  52. font-size: @font-size-base;
  53. &:hover {
  54. color: @text-color;
  55. }
  56. }
  57. &-view {
  58. flex: auto;
  59. font-weight: 500;
  60. line-height: @picker-text-height;
  61. button {
  62. color: inherit;
  63. font-weight: inherit;
  64. &:not(:first-child) {
  65. margin-left: @padding-xs;
  66. }
  67. &:hover {
  68. color: @primary-color;
  69. }
  70. }
  71. }
  72. }
  73. // Arrow button
  74. &-prev-icon,
  75. &-next-icon,
  76. &-super-prev-icon,
  77. &-super-next-icon {
  78. position: relative;
  79. display: inline-block;
  80. width: @picker-arrow-size;
  81. height: @picker-arrow-size;
  82. &::before {
  83. position: absolute;
  84. top: 0;
  85. left: 0;
  86. display: inline-block;
  87. width: @picker-arrow-size;
  88. height: @picker-arrow-size;
  89. border: 0 solid currentcolor;
  90. border-width: 1.5px 0 0 1.5px;
  91. content: '';
  92. }
  93. }
  94. &-super-prev-icon,
  95. &-super-next-icon {
  96. &::after {
  97. position: absolute;
  98. top: ceil((@picker-arrow-size / 2));
  99. left: ceil((@picker-arrow-size / 2));
  100. display: inline-block;
  101. width: @picker-arrow-size;
  102. height: @picker-arrow-size;
  103. border: 0 solid currentcolor;
  104. border-width: 1.5px 0 0 1.5px;
  105. content: '';
  106. }
  107. }
  108. &-prev-icon,
  109. &-super-prev-icon {
  110. transform: rotate(-45deg);
  111. }
  112. &-next-icon,
  113. &-super-next-icon {
  114. transform: rotate(135deg);
  115. }
  116. // ======================== Body ========================
  117. &-content {
  118. width: 100%;
  119. table-layout: fixed;
  120. border-collapse: collapse;
  121. th,
  122. td {
  123. position: relative;
  124. min-width: 24px;
  125. font-weight: 400;
  126. }
  127. th {
  128. height: 30px;
  129. color: @text-color;
  130. line-height: 30px;
  131. }
  132. }
  133. .picker-cell-inner(@cellClassName) {
  134. &::before {
  135. position: absolute;
  136. top: 50%;
  137. right: 0;
  138. left: 0;
  139. z-index: 1;
  140. height: @picker-panel-cell-height;
  141. transform: translateY(-50%);
  142. transition: all @animation-duration-slow;
  143. content: '';
  144. }
  145. // >>> Default
  146. .@{cellClassName} {
  147. position: relative;
  148. z-index: 2;
  149. display: inline-block;
  150. min-width: @picker-panel-cell-height;
  151. height: @picker-panel-cell-height;
  152. line-height: @picker-panel-cell-height;
  153. border-radius: @border-radius-base;
  154. transition: background @animation-duration-slow, border @animation-duration-slow;
  155. }
  156. // >>> Hover
  157. &:hover:not(&-in-view),
  158. &:hover:not(&-selected):not(&-range-start):not(&-range-end):not(&-range-hover-start):not(&-range-hover-end) {
  159. .@{cellClassName} {
  160. background: @picker-basic-cell-hover-color;
  161. }
  162. }
  163. // >>> Today
  164. &-in-view&-today .@{cellClassName} {
  165. &::before {
  166. position: absolute;
  167. top: 0;
  168. right: 0;
  169. bottom: 0;
  170. left: 0;
  171. z-index: 1;
  172. border: @border-width-base @border-style-base @primary-color;
  173. border-radius: @border-radius-base;
  174. content: '';
  175. }
  176. }
  177. // >>> In Range
  178. &-in-view&-in-range {
  179. position: relative;
  180. &::before {
  181. background: @picker-basic-cell-active-with-range-color;
  182. }
  183. }
  184. // >>> Selected
  185. &-in-view&-selected .@{cellClassName},
  186. &-in-view&-range-start .@{cellClassName},
  187. &-in-view&-range-end .@{cellClassName} {
  188. color: @text-color-inverse;
  189. background: @primary-color;
  190. }
  191. &-in-view&-range-start:not(&-range-start-single),
  192. &-in-view&-range-end:not(&-range-end-single) {
  193. &::before {
  194. background: @picker-basic-cell-active-with-range-color;
  195. }
  196. }
  197. &-in-view&-range-start::before {
  198. left: 50%;
  199. }
  200. &-in-view&-range-end::before {
  201. right: 50%;
  202. }
  203. // >>> Range Hover
  204. &-in-view&-range-hover-start:not(&-in-range):not(&-range-start):not(&-range-end),
  205. &-in-view&-range-hover-end:not(&-in-range):not(&-range-start):not(&-range-end),
  206. &-in-view&-range-hover-start&-range-start-single,
  207. &-in-view&-range-hover-start&-range-start&-range-end&-range-end-near-hover,
  208. &-in-view&-range-hover-end&-range-start&-range-end&-range-start-near-hover,
  209. &-in-view&-range-hover-end&-range-end-single,
  210. &-in-view&-range-hover:not(&-in-range) {
  211. &::after {
  212. position: absolute;
  213. top: 50%;
  214. z-index: 0;
  215. height: 24px;
  216. border-top: @border-width-base dashed @picker-date-hover-range-border-color;
  217. border-bottom: @border-width-base dashed @picker-date-hover-range-border-color;
  218. transform: translateY(-50%);
  219. transition: all @animation-duration-slow;
  220. content: '';
  221. }
  222. }
  223. // Add space for stash
  224. &-range-hover-start::after,
  225. &-range-hover-end::after,
  226. &-range-hover::after {
  227. right: 0;
  228. left: 2px;
  229. }
  230. // Hover with in range
  231. &-in-view&-in-range&-range-hover::before,
  232. &-in-view&-range-start&-range-hover::before,
  233. &-in-view&-range-end&-range-hover::before,
  234. &-in-view&-range-start:not(&-range-start-single)&-range-hover-start::before,
  235. &-in-view&-range-end:not(&-range-end-single)&-range-hover-end::before,
  236. .@{picker-prefix-cls}-panel
  237. > :not(.@{picker-prefix-cls}-date-panel)
  238. &-in-view&-in-range&-range-hover-start::before,
  239. .@{picker-prefix-cls}-panel
  240. > :not(.@{picker-prefix-cls}-date-panel)
  241. &-in-view&-in-range&-range-hover-end::before {
  242. background: @picker-date-hover-range-color;
  243. }
  244. // range start border-radius
  245. &-in-view&-range-start:not(&-range-start-single):not(&-range-end) .@{cellClassName} {
  246. border-radius: @border-radius-base 0 0 @border-radius-base;
  247. }
  248. // range end border-radius
  249. &-in-view&-range-end:not(&-range-end-single):not(&-range-start) .@{cellClassName} {
  250. border-radius: 0 @border-radius-base @border-radius-base 0;
  251. }
  252. // DatePanel only
  253. .@{picker-prefix-cls}-date-panel &-in-view&-in-range&-range-hover-start .@{cellClassName},
  254. .@{picker-prefix-cls}-date-panel &-in-view&-in-range&-range-hover-end .@{cellClassName} {
  255. &::after {
  256. position: absolute;
  257. top: 0;
  258. bottom: 0;
  259. z-index: -1;
  260. background: @picker-date-hover-range-color;
  261. transition: all @animation-duration-slow;
  262. content: '';
  263. }
  264. }
  265. .@{picker-prefix-cls}-date-panel
  266. &-in-view&-in-range&-range-hover-start
  267. .@{cellClassName}::after {
  268. right: -5px - @border-width-base;
  269. left: 0;
  270. }
  271. .@{picker-prefix-cls}-date-panel &-in-view&-in-range&-range-hover-end .@{cellClassName}::after {
  272. right: 0;
  273. left: -5px - @border-width-base;
  274. }
  275. // Hover with range start & end
  276. &-range-hover&-range-start::after {
  277. right: 50%;
  278. }
  279. &-range-hover&-range-end::after {
  280. left: 50%;
  281. }
  282. // Edge start
  283. tr > &-in-view&-range-hover:first-child::after,
  284. tr > &-in-view&-range-hover-end:first-child::after,
  285. &-in-view&-start&-range-hover-edge-start&-range-hover-edge-start-near-range::after,
  286. &-in-view&-range-hover-edge-start:not(&-range-hover-edge-start-near-range)::after,
  287. &-in-view&-range-hover-start::after {
  288. left: 6px;
  289. border-left: @border-width-base dashed @picker-date-hover-range-border-color;
  290. border-top-left-radius: @border-radius-base;
  291. border-bottom-left-radius: @border-radius-base;
  292. }
  293. // Edge end
  294. tr > &-in-view&-range-hover:last-child::after,
  295. tr > &-in-view&-range-hover-start:last-child::after,
  296. &-in-view&-end&-range-hover-edge-end&-range-hover-edge-end-near-range::after,
  297. &-in-view&-range-hover-edge-end:not(&-range-hover-edge-end-near-range)::after,
  298. &-in-view&-range-hover-end::after {
  299. right: 6px;
  300. border-right: @border-width-base dashed @picker-date-hover-range-border-color;
  301. border-top-right-radius: @border-radius-base;
  302. border-bottom-right-radius: @border-radius-base;
  303. }
  304. // >>> Disabled
  305. &-disabled {
  306. color: @disabled-color;
  307. pointer-events: none;
  308. .@{cellClassName} {
  309. background: transparent;
  310. }
  311. &::before {
  312. background: @picker-basic-cell-disabled-bg;
  313. }
  314. }
  315. &-disabled&-today .@{cellClassName}::before {
  316. border-color: @disabled-color;
  317. }
  318. }
  319. &-cell {
  320. padding: 3px 0;
  321. color: @disabled-color;
  322. cursor: pointer;
  323. // In view
  324. &-in-view {
  325. color: @text-color;
  326. }
  327. .picker-cell-inner(~'@{picker-cell-inner-cls}');
  328. }
  329. &-decade-panel,
  330. &-year-panel,
  331. &-quarter-panel,
  332. &-month-panel {
  333. .@{picker-prefix-cls}-content {
  334. height: @picker-panel-without-time-cell-height * 4;
  335. }
  336. .@{picker-cell-inner-cls} {
  337. padding: 0 @padding-xs;
  338. }
  339. }
  340. &-quarter-panel {
  341. .@{picker-prefix-cls}-content {
  342. height: 56px;
  343. }
  344. }
  345. // ======================== Footer ========================
  346. &-footer {
  347. width: min-content;
  348. min-width: 100%;
  349. line-height: @picker-text-height - 2 * @border-width-base;
  350. text-align: center;
  351. border-bottom: @border-width-base @border-style-base transparent;
  352. .@{picker-prefix-cls}-panel & {
  353. border-top: @border-width-base @border-style-base @picker-border-color;
  354. }
  355. &-extra {
  356. padding: 0 @padding-sm;
  357. line-height: @picker-text-height - 2 * @border-width-base;
  358. text-align: left;
  359. &:not(:last-child) {
  360. border-bottom: @border-width-base @border-style-base @picker-border-color;
  361. }
  362. }
  363. }
  364. &-now {
  365. text-align: left;
  366. }
  367. &-today-btn {
  368. color: @link-color;
  369. &:hover {
  370. color: @link-hover-color;
  371. }
  372. &:active {
  373. color: @link-active-color;
  374. }
  375. &&-disabled {
  376. color: @disabled-color;
  377. cursor: not-allowed;
  378. }
  379. }
  380. // ========================================================
  381. // = Special =
  382. // ========================================================
  383. // ===================== Decade Panel =====================
  384. &-decade-panel {
  385. .@{picker-cell-inner-cls} {
  386. padding: 0 (@padding-xs / 2);
  387. }
  388. .@{picker-prefix-cls}-cell::before {
  389. display: none;
  390. }
  391. }
  392. // ============= Year & Quarter & Month Panel =============
  393. &-year-panel,
  394. &-quarter-panel,
  395. &-month-panel {
  396. @hover-cell-fixed-distance: (
  397. (((@picker-panel-width - @padding-xs * 2) / 3) - @picker-year-month-cell-width) / 2
  398. );
  399. .@{picker-prefix-cls}-body {
  400. padding: 0 @padding-xs;
  401. }
  402. .@{picker-cell-inner-cls} {
  403. width: @picker-year-month-cell-width;
  404. }
  405. .@{picker-prefix-cls}-cell-range-hover-start::after {
  406. left: @hover-cell-fixed-distance;
  407. border-left: @border-width-base dashed @picker-date-hover-range-border-color;
  408. border-radius: @border-radius-base 0 0 @border-radius-base;
  409. .@{picker-prefix-cls}-panel-rtl & {
  410. right: @hover-cell-fixed-distance;
  411. border-right: @border-width-base dashed @picker-date-hover-range-border-color;
  412. border-radius: 0 @border-radius-base @border-radius-base 0;
  413. }
  414. }
  415. .@{picker-prefix-cls}-cell-range-hover-end::after {
  416. right: @hover-cell-fixed-distance;
  417. border-right: @border-width-base dashed @picker-date-hover-range-border-color;
  418. border-radius: 0 @border-radius-base @border-radius-base 0;
  419. .@{picker-prefix-cls}-panel-rtl & {
  420. left: @hover-cell-fixed-distance;
  421. border-left: @border-width-base dashed @picker-date-hover-range-border-color;
  422. border-radius: @border-radius-base 0 0 @border-radius-base;
  423. }
  424. }
  425. }
  426. // ====================== Week Panel ======================
  427. &-week-panel {
  428. .@{picker-prefix-cls}-body {
  429. padding: @padding-xs @padding-sm;
  430. }
  431. // Clear cell style
  432. .@{picker-prefix-cls}-cell {
  433. &:hover .@{picker-cell-inner-cls},
  434. &-selected .@{picker-cell-inner-cls},
  435. .@{picker-cell-inner-cls} {
  436. background: transparent !important;
  437. }
  438. }
  439. &-row {
  440. td {
  441. transition: background @animation-duration-slow;
  442. }
  443. &:hover td {
  444. background: @picker-basic-cell-hover-color;
  445. }
  446. &-selected td,
  447. &-selected:hover td {
  448. background: @primary-color;
  449. &.@{picker-prefix-cls}-cell-week {
  450. color: fade(@text-color-inverse, 50%);
  451. }
  452. &.@{picker-prefix-cls}-cell-today .@{picker-cell-inner-cls}::before {
  453. border-color: @text-color-inverse;
  454. }
  455. .@{picker-cell-inner-cls} {
  456. color: @text-color-inverse;
  457. }
  458. }
  459. }
  460. }
  461. // ====================== Date Panel ======================
  462. &-date-panel {
  463. .@{picker-prefix-cls}-body {
  464. padding: @padding-xs @padding-sm;
  465. }
  466. .@{picker-prefix-cls}-content {
  467. width: @picker-panel-cell-width * 7;
  468. th {
  469. width: @picker-panel-cell-width;
  470. }
  471. }
  472. }
  473. // ==================== Datetime Panel ====================
  474. &-datetime-panel {
  475. display: flex;
  476. .@{picker-prefix-cls}-time-panel {
  477. border-left: @border-width-base @border-style-base @picker-border-color;
  478. }
  479. .@{picker-prefix-cls}-date-panel,
  480. .@{picker-prefix-cls}-time-panel {
  481. transition: opacity @animation-duration-slow;
  482. }
  483. // Keyboard
  484. &-active {
  485. .@{picker-prefix-cls}-date-panel,
  486. .@{picker-prefix-cls}-time-panel {
  487. opacity: 0.3;
  488. &-active {
  489. opacity: 1;
  490. }
  491. }
  492. }
  493. }
  494. // ====================== Time Panel ======================
  495. &-time-panel {
  496. width: auto;
  497. min-width: auto;
  498. .@{picker-prefix-cls}-content {
  499. display: flex;
  500. flex: auto;
  501. height: @picker-time-panel-column-height;
  502. }
  503. &-column {
  504. flex: 1 0 auto;
  505. width: @picker-time-panel-column-width;
  506. margin: 0;
  507. padding: 0;
  508. overflow-y: hidden;
  509. text-align: left;
  510. list-style: none;
  511. transition: background @animation-duration-slow;
  512. &::after {
  513. display: block;
  514. height: @picker-time-panel-column-height - @picker-time-panel-cell-height;
  515. content: '';
  516. .@{picker-prefix-cls}-datetime-panel & {
  517. height: @picker-time-panel-column-height - @picker-time-panel-cell-height + 2 *
  518. @border-width-base;
  519. }
  520. }
  521. &:not(:first-child) {
  522. border-left: @border-width-base @border-style-base @picker-border-color;
  523. }
  524. &-active {
  525. background: @calendar-column-active-bg;
  526. }
  527. &:hover {
  528. overflow-y: auto;
  529. }
  530. > li {
  531. margin: 0;
  532. padding: 0;
  533. &.@{picker-prefix-cls}-time-panel-cell {
  534. .@{picker-prefix-cls}-time-panel-cell-inner {
  535. display: block;
  536. width: 100%;
  537. height: @picker-time-panel-cell-height;
  538. margin: 0;
  539. padding: 0 0 0 ((@picker-time-panel-column-width - 28px) / 2);
  540. color: @text-color;
  541. line-height: @picker-time-panel-cell-height;
  542. border-radius: 0;
  543. cursor: pointer;
  544. transition: background @animation-duration-slow;
  545. &:hover {
  546. background: @item-hover-bg;
  547. }
  548. }
  549. &-selected {
  550. .@{picker-prefix-cls}-time-panel-cell-inner {
  551. background: @calendar-item-active-bg;
  552. }
  553. }
  554. &-disabled {
  555. .@{picker-prefix-cls}-time-panel-cell-inner {
  556. color: @disabled-color;
  557. background: transparent;
  558. cursor: not-allowed;
  559. }
  560. }
  561. }
  562. }
  563. }
  564. }
  565. }
  566. // Fix IE11 render bug by css hacks
  567. // https://github.com/ant-design/ant-design/issues/21559
  568. // https://codepen.io/afc163-1472555193/pen/mdJRaNj?editors=0110
  569. /* stylelint-disable selector-type-no-unknown,selector-no-vendor-prefix */
  570. _:-ms-fullscreen,
  571. :root {
  572. .@{picker-prefix-cls}-range-wrapper {
  573. .@{picker-prefix-cls}-month-panel .@{picker-prefix-cls}-cell,
  574. .@{picker-prefix-cls}-year-panel .@{picker-prefix-cls}-cell {
  575. padding: 21px 0;
  576. }
  577. }
  578. }