picture.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.genPictureStyle = exports.genPictureCardStyle = void 0;
  6. var _colors = require("@ant-design/colors");
  7. var _cssinjs = require("@ant-design/cssinjs");
  8. var _style = require("../../style");
  9. const genPictureStyle = token => {
  10. const {
  11. componentCls,
  12. iconCls,
  13. uploadThumbnailSize,
  14. uploadProgressOffset,
  15. calc
  16. } = token;
  17. const listCls = `${componentCls}-list`;
  18. const itemCls = `${listCls}-item`;
  19. return {
  20. [`${componentCls}-wrapper`]: {
  21. // ${listCls} 增加优先级
  22. [`
  23. ${listCls}${listCls}-picture,
  24. ${listCls}${listCls}-picture-card,
  25. ${listCls}${listCls}-picture-circle
  26. `]: {
  27. [itemCls]: {
  28. position: 'relative',
  29. height: calc(uploadThumbnailSize).add(calc(token.lineWidth).mul(2)).add(calc(token.paddingXS).mul(2)).equal(),
  30. padding: token.paddingXS,
  31. border: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorBorder}`,
  32. borderRadius: token.borderRadiusLG,
  33. '&:hover': {
  34. background: 'transparent'
  35. },
  36. [`${itemCls}-thumbnail`]: Object.assign(Object.assign({}, _style.textEllipsis), {
  37. width: uploadThumbnailSize,
  38. height: uploadThumbnailSize,
  39. lineHeight: (0, _cssinjs.unit)(calc(uploadThumbnailSize).add(token.paddingSM).equal()),
  40. textAlign: 'center',
  41. flex: 'none',
  42. [iconCls]: {
  43. fontSize: token.fontSizeHeading2,
  44. color: token.colorPrimary
  45. },
  46. img: {
  47. display: 'block',
  48. width: '100%',
  49. height: '100%',
  50. overflow: 'hidden'
  51. }
  52. }),
  53. [`${itemCls}-progress`]: {
  54. bottom: uploadProgressOffset,
  55. width: `calc(100% - ${(0, _cssinjs.unit)(calc(token.paddingSM).mul(2).equal())})`,
  56. marginTop: 0,
  57. paddingInlineStart: calc(uploadThumbnailSize).add(token.paddingXS).equal()
  58. }
  59. },
  60. [`${itemCls}-error`]: {
  61. borderColor: token.colorError,
  62. // Adjust the color of the error icon : https://github.com/ant-design/ant-design/pull/24160
  63. [`${itemCls}-thumbnail ${iconCls}`]: {
  64. [`svg path[fill='${_colors.blue[0]}']`]: {
  65. fill: token.colorErrorBg
  66. },
  67. [`svg path[fill='${_colors.blue.primary}']`]: {
  68. fill: token.colorError
  69. }
  70. }
  71. },
  72. [`${itemCls}-uploading`]: {
  73. borderStyle: 'dashed',
  74. [`${itemCls}-name`]: {
  75. marginBottom: uploadProgressOffset
  76. }
  77. }
  78. },
  79. [`${listCls}${listCls}-picture-circle ${itemCls}`]: {
  80. [`&, &::before, ${itemCls}-thumbnail`]: {
  81. borderRadius: '50%'
  82. }
  83. }
  84. }
  85. };
  86. };
  87. exports.genPictureStyle = genPictureStyle;
  88. const genPictureCardStyle = token => {
  89. const {
  90. componentCls,
  91. iconCls,
  92. fontSizeLG,
  93. colorTextLightSolid,
  94. calc
  95. } = token;
  96. const listCls = `${componentCls}-list`;
  97. const itemCls = `${listCls}-item`;
  98. const uploadPictureCardSize = token.uploadPicCardSize;
  99. return {
  100. [`
  101. ${componentCls}-wrapper${componentCls}-picture-card-wrapper,
  102. ${componentCls}-wrapper${componentCls}-picture-circle-wrapper
  103. `]: Object.assign(Object.assign({}, (0, _style.clearFix)()), {
  104. display: 'block',
  105. [`${componentCls}${componentCls}-select`]: {
  106. width: uploadPictureCardSize,
  107. height: uploadPictureCardSize,
  108. textAlign: 'center',
  109. verticalAlign: 'top',
  110. backgroundColor: token.colorFillAlter,
  111. border: `${(0, _cssinjs.unit)(token.lineWidth)} dashed ${token.colorBorder}`,
  112. borderRadius: token.borderRadiusLG,
  113. cursor: 'pointer',
  114. transition: `border-color ${token.motionDurationSlow}`,
  115. [`> ${componentCls}`]: {
  116. display: 'flex',
  117. alignItems: 'center',
  118. justifyContent: 'center',
  119. height: '100%',
  120. textAlign: 'center'
  121. },
  122. [`&:not(${componentCls}-disabled):hover`]: {
  123. borderColor: token.colorPrimary
  124. }
  125. },
  126. // list
  127. [`${listCls}${listCls}-picture-card, ${listCls}${listCls}-picture-circle`]: {
  128. display: 'flex',
  129. flexWrap: 'wrap',
  130. '@supports not (gap: 1px)': {
  131. '& > *': {
  132. marginBlockEnd: token.marginXS,
  133. marginInlineEnd: token.marginXS
  134. }
  135. },
  136. '@supports (gap: 1px)': {
  137. gap: token.marginXS
  138. },
  139. [`${listCls}-item-container`]: {
  140. display: 'inline-block',
  141. width: uploadPictureCardSize,
  142. height: uploadPictureCardSize,
  143. verticalAlign: 'top'
  144. },
  145. '&::after': {
  146. display: 'none'
  147. },
  148. '&::before': {
  149. display: 'none'
  150. },
  151. [itemCls]: {
  152. height: '100%',
  153. margin: 0,
  154. '&::before': {
  155. position: 'absolute',
  156. zIndex: 1,
  157. width: `calc(100% - ${(0, _cssinjs.unit)(calc(token.paddingXS).mul(2).equal())})`,
  158. height: `calc(100% - ${(0, _cssinjs.unit)(calc(token.paddingXS).mul(2).equal())})`,
  159. backgroundColor: token.colorBgMask,
  160. opacity: 0,
  161. transition: `all ${token.motionDurationSlow}`,
  162. content: '" "'
  163. }
  164. },
  165. [`${itemCls}:hover`]: {
  166. [`&::before, ${itemCls}-actions`]: {
  167. opacity: 1
  168. }
  169. },
  170. [`${itemCls}-actions`]: {
  171. position: 'absolute',
  172. insetInlineStart: 0,
  173. zIndex: 10,
  174. width: '100%',
  175. whiteSpace: 'nowrap',
  176. textAlign: 'center',
  177. opacity: 0,
  178. transition: `all ${token.motionDurationSlow}`,
  179. [`
  180. ${iconCls}-eye,
  181. ${iconCls}-download,
  182. ${iconCls}-delete
  183. `]: {
  184. zIndex: 10,
  185. width: fontSizeLG,
  186. margin: `0 ${(0, _cssinjs.unit)(token.marginXXS)}`,
  187. fontSize: fontSizeLG,
  188. cursor: 'pointer',
  189. transition: `all ${token.motionDurationSlow}`,
  190. color: colorTextLightSolid,
  191. '&:hover': {
  192. color: colorTextLightSolid
  193. },
  194. svg: {
  195. verticalAlign: 'baseline'
  196. }
  197. }
  198. },
  199. [`${itemCls}-thumbnail, ${itemCls}-thumbnail img`]: {
  200. position: 'static',
  201. display: 'block',
  202. width: '100%',
  203. height: '100%',
  204. objectFit: 'contain'
  205. },
  206. [`${itemCls}-name`]: {
  207. display: 'none',
  208. textAlign: 'center'
  209. },
  210. [`${itemCls}-file + ${itemCls}-name`]: {
  211. position: 'absolute',
  212. bottom: token.margin,
  213. display: 'block',
  214. width: `calc(100% - ${(0, _cssinjs.unit)(calc(token.paddingXS).mul(2).equal())})`
  215. },
  216. [`${itemCls}-uploading`]: {
  217. [`&${itemCls}`]: {
  218. backgroundColor: token.colorFillAlter
  219. },
  220. [`&::before, ${iconCls}-eye, ${iconCls}-download, ${iconCls}-delete`]: {
  221. display: 'none'
  222. }
  223. },
  224. [`${itemCls}-progress`]: {
  225. bottom: token.marginXL,
  226. width: `calc(100% - ${(0, _cssinjs.unit)(calc(token.paddingXS).mul(2).equal())})`,
  227. paddingInlineStart: 0
  228. }
  229. }
  230. }),
  231. [`${componentCls}-wrapper${componentCls}-picture-circle-wrapper`]: {
  232. [`${componentCls}${componentCls}-select`]: {
  233. borderRadius: '50%'
  234. }
  235. }
  236. };
  237. };
  238. exports.genPictureCardStyle = genPictureCardStyle;