gitoria

layouts

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit5d204c465d204c46Re-vendor layouts to Hybriel set day38bmre5d204c46/components/file-upload/README.md

1.7 KB

  1. # File upload (one file)
  2. A dashed drop zone with a "Choose a file" button. Drop or choose a file: its name, size and a progress bar show, then
  3. "Uploaded", and the file is listed under "Uploaded". One file at a time (a drop of several takes the first; a file dropped
  4. during an upload is ignored). Live demo: https://components.hybriel.worldapi.org/file-upload
  5. ## Use it in an app
  6. Copy the folder `components/file-upload/` (`file-upload.hl`; it carries its own `Style`, colours are semantic tokens with a
  7. black/white/grey fallback, the one border is the drop zone's dashed one), compose it, and write the face that stores the file:
  8. ```
  9. import FileUpload from './file-upload.hl'
  10. View { FileUpload { } }
  11. on server saveFile(file) {
  12. // file.name, file.type, file.size, file.bytes — store it where you want
  13. writeFile('storage/uploads/' + name, file.bytes)
  14. return { ok = true }
  15. }
  16. ```
  17. - The component sends the file with `emit server saveFile(file)`; the framework carries it over HTTP in parts with progress
  18. (hybriel#94). Pure Hybriel: no `.js`, no own network calls.
  19. - The face decides where the file goes and how big it may be (`uploadMax` of the WebFramework). Answer anything but `null`
  20. when it is stored; `null` (or an error) shows "Failed".
  21. - Face names are global to the app (`saveFile`): one upload face per app.
  22. - `dropText`, `chooseText`, `uploadedTitle` are the texts. One component per page (composed members are the page's state).
  23. - Progress comes from `on client uploadProgress`, shown by the component itself.
  24. ## Markup and states
  25. `<file-upload>` holds `<drop-zone>` (class `over` while a file is dragged over) with `<upload-status>` (name, size,
  26. `<progress>`, `<output class="state">`) and `<uploaded-list>` with `<ul class="uploaded">`. Classes on `<file-upload>`:
  27. `busy`, `done`, `failed`, `shown`.

Branches

Latest commits

  • 5d204c46Re-vendor layouts to Hybriel set day38bmre
  • 17e0f03eNest html-prefixed theme component overridesmre
  • e54e735eFormat plain theme elements with nested rules and bare mediamre
  • 547f834eRecord LY7 deployment and live verificationmre
  • fa4600b1Link caller-slot style exceptions to hybriel#270mre
  • 413b11e1Record corrected LY7 nesting, exact CSS and Chrome proofmre
  • b810453etracker-demo: nest child and compound selectors in Stylemre
  • 0b5b1d61notes-demo: nest child and compound selectors in Stylemre
  • ab22bdc2mail-demo: nest child and compound selectors in Stylemre
  • fe2d8de9home: nest child and compound selectors in Stylemre
  • e631791buser-menu: nest child and compound selectors in Stylemre
  • 69604944three-pane: nest child and compound selectors in Stylemre
  • 3e389b83main-menu: nest child and compound selectors in Stylemre
  • 05413975list-first: nest child and compound selectors in Stylemre
  • c545b642content-first: nest child and compound selectors in Stylemre
  • eae2be7aapp-sidebar: nest child selectors and document caller-slot gapmre
  • 69c9f784Record LY7 slot nesting blocker and minimal repromre
  • b1d4f379app-header: nest child and compound selectors in Stylemre
  • 6385ff8eRecord LY7 style formatting proof and review statusmre
  • 0100f51etracker-demo: format Style with nested rules and bare mediamre