diff --git a/docs/dist/donate-button/embed.js b/docs/dist/donate-button/embed.js new file mode 100644 index 00000000..bfb99aa3 --- /dev/null +++ b/docs/dist/donate-button/embed.js @@ -0,0 +1 @@ +"use strict";!function(){var e="https://embed-staging.every.org",t="every-widget";window.everyWidget={create:function(n){var r,o="string"==typeof(r=n.selector)?document.querySelector(r):r instanceof Element?r:null;if(!o)return console.error("everyWidget: no element matches",n.selector),null;if(!n.partnerSlug||!n.nonprofitSlug)return console.error("everyWidget: partnerSlug and nonprofitSlug are required",n),null;var i=document.createElement("iframe");return i.src=e+"/embed/"+encodeURIComponent(n.nonprofitSlug)+"/donate?partnerSlug="+encodeURIComponent(n.partnerSlug),i.title="Donate",i.setAttribute("scrolling","no"),i.setAttribute("allow","payment"),i.style.display="block",i.style.width="100%",i.style.border="0",i.style.overflow="hidden",i.style.minHeight="480px",o.appendChild(i),window.addEventListener("message",(function(r){if(r.origin===e&&r.source===i.contentWindow){var o=r.data;(function(e){return"object"==typeof e&&null!==e&&e.source===t})(o)&&("resize"===o.type&&"number"==typeof o.height&&(i.style.minHeight="0",i.style.height=o.height+"px"),"success"===o.type&&"function"==typeof n.onSuccess&&n.onSuccess())}})),i}}}(); \ No newline at end of file diff --git a/package.json b/package.json index 69ae5fa4..c5836f8a 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,9 @@ "build:donateButton": "yarn workspace @everydotorg/donate-button build && cp -r packages/donate-button/dist ./docs", "build:donateButtonNext": "yarn workspace @everydotorg/donate-button-next build && cp -r packages/donate-button-next/dist ./docs", "build:donateButtonV4": "yarn workspace @everydotorg/donate-button-v4 build && cp -r packages/donate-button-v4/dist ./docs", - "build": "yarn build:donateButtonV4", - "lint": "yarn workspace @everydotorg/donate-button-v4 lint", + "build:donateEmbed": "yarn workspace @everydotorg/donate-embed build && cp -r packages/donate-embed/dist ./docs", + "build": "yarn build:donateButtonV4 && yarn build:donateEmbed", + "lint": "yarn workspace @everydotorg/donate-button-v4 lint && yarn workspace @everydotorg/donate-embed lint", "lint:fix": "yarn workspaces @everydotorg/donate-button-v4 lint:fix", "test": "yarn concurrently -n 'api,website-next,common,partner-api' 'yarn workspace @everydotorg/donate-button-cloudflare-worker test' 'yarn workspace @everydotorg/donate-button test' 'yarn workspace @everydotorg/donate-button-next test' 'yarn workspace @everydotorg/donate-button-v4 test'", "postinstall": "patch-package" @@ -17,7 +18,8 @@ "packages/cloudflare-worker", "packages/donate-button", "packages/donate-button-next", - "packages/donate-button-v4" + "packages/donate-button-v4", + "packages/donate-embed" ], "devDependencies": { "concurrently": "^7.1.0", diff --git a/packages/donate-embed/.gitignore b/packages/donate-embed/.gitignore new file mode 100644 index 00000000..1521c8b7 --- /dev/null +++ b/packages/donate-embed/.gitignore @@ -0,0 +1 @@ +dist diff --git a/packages/donate-embed/.prettierignore b/packages/donate-embed/.prettierignore new file mode 100644 index 00000000..1521c8b7 --- /dev/null +++ b/packages/donate-embed/.prettierignore @@ -0,0 +1 @@ +dist diff --git a/packages/donate-embed/.prettierrc b/packages/donate-embed/.prettierrc new file mode 100644 index 00000000..376cdae7 --- /dev/null +++ b/packages/donate-embed/.prettierrc @@ -0,0 +1,7 @@ +{ + "tabWidth": 2, + "useTabs": true, + "trailingComma": "none", + "bracketSpacing": false, + "singleQuote": true +} diff --git a/packages/donate-embed/LICENSE b/packages/donate-embed/LICENSE new file mode 100644 index 00000000..5bad0a3e --- /dev/null +++ b/packages/donate-embed/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Every.org + +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. diff --git a/packages/donate-embed/README.md b/packages/donate-embed/README.md new file mode 100644 index 00000000..9c3506c1 --- /dev/null +++ b/packages/donate-embed/README.md @@ -0,0 +1,73 @@ +# donate-embed + +`embed.js` renders the every.org donate form inline on your page. It adds an +iframe to a container of your choice, sizes it to fit the form, and tells you +when a donation completes. + +Published at **https://embeds.every.org/embed.js**. + +## Usage + +```html +
+ + + +``` + +Options for `everyWidget.create`: + +- `selector` (required): CSS selector of the element the donate form is added + to, or the element itself. Pass an element when the container is not + reachable from `document`, for example inside a web component's shadow root. + A malformed selector string throws, just like `document.querySelector`. +- `partnerSlug` (required): the partner slug every.org assigned to you. +- `nonprofitSlug` (required): the every.org slug of the nonprofit to donate to. +- `onSuccess` (optional): called when a donation completes. + +`create` returns the `