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