upload.scss 13 KB

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