-
Notifications
You must be signed in to change notification settings - Fork 19
Init #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Init #1
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
28f63c9
init
koddsson 299cf78
add post HTML proccessing
koddsson cb2126f
fix year in LICENSE
9f5f946
expand JS example
koddsson 0ca8e0f
add more info to README on how remoteForm works
koddsson 6126044
remove post processing of HTML
koddsson 44bbe9f
add info on custom element polyfills
a6a492f
use `response.ok` instead of checking response status code is <300
6cda526
add missing `data-remote` attribute to html usage
811d7da
clarify description
989b8d6
replace rollup with babel
koddsson 9775661
remove unused header in tests
koddsson 12b08be
clean up eslint configuration
koddsson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "env": { | ||
| "esm": { | ||
| "presets": ["github"] | ||
| }, | ||
| "umd": { | ||
| "plugins": [ | ||
| ["@babel/plugin-transform-modules-umd", { | ||
| "globals": { | ||
| "selector-set": "SelectorSet" | ||
| } | ||
| }] | ||
| ], | ||
| "moduleId": "remoteForm", | ||
| "presets": ["github"] | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "extends": [ | ||
| "plugin:github/es6", | ||
| "plugin:github/browser", | ||
| "plugin:github/flow" | ||
| ], | ||
| "overrides": [ | ||
| { | ||
| "files": "test/**/*.js", | ||
| "rules": { | ||
| "flowtype/require-valid-file-annotation": "off", | ||
| "github/unescaped-html-literal": "off", | ||
| "eslint-comments/no-use": "off" | ||
| }, | ||
| "env": { | ||
| "mocha": true | ||
| }, | ||
| "globals": { | ||
| "assert": true, | ||
| "remoteForm": true | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| [ignore] | ||
|
|
||
| [include] | ||
|
|
||
| [libs] | ||
|
|
||
| [lints] | ||
|
|
||
| [options] | ||
|
|
||
| [strict] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| dist/ | ||
| node_modules/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| Copyright (c) 2019 GitHub, Inc. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,75 @@ | ||
| # remote-form | ||
|
|
||
| A function that will enable submitting forms over AJAX. | ||
|
|
||
| The function will make a request based on the form using `window.fetch` with the payload encoded as URL parameters if the form method is a `GET` and `FormData` for all the other methods. | ||
|
|
||
| The request object is available in the callback function, allowing the headers and body to be modified before the request is sent. | ||
|
|
||
| ## Installation | ||
|
|
||
| ``` | ||
| $ npm install --save @github/remote-form | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```js | ||
| import {remoteForm} from '@github/remote-form' | ||
koddsson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Make all forms that have the `data-remote` attribute a remote form. | ||
| remoteForm('form[data-remote]', async function(form, wants, request) { | ||
| // Before we start the request | ||
| form.classList.remove('has-error') | ||
| form.classList.add('is-loading') | ||
|
|
||
| let response | ||
| try { | ||
| response = await wants.html() | ||
| } catch (error) { | ||
| // If the request errored, we'll set the error state and return. | ||
| form.classList.remove('is-loading') | ||
| form.classList.add('has-error') | ||
| return | ||
| } | ||
|
|
||
| // If the request succeeded we can do something with the results. | ||
| form.classList.remove('is-loading') | ||
| form.querySelector('.results').innerHTML = response.html | ||
| }) | ||
| ``` | ||
|
|
||
| ```html | ||
| <form action="/signup" method="post" data-remote> | ||
| <label for="username">Username</label> | ||
| <input id="username" type="text" /> | ||
|
|
||
| <label for="password">Username</label> | ||
| <input id="password" type="password" /> | ||
|
|
||
| <button>Log in</button> | ||
| </form> | ||
| ``` | ||
|
|
||
| ## Browser support | ||
koddsson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Browsers without native [custom element support][support] require a [polyfill][]. | ||
|
|
||
| - Chrome | ||
| - Firefox | ||
| - Safari | ||
| - Microsoft Edge | ||
dgraham marked this conversation as resolved.
Show resolved
Hide resolved
koddsson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [support]: https://caniuse.com/#feat=custom-elementsv1 | ||
| [polyfill]: https://github.com/webcomponents/custom-elements | ||
|
|
||
| ## Development | ||
|
|
||
| ``` | ||
| npm install | ||
| npm test | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| Distributed under the MIT license. See LICENSE for details. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UMD build was looking for
selectorSetinglobalbut in theselector-setUMD build the global is set toSelectorSet:https://github.com/josh/selector-set/blob/master/selector-set.js#L7