status-bar.mdx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. ---
  2. sidebar_position: 4
  3. slug: /status-bar
  4. ---
  5. import Tabs from '@theme/Tabs';
  6. import TabItem from '@theme/TabItem';
  7. import UppyCdnExample from '/src/components/UppyCdnExample';
  8. # Status bar
  9. The `@uppy/status-bar` plugin shows upload progress and speed, estimated time,
  10. pre- and post-processing information, and allows users to control
  11. (pause/resume/cancel) the upload.
  12. :::tip
  13. Try it out together with [`@uppy/drag-drop`](/docs/drag-drop) in
  14. [StackBlitz](https://stackblitz.com/edit/vitejs-vite-yzbujq?file=main.js/g)
  15. :::
  16. ## When should I use it?
  17. When you use the [Dashboard](/docs/dashboard) it’s already included by default.
  18. This plugin is published separately but made specifically for the Dashboard. You
  19. can still use it without it but it may need some (CSS) tweaking for your use
  20. case.
  21. ## Install
  22. <Tabs>
  23. <TabItem value="npm" label="NPM" default>
  24. ```shell
  25. npm install @uppy/status-bar
  26. ```
  27. </TabItem>
  28. <TabItem value="yarn" label="Yarn">
  29. ```shell
  30. yarn add @uppy/status-bar
  31. ```
  32. </TabItem>
  33. <TabItem value="cdn" label="CDN">
  34. <UppyCdnExample>
  35. {`
  36. import { Uppy, StatusBar } from "{{UPPY_JS_URL}}"
  37. const uppy = new Uppy()
  38. uppy.use(StatusBar, { target: '#status-bar' })
  39. `}
  40. </UppyCdnExample>
  41. </TabItem>
  42. </Tabs>
  43. ## Use
  44. ```js showLineNumbers
  45. import Uppy from '@uppy/core';
  46. import StatusBar from '@uppy/status-bar';
  47. import '@uppy/core/dist/style.min.css';
  48. import '@uppy/status-bar/dist/style.min.css';
  49. new Uppy().use(StatusBar, { target: '#status-bar' });
  50. ```
  51. ## API
  52. ### Options
  53. #### `id`
  54. A unique identifier for this Status Bar (`string`, default: `'StatusBar'`).
  55. Use this if you need to add several StatusBar instances.
  56. #### `target`
  57. DOM element, CSS selector, or plugin to mount the Status Bar into (`Element`,
  58. `string`, `UIPlugin`, default: `'body'`).
  59. #### `hideAfterFinish`
  60. Hide the Status Bar after the upload is complete (`boolean`, default: `true`).
  61. #### `showProgressDetails`
  62. Display remaining upload size and estimated time (`boolean`, default: `false`)
  63. :::note
  64. `false`: Uploading: 45%
  65. `true`: Uploading: 45%・43 MB of 101 MB・8s left
  66. :::
  67. #### `hideUploadButton`
  68. Hide the upload button (`boolean`, default: `false`).
  69. Use this if you are providing a custom upload button somewhere, and using the
  70. `uppy.upload()` API.
  71. #### `hideRetryButton`
  72. Hide the retry button (`boolean`, default: `false`).
  73. Use this if you are providing a custom retry button somewhere, and using the
  74. `uppy.retryAll()` or `uppy.retryUpload(fileID)` API.
  75. #### `hidePauseResumeButton`
  76. Hide pause/resume buttons (for resumable uploads, via [tus](http://tus.io), for
  77. example) (`boolean`, default: `false`).
  78. Use this if you are providing custom cancel or pause/resume buttons somewhere,
  79. and using the `uppy.pauseResume(fileID)` or `uppy.removeFile(fileID)` API.
  80. #### `hideCancelButton`
  81. Hide the cancel button (`boolean`, default: `false`).
  82. Use this if you are providing a custom retry button somewhere, and using the
  83. `uppy.cancelAll()` API.
  84. #### `doneButtonHandler`
  85. Status Bar will render a “Done” button in place of pause/resume/cancel buttons,
  86. once the upload/encoding is done (`Function`, default: `null`).
  87. The behaviour of this “Done” button is defined by the handler function — can be
  88. used to close file picker modals or clear the upload state. This is what the
  89. Dashboard plugin, which uses Status Bar internally, sets:
  90. ```js
  91. const doneButtonHandler = () => {
  92. this.uppy.reset();
  93. this.requestCloseModal();
  94. };
  95. ```
  96. #### `locale`
  97. ```js
  98. export default {
  99. strings: {
  100. // Shown in the status bar while files are being uploaded.
  101. uploading: 'Uploading',
  102. // Shown in the status bar once all files have been uploaded.
  103. complete: 'Complete',
  104. // Shown in the status bar if an upload failed.
  105. uploadFailed: 'Upload failed',
  106. // Shown in the status bar while the upload is paused.
  107. paused: 'Paused',
  108. // Used as the label for the button that retries an upload.
  109. retry: 'Retry',
  110. // Used as the label for the button that cancels an upload.
  111. cancel: 'Cancel',
  112. // Used as the label for the button that pauses an upload.
  113. pause: 'Pause',
  114. // Used as the label for the button that resumes an upload.
  115. resume: 'Resume',
  116. // Used as the label for the button that resets the upload state after an upload
  117. done: 'Done',
  118. // When `showProgressDetails` is set, shows the number of files that have been fully uploaded so far.
  119. filesUploadedOfTotal: {
  120. 0: '%{complete} of %{smart_count} file uploaded',
  121. 1: '%{complete} of %{smart_count} files uploaded',
  122. },
  123. // When `showProgressDetails` is set, shows the amount of bytes that have been uploaded so far.
  124. dataUploadedOfTotal: '%{complete} of %{total}',
  125. // When `showProgressDetails` is set, shows an estimation of how long the upload will take to complete.
  126. xTimeLeft: '%{time} left',
  127. // Used as the label for the button that starts an upload.
  128. uploadXFiles: {
  129. 0: 'Upload %{smart_count} file',
  130. 1: 'Upload %{smart_count} files',
  131. },
  132. // Used as the label for the button that starts an upload, if another upload has been started in the past
  133. // and new files were added later.
  134. uploadXNewFiles: {
  135. 0: 'Upload +%{smart_count} file',
  136. 1: 'Upload +%{smart_count} files',
  137. },
  138. upload: 'Upload',
  139. retryUpload: 'Retry upload',
  140. xMoreFilesAdded: {
  141. 0: '%{smart_count} more file added',
  142. 1: '%{smart_count} more files added',
  143. },
  144. showErrorDetails: 'Show error details',
  145. },
  146. };
  147. ```