Browse Source

add Form docs, fix other docs

Artur Paikin 7 years ago
parent
commit
b70f803df1

+ 21 - 5
website/src/docs/dashboard.md

@@ -68,7 +68,7 @@ String with a CSS selector for a button that will trigger opening Dashboard moda
 
 Maximum width of the Dashboard in pixels. Used when `inline: true`.
 
-### `height: 750`
+### `height: 550`
 
 Maximum height of the Dashboard in pixels. Used when `inline: true`.
 
@@ -80,6 +80,26 @@ Hide the upload button. Use this if you are providing a custom upload button som
 
 Optionally specify a string of text that explains something about the upload for the user. This is a place to explain `restrictions` that are put in place. For example: `'Images and video only, 2–3 files, up to 1 MB'`.
 
+### `metaFields: []`
+
+An array of UI field objects that will be shown when a user clicks “edit” button on that file. Each object requires:
+
+- `id`, the name of the meta field.
+— `name`, the label shown in the interface.
+- `placeholder`, the text shown when no value it set in the field.
+
+```js
+.use(Dashboard, {
+  trigger: '#pick-files',
+  metaFields: [
+    { id: 'license', name: 'License', placeholder: 'specify license' },
+    { id: 'caption', name: 'Caption', placeholder: 'describe what the image is about' }
+  ]
+})
+```
+
+Note that this meta data will only be set to a file if it’s entered by user. If you want to set certain default meta field to each file regardless of user actions, set [`meta` in Uppy options](docs/uppy/#meta).
+
 ### `closeModalOnClickOutside: false`
 
 Set to true to automatically close the modal when the user clicks outside it.
@@ -92,10 +112,6 @@ Dashboard ships with `StatusBar` plugin that shows upload progress and pause/res
 
 Dashboard ships with `Informer` plugin that notifies when the browser is offline, or when it’s time to smile if `Webcam` is taking a picture. If you want, you can disable the Informer and/or provide your custom solution.
 
-### `getMetaFromForm: true`
-
-See [general plugin options](/docs/plugins).
-
 ### `locale`
 
 See [general plugin options](/docs/plugins).

+ 40 - 0
website/src/docs/form.md

@@ -0,0 +1,40 @@
+---
+type: docs
+order: 30
+title: "Form"
+permalink: docs/form/
+---
+
+Form plugin collects metadata from any specified `<form>` element, right before Uppy begins uploading/processing files. And then optionally appends results back to the form. Currently the appended result is a strigified version of a [`result`](docs/uppy/#uppy-upload) returned from `uppy.upload()` or `complete` event.
+
+## Options
+
+```js
+uppy.use(Form, {
+  target: null,
+  getMetaFromForm: true,
+  addResultToForm: true,
+  resultName: 'uppyResult',
+  submitOnSuccess: false
+})
+```
+
+### `target: null`
+
+DOM element or CSS selector for the form element. Required for the plugin to work.
+
+### `getMetaFromForm: true`
+
+Whether to extract metadata from the form.
+
+### `addResultToForm: true`
+
+Whether to add upload/encoding results back to the form in an `<input name="uppyResult" type="hidden">` element.
+
+### `resultName: 'uppyResult'`
+
+The `name` attribute for the `<input type="hidden">` where the result will be added. 
+
+### `submitOnSuccess: false`
+
+Whether to submit the form after Uppy finishes uploading/encoding.

+ 4 - 40
website/src/docs/plugins.md

@@ -38,8 +38,8 @@ Can be a `string` CSS selector, a DOM element, or a Plugin class. Consider the f
 const Uppy = require('uppy/lib/core')
 const DragDrop = require('uppy/lib/plugins/DragDrop')
 const uppy = Uppy()
-uppy.use(DragDrop, {target: 'body'})
-// or: uppy.use(DragDrop, {target: document.body})
+uppy.use(DragDrop, { target: 'body' })
+// or: uppy.use(DragDrop, { target: document.body })
 ```
 
 While in this one, we are using the `Dashboard` plugin, which can act as a host target for other plugins:
@@ -50,8 +50,7 @@ const DragDrop = require('uppy/lib/plugins/Dashboard')
 const GoogleDrive = require('uppy/lib/plugins/GoogleDrive')
 const uppy = Uppy()
 uppy.use(Dashboard, {
-  trigger: '#uppyModalOpener',
-  target: '#uppy',
+  trigger: '#uppyModalOpener'
 })
 uppy.use(GoogleDrive, {target: Dashboard})
 ```
@@ -72,44 +71,9 @@ const GoogleDrive = require('uppy/lib/plugins/GoogleDrive')
 uppy.use(GoogleDrive, {target: Dashboard, host: 'http://localhost:3020'})
 ```
 
-### `getMetaFromForm: false`
-
-If `getMetaFromForm === true`, UI acquire type plugins, like `Dashboard`, `FileInput` and `DragDrop`, before mounting themselves or doing anything else, will extract FormData from the target `<form>` element (it must be a form currently), and merge the object with the global `uppy.state.meta`.
-
-If you have a form like this one:
-
-```html
-<form class="MyForm" action="/">
-  <input type="file">
-  <input type="hidden" name="bla" value="12333">
-  <input type="text" name="yo" value="1">
-  <button type="submit">Upload</button>
-</form>
-```
-
-And then do:
-
-```js
-uppy.use(DragDrop, {
-  target: '.MyForm',
-  getMetaFromForm: true
-})
-```
-
-Uppy’s `uppy.state.meta` will become:
-
-```js
-state = {
-  meta: {
-    bla: 12333,
-    yo: 1
-  }
-}
-```
-
 ### `replaceTargetContent: false`
 
-By default Uppy will append any UI to a DOM element, if such element is specified as a `target`. This default is the least dangerous option. However, you might want to provide fallback `<form>` with `<button type="submit">` that will be shown if Uppy or JavaScript is not loaded/supported on the page. Set `replaceTargetContent: true` to clear the `target` before appending, that way all your fallback elements will be removed if Uppy is actually functioning.
+By default Uppy will append any UI to a DOM element, if such element is specified as a `target`. This default is the least dangerous option. However, there might be cases when you’d want to clear the container element before place Uppy UI in there (for example, to provide a fallback `<form>` that will be shown if Uppy or JavaScript is not loaded/supported on the page). Set `replaceTargetContent: true` to clear the `target` before appending.
 
 ### `locale: {}`
 

+ 1 - 1
website/src/docs/stores.md

@@ -1,6 +1,6 @@
 ---
 type: docs
-order: 4
+order: 3
 title: "Custom Stores"
 permalink: docs/stores/
 ---

+ 3 - 3
website/src/docs/uppy.md

@@ -149,7 +149,7 @@ const Uppy = require('uppy/lib/core')
 const DragDrop = require('uppy/lib/plugins/DragDrop')
 
 const uppy = Uppy()
-uppy.use(DragDrop, {target: 'body'})
+uppy.use(DragDrop, { target: 'body' })
 ```
 
 ### `uppy.run()`
@@ -243,10 +243,10 @@ Returns `uppy.state`, which you can also use directly.
 
 ### `uppy.setMeta(data)`
 
-Alters global `meta` object is state, the one that can be set in Uppy options and gets merged with all newly added files.
+Alters global `meta` object is state, the one that can be set in Uppy options and gets merged with all newly added files. Calling `setMeta` will also merge newly added meta data with previously selected files.
 
 ```js
-uppy.setMeta({ resize: 1500 })
+uppy.setMeta({ resize: 1500, token: 'ab5kjfg' })
 ```
 
 ### `uppy.setFileMeta(fileID, data)`

+ 0 - 171
website/src/guide/contributing.md

@@ -1,171 +0,0 @@
----
-title: "Contributing Guidelines"
-type: guide
-order: 3
----
-
-## Uppy Development
-
-First clone and install the project:
-
-```bash
-git clone git@github.com:transloadit/uppy.git
-cd uppy
-npm install
-```
-
-Our website's examples section is also our playground, read "Website Development"'s "Local Previews" section to get up and running.
-
-## Website Development
-
-We keep the [uppy.io](http://uppy.io) website in `./website` for so it's easy to keep docs & code in sync as we're still iterating at high velocity. For those reading this screaming murder, [HashiCorp does this](https://github.com/hashicorp/terraform/tree/master/website) for all their projects, and it's working well for them on a scale vastly more impressive than Uppy's.
-
-The site is built with [Hexo](http://hexo.io/), and Travis automatically deploys this onto GitHub Pages (it overwrites the `gh-pages` branch with Hexo's build at every change to `master`). The content is written in Markdown and located in `./website/src`. Feel free to fork & hack!  
-
-Even though bundled in this repo, the website is regarded as a separate project. So it has its own `package.json` and we aim keep the surface where the two projects interface as small as possible. `./website/update.js` is called during website builds to inject the Uppy knowledge into the site.
-
-### Local Previews
-
-It's recommended to exclude `./website/public/` from your editor if you want efficient searches.
-
-To install the required node modules, type:
-```bash
-npm install && cd website && npm install && cd ..
-```
-
-For local previews on http://127.0.0.1:4000 type:
-
-```bash
-npm start
-```
-
-This will watch the website, as well as Uppy, as the examples, and rebuild everything and refresh your browser as files change.
-
-Then, to work on e.g. the Multipart example, you'd edit the following files:
-
-```bash
-atom src/core/Core.js \
-  src/plugins/Multipart.js \
-  src/plugins/Formtag.js \
-  src/plugins/Plugin.js \
-  website/src/examples/multipart/app.es6
-```
-
-And open <http://0.0.0.0:4000/examples/multipart/index.html> in your webbrowser.
-
-## Tests
-
-Unit tests can be run with:
-
-```npm run test:unit```
-
-For acceptance (or end to end) tests, we use [Webdriverio](http://webdriver.io). For it to run locally, you need to install selenium standalone server, just follow [the guide](http://webdriver.io/guide.html) to do so.
-
-After you’ve installed and launched the selenium standalone server, run:
-
-```
-npm run test:acceptance:local
-```
-
-## CSS Guidelines
-
-The CSS standards followed in this project closely resemble those from [Medium's CSS Guidelines](https://gist.github.com/fat/a47b882eb5f84293c4ed). If it's not mentioned here, follow their guidelines.
-
-### Naming Conventions
-
-This project uses naming conventions adopted from the SUIT CSS framework.
-[Read about them here](https://github.com/suitcss/suit/blob/master/doc/naming-conventions.md).
-
-To quickly summarize:
-
-#### Utilities
-
-Syntax: u-[sm-|md-|lg-]<utilityName>
-
-```css
-.u-utilityName
-.u-floatLeft
-.u-lg-col6
-```
-
-#### Components
-
-Syntax: [<namespace>-]<ComponentName>[-descendentName][--modifierName]
-
-```css
-.twt-Button /* Namespaced component */
-.MyComponent /* Components pascal cased */
-.Button--default /* Modified button style */
-.Button--large
-
-.Tweet
-.Tweet-header /* Descendents */
-.Tweet-bodyText
-
-.Accordion.is-collapsed /* State of component */
-.Accordion.is-expanded
-```
-
-### SASS
-
-This project uses SASS, with some limitations on nesting.  One-level deep nesting is allowed, but nesting may not extend a selector by using the `&` operator.  For example:
-
-```sass
-/* BAD */
-.Button {
-  &--disabled {
-    ...
-  }
-}
-
-/* GOOD */
-.Button {
-  ...
-}
-
-.Button--disabled {
-  ...
-}
-```
-
-### Mobile-first Responsive Approach
-
-Style to the mobile breakpoint with your selectors, then use `min-width` media queries to add any styles to the tablet or desktop breakpoints.
-
-### Selector, Rule Ordering
-
-- All selectors are sorted alphabetically and by type.
-- HTML elements go above classes and IDs in a file.
-- Rules are sorted alphabetically.
-
-```sass
-/* BAD */
-.wrapper {
-  width: 940px;
-  margin: auto;
-}
-
-h1 {
-  color: red;
-}
-
-.article {
-  width: 100%;
-  padding: 32px;
-}
-
-/* GOOD */
-h1 {
-  color: red;
-}
-
-.article {
-  padding: 32px;
-  width: 100%;
-}
-
-.wrapper {
-  margin: auto;
-  width: 940px;
-}
-```

+ 0 - 11
website/src/guide/faq.md

@@ -1,11 +0,0 @@
----
-title: "FAQ"
-type: guide
-order: 2
----
-
-## Why does your site look like vuejs.org?
-
-The website started as a clone of Yuxi Evan You's wonderful [Vue.js](http://vuejs.org/) website ([view license](website/VUEORG_LICENSE)) - just so we can hit the ground running in terms of Hexo boilerplate. As we go we'll be rolling out more original content and design and make this place our own.
-
-We have <a href="https://twitter.com/youyuxi/status/672441843183960067">consent</a> of Yuxi Evan You for this. We're redistributing his <a href="https://github.com/transloadit/uppy/blob/master/website/VUEORG_LICENSE">LICENSE</a>, and will keep credits in the footer in tact as long as this remains a direct descendant.

+ 1 - 1
website/src/stats.ejs

@@ -6,5 +6,5 @@ permalink: docs/stats/
 alias: 
   - guide/stats/
   - stats/
-order: 3
+order: 5
 ---