upload.scss 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. @use 'mixins/mixins' as *;
  2. @use 'mixins/utils' as *;
  3. @use 'common/var' as *;
  4. @mixin upload-success($color: null) {
  5. right: -15px;
  6. top: -6px;
  7. width: 40px;
  8. height: 24px;
  9. background: getCssVar('color-success');
  10. text-align: center;
  11. transform: rotate(45deg);
  12. i {
  13. font-size: 12px;
  14. margin-top: 11px;
  15. transform: rotate(-45deg);
  16. color: $color;
  17. }
  18. }
  19. @include b(upload) {
  20. @include set-component-css-var('upload', $upload);
  21. }
  22. @include b(upload) {
  23. @include utils-inline-flex-center;
  24. cursor: pointer;
  25. outline: none;
  26. @include e(input) {
  27. display: none;
  28. }
  29. @include e(tip) {
  30. font-size: 12px;
  31. color: getCssVar('text-color', 'regular');
  32. margin-top: 7px;
  33. }
  34. iframe {
  35. position: absolute;
  36. z-index: -1;
  37. top: 0;
  38. left: 0;
  39. opacity: 0;
  40. filter: alpha(opacity=0);
  41. }
  42. /* Picture Card for Wall */
  43. @include m(picture-card) {
  44. @include set-css-var-value(('upload', 'picture-card', 'size'), 148px);
  45. background-color: getCssVar('fill-color', 'lighter');
  46. border: 1px dashed getCssVar('border-color', 'darker');
  47. border-radius: 6px;
  48. box-sizing: border-box;
  49. width: getCssVar('upload', 'picture-card', 'size');
  50. height: getCssVar('upload', 'picture-card', 'size');
  51. cursor: pointer;
  52. vertical-align: top;
  53. @include utils-inline-flex-center;
  54. > i {
  55. font-size: 28px;
  56. color: getCssVar('text-color', 'secondary');
  57. }
  58. &:hover {
  59. border-color: getCssVar('color-primary');
  60. color: getCssVar('color-primary');
  61. }
  62. }
  63. @include when(drag) {
  64. display: block;
  65. }
  66. &:focus {
  67. border-color: getCssVar('color-primary');
  68. color: getCssVar('color-primary');
  69. .#{$namespace}-upload-dragger {
  70. border-color: getCssVar('color-primary');
  71. }
  72. }
  73. }
  74. @include b(upload-dragger) {
  75. padding: getCssVar('upload-dragger-padding-horizontal')
  76. getCssVar('upload-dragger-padding-vertical');
  77. background-color: getCssVar('fill-color', 'blank');
  78. border: 1px dashed getCssVar('border-color');
  79. border-radius: 6px;
  80. box-sizing: border-box;
  81. text-align: center;
  82. cursor: pointer;
  83. position: relative;
  84. overflow: hidden;
  85. .#{bem('icon', '', 'upload')} {
  86. font-size: 67px;
  87. color: getCssVar('text-color', 'placeholder');
  88. margin-bottom: 16px;
  89. line-height: 50px;
  90. }
  91. + .#{bem('upload', 'tip')} {
  92. text-align: center;
  93. }
  94. ~ .#{bem('upload', 'files')} {
  95. border-top: getCssVar('border');
  96. margin-top: 7px;
  97. padding-top: 5px;
  98. }
  99. .#{bem('upload', 'text')} {
  100. color: getCssVar('text-color', 'regular');
  101. font-size: 14px;
  102. text-align: center;
  103. em {
  104. color: getCssVar('color-primary');
  105. font-style: normal;
  106. }
  107. }
  108. &:hover {
  109. border-color: getCssVar('color-primary');
  110. }
  111. @include when(dragover) {
  112. padding: calc(#{getCssVar('upload-dragger-padding-horizontal')} - 1px)
  113. calc(#{getCssVar('upload-dragger-padding-vertical')} - 1px);
  114. background-color: getCssVar('color', 'primary', 'light-9');
  115. border: 2px dashed getCssVar('color-primary');
  116. }
  117. }
  118. @include b(upload-list) {
  119. margin: 10px 0 0;
  120. padding: 0;
  121. list-style: none;
  122. position: relative;
  123. @include e(item) {
  124. transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);
  125. font-size: 14px;
  126. color: getCssVar('text-color', 'regular');
  127. margin-bottom: 5px;
  128. position: relative;
  129. box-sizing: border-box;
  130. border-radius: 4px;
  131. width: 100%;
  132. .#{bem('progress')} {
  133. position: absolute;
  134. top: 20px;
  135. width: 100%;
  136. }
  137. .#{bem('progress', 'text')} {
  138. position: absolute;
  139. right: 0;
  140. top: -13px;
  141. }
  142. .#{bem('progress-bar')} {
  143. margin-right: 0;
  144. padding-right: 0;
  145. }
  146. & .#{bem('icon', '', 'upload-success')} {
  147. color: getCssVar('color-success');
  148. }
  149. .#{bem('icon', '', 'close')} {
  150. display: none;
  151. position: absolute;
  152. right: 5px;
  153. top: 50%;
  154. cursor: pointer;
  155. opacity: 0.75;
  156. color: getCssVar('text-color', 'regular');
  157. transition: opacity getCssVar('transition-duration');
  158. transform: translateY(-50%);
  159. &:hover {
  160. opacity: 1;
  161. color: getCssVar('color-primary');
  162. }
  163. }
  164. & .#{bem('icon', '', 'close-tip')} {
  165. display: none;
  166. position: absolute;
  167. top: 1px;
  168. right: 5px;
  169. font-size: 12px;
  170. cursor: pointer;
  171. opacity: 1;
  172. color: getCssVar('color-primary');
  173. font-style: normal;
  174. }
  175. &:hover {
  176. background-color: getCssVar('fill-color', 'light');
  177. .#{bem('icon', '', 'close')} {
  178. display: inline-flex;
  179. }
  180. .#{bem('progress', 'text')} {
  181. display: none;
  182. }
  183. }
  184. .#{bem('upload-list', 'item-info')} {
  185. display: inline-flex;
  186. justify-content: center;
  187. flex-direction: column;
  188. width: calc(100% - 30px);
  189. margin-left: 4px;
  190. }
  191. @include when(success) {
  192. .#{bem('upload-list', 'item-status-label')} {
  193. display: inline-flex;
  194. }
  195. .#{bem('upload-list', 'item-name')}:hover,
  196. .#{bem('upload-list', 'item-name')}:focus {
  197. color: getCssVar('color-primary');
  198. cursor: pointer;
  199. }
  200. &:focus:not(:hover) {
  201. /* 键盘focus */
  202. .#{bem('icon', '', 'close-tip')} {
  203. display: inline-block;
  204. }
  205. }
  206. &:not(.focusing):focus,
  207. &:active {
  208. /* click时 */
  209. outline-width: 0;
  210. .#{bem('icon', '', 'close-tip')} {
  211. display: none;
  212. }
  213. }
  214. &:hover,
  215. &:focus {
  216. .#{bem('upload-list', 'item-status-label')} {
  217. display: none;
  218. opacity: 0;
  219. }
  220. }
  221. }
  222. }
  223. @include e(item-name) {
  224. color: getCssVar('text-color', 'regular');
  225. display: inline-flex;
  226. text-align: center;
  227. align-items: center;
  228. padding: 0 4px;
  229. transition: color getCssVar('transition-duration');
  230. font-size: getCssVar('font-size', 'base');
  231. .#{$namespace}-icon {
  232. margin-right: 6px;
  233. color: getCssVar('text-color', 'secondary');
  234. }
  235. }
  236. @include e(item-file-name) {
  237. overflow: hidden;
  238. text-overflow: ellipsis;
  239. white-space: nowrap;
  240. }
  241. @include e(item-status-label) {
  242. position: absolute;
  243. right: 5px;
  244. top: 0;
  245. line-height: inherit;
  246. display: none;
  247. height: 100%;
  248. justify-content: center;
  249. align-items: center;
  250. transition: opacity getCssVar('transition-duration');
  251. }
  252. @include e(item-delete) {
  253. position: absolute;
  254. right: 10px;
  255. top: 0;
  256. font-size: 12px;
  257. color: getCssVar('text-color', 'regular');
  258. display: none;
  259. &:hover {
  260. color: getCssVar('color-primary');
  261. }
  262. }
  263. // upload-list
  264. @include m(picture-card) {
  265. @include set-css-var-value(('upload-list', 'picture-card', 'size'), 148px);
  266. display: inline-flex;
  267. flex-wrap: wrap;
  268. margin: 0;
  269. .#{bem('upload-list', 'item')} {
  270. overflow: hidden;
  271. background-color: getCssVar('fill-color', 'blank');
  272. border: 1px solid getCssVar('border-color');
  273. border-radius: 6px;
  274. box-sizing: border-box;
  275. width: getCssVar('upload-list', 'picture-card', 'size');
  276. height: getCssVar('upload-list', 'picture-card', 'size');
  277. margin: 0 8px 8px 0;
  278. padding: 0;
  279. display: inline-flex;
  280. .#{bem('icon', '' ,'check')},
  281. .#{bem('icon', '' ,'circle-check')} {
  282. color: $color-white;
  283. }
  284. .#{bem('icon', '', 'close')} {
  285. display: none;
  286. }
  287. &:hover {
  288. .#{bem('upload-list', 'item-status-label')} {
  289. opacity: 0;
  290. // for fade out
  291. display: block;
  292. }
  293. .#{$namespace}-progress__text {
  294. display: block;
  295. }
  296. }
  297. }
  298. .#{bem('upload-list', 'item')} {
  299. .#{bem('upload-list', 'item-name')} {
  300. display: none;
  301. }
  302. }
  303. .#{bem('upload-list', 'item-thumbnail')} {
  304. width: 100%;
  305. height: 100%;
  306. object-fit: contain;
  307. }
  308. .#{bem('upload-list', 'item-status-label')} {
  309. @include upload-success();
  310. }
  311. .#{bem('upload-list', 'item-actions')} {
  312. position: absolute;
  313. width: 100%;
  314. height: 100%;
  315. left: 0;
  316. top: 0;
  317. cursor: default;
  318. display: inline-flex;
  319. justify-content: center;
  320. align-items: center;
  321. color: #fff;
  322. opacity: 0;
  323. font-size: 20px;
  324. background-color: getCssVar('overlay-color', 'lighter');
  325. transition: opacity getCssVar('transition-duration');
  326. span {
  327. display: none;
  328. cursor: pointer;
  329. }
  330. span + span {
  331. margin-left: 16px;
  332. }
  333. .#{bem('upload-list', 'item-delete')} {
  334. position: static;
  335. font-size: inherit;
  336. color: inherit;
  337. }
  338. &:hover {
  339. opacity: 1;
  340. span {
  341. display: inline-flex;
  342. }
  343. }
  344. }
  345. .#{bem('progress')} {
  346. top: 50%;
  347. left: 50%;
  348. transform: translate(-50%, -50%);
  349. bottom: auto;
  350. width: 126px;
  351. .#{$namespace}-progress__text {
  352. top: 50%;
  353. }
  354. }
  355. }
  356. @include m(picture) {
  357. .#{bem('upload-list', 'item')} {
  358. overflow: hidden;
  359. z-index: 0;
  360. background-color: getCssVar('fill-color', 'blank');
  361. border: 1px solid getCssVar('border-color');
  362. border-radius: 6px;
  363. box-sizing: border-box;
  364. margin-top: 10px;
  365. padding: 10px;
  366. display: flex;
  367. align-items: center;
  368. .#{bem('icon', '' ,'check')},
  369. .#{bem('icon', '' ,'circle-check')} {
  370. color: $color-white;
  371. }
  372. &:hover {
  373. .#{bem('upload-list', 'item-status-label')} {
  374. opacity: 0;
  375. display: inline-flex;
  376. }
  377. .#{bem('progress', 'text')} {
  378. display: block;
  379. }
  380. }
  381. &.is-success {
  382. .#{bem('upload-list', 'item-name')} {
  383. i {
  384. display: none;
  385. }
  386. }
  387. }
  388. & .#{bem('icon', '' ,'close')} {
  389. top: 5px;
  390. transform: translateY(0);
  391. }
  392. }
  393. .#{bem('upload-list', 'item-thumbnail')} {
  394. $item-thumbnail-size: 70px;
  395. display: inline-flex;
  396. justify-content: center;
  397. align-items: center;
  398. width: $item-thumbnail-size;
  399. height: $item-thumbnail-size;
  400. object-fit: contain;
  401. position: relative;
  402. z-index: 1;
  403. background-color: getCssVar('color-white');
  404. }
  405. .#{bem('upload-list', 'item-status-label')} {
  406. position: absolute;
  407. right: -17px;
  408. top: -7px;
  409. width: 46px;
  410. height: 26px;
  411. background: getCssVar('color-success');
  412. text-align: center;
  413. transform: rotate(45deg);
  414. i {
  415. font-size: 12px;
  416. margin-top: 12px;
  417. transform: rotate(-45deg);
  418. }
  419. }
  420. .#{$namespace}-progress {
  421. position: relative;
  422. top: -7px;
  423. }
  424. }
  425. }
  426. @include b(upload-cover) {
  427. position: absolute;
  428. left: 0;
  429. top: 0;
  430. width: 100%;
  431. height: 100%;
  432. overflow: hidden;
  433. z-index: 10;
  434. cursor: default;
  435. @include utils-vertical-center;
  436. img {
  437. display: block;
  438. width: 100%;
  439. height: 100%;
  440. }
  441. @include e(label) {
  442. @include upload-success(#fff);
  443. }
  444. @include e(progress) {
  445. display: inline-block;
  446. vertical-align: middle;
  447. position: static;
  448. width: 243px;
  449. + .#{bem('upload', 'inner')} {
  450. opacity: 0;
  451. }
  452. }
  453. @include e(content) {
  454. position: absolute;
  455. top: 0;
  456. left: 0;
  457. width: 100%;
  458. height: 100%;
  459. }
  460. @include e(interact) {
  461. position: absolute;
  462. bottom: 0;
  463. left: 0;
  464. width: 100%;
  465. height: 100%;
  466. background-color: getCssVar('overlay-color', 'light');
  467. text-align: center;
  468. .btn {
  469. display: inline-block;
  470. color: $color-white;
  471. font-size: 14px;
  472. cursor: pointer;
  473. vertical-align: middle;
  474. transition: getCssVar('transition-md-fade');
  475. margin-top: 60px;
  476. i {
  477. margin-top: 0;
  478. }
  479. span {
  480. opacity: 0;
  481. transition: opacity 0.15s linear;
  482. }
  483. &:not(:first-child) {
  484. margin-left: 35px;
  485. }
  486. &:hover {
  487. transform: translateY(-13px);
  488. span {
  489. opacity: 1;
  490. }
  491. }
  492. i {
  493. color: $color-white;
  494. display: block;
  495. font-size: 24px;
  496. line-height: inherit;
  497. margin: 0 auto 5px;
  498. }
  499. }
  500. }
  501. @include e(title) {
  502. position: absolute;
  503. bottom: 0;
  504. left: 0;
  505. background-color: $color-white;
  506. height: 36px;
  507. width: 100%;
  508. overflow: hidden;
  509. text-overflow: ellipsis;
  510. white-space: nowrap;
  511. font-weight: normal;
  512. text-align: left;
  513. padding: 0 10px;
  514. margin: 0;
  515. line-height: 36px;
  516. font-size: 14px;
  517. color: getCssVar('text-color', 'primary');
  518. }
  519. + .#{bem('upload', 'inner')} {
  520. opacity: 0;
  521. position: relative;
  522. z-index: 1;
  523. }
  524. }