Skip to content

Review Follow Ups and Refactoring #2

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
merged 21 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 79 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ npm install @anvilco/react-signature-frame

```js
import AnvilSignatureFrame from '@anvilco/react-signature-frame'
import '@anvilco/react-signature-frame/dist/styles.css'

<AnvilSignatureFrame
signURL={signURL}
Expand All @@ -40,9 +39,10 @@ signURL={`https://app.useanvil.com/etch/8iJDbq8dkEmjrsNw7Dnb/sign?token=dsa...`}
```

#### scroll
##### string
* `auto` - scrolls the window to the signing frame when rendered
* `smooth` - smoothly scrolls the window to the signing frame when rendered
##### string | null
* `auto` - scrolls the window to the signing frame when mounted
* `smooth` - smoothly scrolls the window to the signing frame when mounted
* `null` - disables scrolling

#### onLoad
##### function
Expand All @@ -64,6 +64,21 @@ onFinish={(redirectURL) => window.location.assign(redirectURL)}
```


#### enableDefaultStyles
##### boolean (default: true)
Set to false to disable the default inline styles of the component.


#### iframeWarningProps
##### object
Pass in custom props into the paragraph tag displayed if the user's browser does not support iframes.

Example:
```js
iframeWarningProps={{ className: 'warning-text' }}
```


## AnvilSignatureModal
A modal component that handles the signing process lifecycle. Compatible with mobile viewports with minimal dependencies.

Expand All @@ -80,7 +95,6 @@ npm install @anvilco/react-signature-modal

```js
import AnvilSignatureFrame from '@anvilco/react-signature-modal'
import '@anvilco/react-signature-modal/dist/styles.css'

<AnvilSignatureModal
signURL={signURL}
Expand Down Expand Up @@ -135,19 +149,76 @@ onFinish={(redirectURL) => window.location.assign(redirectURL)}
```


#### modalAppElement
#### string
Pass in a query selector identifying the root of your app. Used to hide other page content while the modal is open for
screenreaders and other accessibility purposes.

Default: `#root`


#### showIconClose
#### boolean
Show the close icon on the top right of the modal if true.


#### enableDefaultStyles
##### boolean (default: true)
Set to false to disable the default inline styles of the component.


#### iframeWarningProps
##### object
Pass in custom props into the paragraph tag displayed if the user's browser does not support iframes.

Example:
```js
iframeWarningProps={{ className: 'warning-text' }}
```


#### AnvilFrameProps
##### object
Pass in custom props into the iframe tag displayed within the modal.

Example:
```js
AnvilFrameProps={{
id: 'my-modal',
style: { background: 'white' },
}}
```


#### iconCloseProps
##### object
Pass in custom props into the svg tag for the delete button displayed within the modal.

Example:
```js
AnvilFrameProps={{ className: 'custom-delete-class' }}
```


## Styling

Styles are not embedded into the React component to support customization. The default styles are provided within the modules under `dist/styles.css`.
Customize the component by overriding the default styles. Pass in props to override IDs and classNames.

## Anvil Etch E-Sign Docs

[Read the Docs](https://www.useanvil.com/docs/api/e-signatures)


## Links 🔗
* [@anvilco/react-signature-frame](https://www.npmjs.com/package/@anvilco/react-signature-frame)
* [@anvilco/react-signature-modal](https://www.npmjs.com/package/@anvilco/react-signature-modal)
* [Get started with Anvil](https://www.useanvil.com/)


## Notes

* The `allowFormEmbed` config must be set to `true` under your [Anvil organization](https://useanvil.com) for embedded signing. Please reach us at [[email protected]](mailto:hello@useanvil.com).
* React ^v16.8.0 is required.
* Please contact us at [[email protected]](mailto:support@useanvil.com) to enable iframe embedded signing for production signature packets.
* React >= v16.0 required.


## Bugs
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"scripts": {
"lint": "yarn eslint 'packages/*/src/**.js'",
"prebuild": "git clean -fdx packages -e packages/*/node_modules",
"build": "yarn lerna run build",
"build": "yarn lerna bootstrap && yarn lerna run build",
"release:local": "yarn build && yarn lerna run pack",
"release:npm": "yarn build && yarn lerna publish"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.5",
"babel-eslint": "^10.1.0",
Expand Down
34 changes: 27 additions & 7 deletions packages/react-signature-frame/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ npm install @anvilco/react-signature-frame

```js
import AnvilSignatureFrame from '@anvilco/react-signature-frame'
import '@anvilco/react-signature-frame/dist/styles.css'

<AnvilSignatureFrame
signURL={signURL}
Expand All @@ -35,9 +34,10 @@ signURL={`https://app.useanvil.com/etch/8iJDbq8dkEmjrsNw7Dnb/sign?token=dsa...`}
```

#### scroll
##### string
* `auto` - scrolls the window to the signing frame when rendered
* `smooth` - smoothly scrolls the window to the signing frame when rendered
##### string | null
* `auto` - scrolls the window to the signing frame when mounted
* `smooth` - smoothly scrolls the window to the signing frame when mounted
* `null` - disables scrolling

#### onLoad
##### function
Expand All @@ -59,20 +59,40 @@ onFinish={(redirectURL) => window.location.assign(redirectURL)}
```


#### enableDefaultStyles
##### boolean (default: true)
Set to false to disable the default inline styles of the component.


#### iframeWarningProps
##### object
Pass in custom props into the paragraph tag displayed if the user's browser does not support iframes.

Example:
```js
iframeWarningProps={{ className: 'warning-text' }}
```


## Styling

Styles are not embedded into the React component to support customization. The default styles are provided within the modules under `dist/styles.css`.
Customize the component by overriding the default styles. Pass in props to override IDs and classNames.


## Anvil Etch E-Sign Docs

[Read the Docs](https://www.useanvil.com/docs/api/e-signatures)


## Links 🔗
* [@anvilco/react-signature-frame](https://www.npmjs.com/package/@anvilco/react-signature-frame)
* [Get started with Anvil](https://www.useanvil.com/)


## Notes

* The `allowFormEmbed` config must be set to `true` under your [Anvil organization](https://useanvil.com) for embedded signing. Please reach us at [[email protected]](mailto:hello@useanvil.com).
* React ^v16.8.0 is required.
* Please contact us at [[email protected]](mailto:support@useanvil.com) to enable iframe embedded signing for production signature packets.
* React >= v16.0 required.


## Bugs
Expand Down
10 changes: 5 additions & 5 deletions packages/react-signature-frame/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anvilco/react-signature-frame",
"version": "1.4.2",
"version": "1.4.4",
"description": "The AnvilSignatureFrame React component for embedded Etch signatures",
"author": "Anvil Foundry Inc.",
"license": "MIT",
Expand Down Expand Up @@ -31,12 +31,12 @@
],
"devDependencies": {
"prop-types": "^15.6.0",
"react": "^16.8.0",
"react-dom": "^16.8.0"
"react": "^16.0.0",
"react-dom": "^16.0.0"
},
"peerDependencies": {
"prop-types": "^15.6.0",
"react": "^16.8.0",
"react-dom": "^16.8.0"
"react": "^16.0.0",
"react-dom": "^16.0.0"
}
}
12 changes: 0 additions & 12 deletions packages/react-signature-frame/src/index.css

This file was deleted.

88 changes: 56 additions & 32 deletions packages/react-signature-frame/src/index.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,69 @@
import React, { useEffect, useRef } from 'react'
import React from 'react'
import PropTypes from 'prop-types'
import './index.css'

const ANVIL_URLS = ['https://app.useanvil.com', 'https://staging.useanvil.com']

function AnvilSignatureFrame ({ signURL, scroll, onLoad, onFinish }) {
const iframeRef = useRef(null)

useEffect(() => {
function handleSignFinish ({ origin, data: url }) {
if (!ANVIL_URLS.includes(origin)) return
onFinish(url)
}
window.addEventListener('message', handleSignFinish)
if (scroll) iframeRef.current.scrollIntoView({ behavior: scroll })
return () => window.removeEventListener('message', handleSignFinish)
}, [])

return (
<iframe
id="anvil-signatureFrame"
src={signURL}
name="Anvil Etch E-Sign"
title="Anvil Etch E-Sign"
onLoad={onLoad}
ref={iframeRef}
>
<p className="anvil-docs">Your browser does not support iframes.</p>
</iframe>
)

class AnvilSignatureFrame extends React.Component {
constructor (props) {
super(props)
this.iframeRef = React.createRef()
}

componentDidMount () {
const { scroll } = this.props
window.addEventListener('message', this.handleSignFinish)
if (scroll) this.iframeRef.current.scrollIntoView({ behavior: scroll })
}

componentWillUnmount () {
window.removeEventListener('message', this.handleSignFinish)
}

handleSignFinish = ({ origin, data: url }) => {
if (this.props.anvilURL !== origin) return
this.props.onFinish(url)
}

render () {
const { signURL, onLoad, enableDefaultStyles, ...otherProps } = this.props
const { iframeWarningProps, ...anvilFrameProps } = otherProps
return (
<iframe
id="anvil-signature-frame"
name="Anvil Etch E-Sign"
title="Anvil Etch E-Sign"
style={enableDefaultStyles
? {
width: '80vw',
height: '85vh',
maxWidth: '1200px',
borderStyle: 'groove',
}
: undefined}
{...anvilFrameProps}
src={signURL}
onLoad={onLoad}
ref={this.iframeRef}
>
<p className="anvil-iframe-warning" {...iframeWarningProps}>Your browser does not support iframes.</p>
</iframe>
)
}
}

AnvilSignatureFrame.defaultProps = {
onFinish: (url) => window.location.assign(url),
onFinish: (url) => {
console.log('RedirectURL:', url)
},
anvilURL: 'https://app.useanvil.com',
enableDefaultStyles: true,
}

AnvilSignatureFrame.propTypes = {
signURL: PropTypes.string.isRequired,
signURL: PropTypes.string,
scroll: PropTypes.string,
onLoad: PropTypes.func,
onFinish: PropTypes.func,
anvilURL: PropTypes.string,
enableDefaultStyles: PropTypes.bool,
}

export default AnvilSignatureFrame
9 changes: 2 additions & 7 deletions packages/react-signature-frame/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = {
entry: path.resolve(__dirname, 'src', 'index.js'),
Expand All @@ -8,11 +7,6 @@ module.exports = {
filename: 'index.js',
libraryTarget: 'commonjs2',
},
plugins: [
new MiniCssExtractPlugin({
filename: 'styles.css',
}),
],
module: {
rules: [
{
Expand All @@ -22,13 +16,14 @@ module.exports = {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['@babel/plugin-proposal-class-properties'],
},
},
},
{
test: /\.css$/,
exclude: /node_modules/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
use: ['style-loader', 'css-loader'],
},
],
},
Expand Down
Loading