index.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import { resetComponent } from '../../style';
  3. import { genPanelStyle, initPickerPanelToken } from '../../date-picker/style';
  4. import { initInputToken } from '../../input/style';
  5. import { genComponentStyleHook, mergeToken } from '../../theme/internal';
  6. export const genCalendarStyles = token => {
  7. const {
  8. calendarCls,
  9. componentCls,
  10. calendarFullBg,
  11. calendarFullPanelBg,
  12. calendarItemActiveBg
  13. } = token;
  14. return {
  15. [calendarCls]: _extends(_extends(_extends({}, genPanelStyle(token)), resetComponent(token)), {
  16. background: calendarFullBg,
  17. '&-rtl': {
  18. direction: 'rtl'
  19. },
  20. [`${calendarCls}-header`]: {
  21. display: 'flex',
  22. justifyContent: 'flex-end',
  23. padding: `${token.paddingSM}px 0`,
  24. [`${calendarCls}-year-select`]: {
  25. minWidth: token.yearControlWidth
  26. },
  27. [`${calendarCls}-month-select`]: {
  28. minWidth: token.monthControlWidth,
  29. marginInlineStart: token.marginXS
  30. },
  31. [`${calendarCls}-mode-switch`]: {
  32. marginInlineStart: token.marginXS
  33. }
  34. }
  35. }),
  36. [`${calendarCls} ${componentCls}-panel`]: {
  37. background: calendarFullPanelBg,
  38. border: 0,
  39. borderTop: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
  40. borderRadius: 0,
  41. [`${componentCls}-month-panel, ${componentCls}-date-panel`]: {
  42. width: 'auto'
  43. },
  44. [`${componentCls}-body`]: {
  45. padding: `${token.paddingXS}px 0`
  46. },
  47. [`${componentCls}-content`]: {
  48. width: '100%'
  49. }
  50. },
  51. [`${calendarCls}-mini`]: {
  52. borderRadius: token.borderRadiusLG,
  53. [`${calendarCls}-header`]: {
  54. paddingInlineEnd: token.paddingXS,
  55. paddingInlineStart: token.paddingXS
  56. },
  57. [`${componentCls}-panel`]: {
  58. borderRadius: `0 0 ${token.borderRadiusLG}px ${token.borderRadiusLG}px`
  59. },
  60. [`${componentCls}-content`]: {
  61. height: token.miniContentHeight,
  62. th: {
  63. height: 'auto',
  64. padding: 0,
  65. lineHeight: `${token.weekHeight}px`
  66. }
  67. },
  68. [`${componentCls}-cell::before`]: {
  69. pointerEvents: 'none'
  70. }
  71. },
  72. [`${calendarCls}${calendarCls}-full`]: {
  73. [`${componentCls}-panel`]: {
  74. display: 'block',
  75. width: '100%',
  76. textAlign: 'end',
  77. background: calendarFullBg,
  78. border: 0,
  79. [`${componentCls}-body`]: {
  80. 'th, td': {
  81. padding: 0
  82. },
  83. th: {
  84. height: 'auto',
  85. paddingInlineEnd: token.paddingSM,
  86. paddingBottom: token.paddingXXS,
  87. lineHeight: `${token.weekHeight}px`
  88. }
  89. }
  90. },
  91. [`${componentCls}-cell`]: {
  92. '&::before': {
  93. display: 'none'
  94. },
  95. '&:hover': {
  96. [`${calendarCls}-date`]: {
  97. background: token.controlItemBgHover
  98. }
  99. },
  100. [`${calendarCls}-date-today::before`]: {
  101. display: 'none'
  102. },
  103. // >>> Selected
  104. [`&-in-view${componentCls}-cell-selected`]: {
  105. [`${calendarCls}-date, ${calendarCls}-date-today`]: {
  106. background: calendarItemActiveBg
  107. }
  108. },
  109. '&-selected, &-selected:hover': {
  110. [`${calendarCls}-date, ${calendarCls}-date-today`]: {
  111. [`${calendarCls}-date-value`]: {
  112. color: token.colorPrimary
  113. }
  114. }
  115. }
  116. },
  117. [`${calendarCls}-date`]: {
  118. display: 'block',
  119. width: 'auto',
  120. height: 'auto',
  121. margin: `0 ${token.marginXS / 2}px`,
  122. padding: `${token.paddingXS / 2}px ${token.paddingXS}px 0`,
  123. border: 0,
  124. borderTop: `${token.lineWidthBold}px ${token.lineType} ${token.colorSplit}`,
  125. borderRadius: 0,
  126. transition: `background ${token.motionDurationSlow}`,
  127. '&-value': {
  128. lineHeight: `${token.dateValueHeight}px`,
  129. transition: `color ${token.motionDurationSlow}`
  130. },
  131. '&-content': {
  132. position: 'static',
  133. width: 'auto',
  134. height: token.dateContentHeight,
  135. overflowY: 'auto',
  136. color: token.colorText,
  137. lineHeight: token.lineHeight,
  138. textAlign: 'start'
  139. },
  140. '&-today': {
  141. borderColor: token.colorPrimary,
  142. [`${calendarCls}-date-value`]: {
  143. color: token.colorText
  144. }
  145. }
  146. }
  147. },
  148. [`@media only screen and (max-width: ${token.screenXS}px) `]: {
  149. [`${calendarCls}`]: {
  150. [`${calendarCls}-header`]: {
  151. display: 'block',
  152. [`${calendarCls}-year-select`]: {
  153. width: '50%'
  154. },
  155. [`${calendarCls}-month-select`]: {
  156. width: `calc(50% - ${token.paddingXS}px)`
  157. },
  158. [`${calendarCls}-mode-switch`]: {
  159. width: '100%',
  160. marginTop: token.marginXS,
  161. marginInlineStart: 0,
  162. '> label': {
  163. width: '50%',
  164. textAlign: 'center'
  165. }
  166. }
  167. }
  168. }
  169. }
  170. };
  171. };
  172. export default genComponentStyleHook('Calendar', token => {
  173. const calendarCls = `${token.componentCls}-calendar`;
  174. const calendarToken = mergeToken(initInputToken(token), initPickerPanelToken(token), {
  175. calendarCls,
  176. pickerCellInnerCls: `${token.componentCls}-cell-inner`,
  177. calendarFullBg: token.colorBgContainer,
  178. calendarFullPanelBg: token.colorBgContainer,
  179. calendarItemActiveBg: token.controlItemBgActive,
  180. dateValueHeight: token.controlHeightSM,
  181. weekHeight: token.controlHeightSM * 0.75,
  182. dateContentHeight: (token.fontSizeSM * token.lineHeightSM + token.marginXS) * 3 + token.lineWidth * 2
  183. });
  184. return [genCalendarStyles(calendarToken)];
  185. }, {
  186. yearControlWidth: 80,
  187. monthControlWidth: 70,
  188. miniContentHeight: 256
  189. });