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

Review Follow Ups and Refactoring #2

merged 21 commits into from
Dec 3, 2020

Conversation

Winggo
Copy link
Contributor

@Winggo Winggo commented Nov 17, 2020

Description of the change

  • @anvilco/react-signature-frame and @anvilco/react-signature-modal v1.4.3 are published. Finished up docs.
  • Incorporated review changes
    • AnvilSignatureFrame
      • importing css no longer required, default styles are embedded into the component
      • styles can overridden using classNames and ids
      • custom id and className supported through props
      • removed listening for message from staging
      • removed ANVIL_URLS.includes()
      • custom props passed into component supported
      • classNames and ids use kebab-case
    • AnvilSignatureFrame
      • @anvilco/react-signature-frame component used within @anvilco/react-signature-modal component
      • modal app element is configurable
  • Refactored components into class components

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Dev Checklist

  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development
  • No previous tests unrelated to the changed code fail in development

@Winggo Winggo added the documentation Improvements or additions to documentation label Nov 17, 2020
@Winggo Winggo requested a review from benogle November 17, 2020 01:30
@Winggo Winggo self-assigned this Nov 17, 2020
@Winggo Winggo changed the title Final Touches on Repo Setup and Docs Review Follow Ups and Refactoring Nov 18, 2020
@Winggo Winggo added the enhancement New feature or request label Nov 18, 2020
import PropTypes from 'prop-types'
import ReactModal from 'react-modal'
import AnvilSignatureFrame from '../../react-signature-frame/src/index.js'
import DeleteIcon from './components/DeleteIcon'
import './index.css'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still dont love that we are always importing styles here. But maybe it's fine for now. The output code will inject a style tag in the dom. Not ideal if they want to replace the styling, but probably fine for now.

There is a way to lazy load components, but looks like react >= 16.6: https://medium.com/@prawira/react-conditional-import-conditional-css-import-110cc58e0da6. We could do this later on and select on a prop like loadDefaultStyles or something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about this for a bit and came up with a better idea that doesn't involve importing css, since we don't want to inject a style tag. I've put the default styles inline using the style prop and added an enableDefaultStyles prop that defaults to true. If users set enableDefaultStyles to false, then all the inline styles are removed and can be overriden.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this

<AnvilSignatureFrame
   style={enableDefaultStyles
      ? {
            width: '80vw',
            height: '85vh',
            maxWidth: '1200px',
            borderStyle: 'none',
         }
      : undefined}
   {...anvilFrameProps}
   signURL={signURL}
   onLoad={onLoad}
   onFinish={onFinish}
   anvilURL={anvilURL}
/>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok noted. I think there is a more flexible way to do the width and height in the modal then. Maybe use width/height 100% then the users can size the modal and the iframe will react accordingly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works the opposite way when I play around with it. The modal reacts to AnvilSignatureFrame. Whatever width/height you set the frame to, that's how big the modal will be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it respond in mobile? The view units thing is good except when the modal gets below like 4 or 500px. Below that, it should take up the whole width of the screen, or maybe minus like 10px so people know its in a modal.

I'm not opposed to the css file in this component then nulling out the style on the frame. It would let you do media queries, and we could get exactly the behavior we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case I'll add some CSS for media queries for mobile.

@benogle
Copy link
Contributor

benogle commented Nov 19, 2020

Looking good. I tried it out on the example repo and the styling on the modal is good too 👍

@Winggo
Copy link
Contributor Author

Winggo commented Nov 24, 2020

Addressed all the feedback here and released them in v1.4.4.

@Winggo Winggo requested a review from benogle November 30, 2020 17:13
Copy link
Contributor

@benogle benogle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, maybe just dont need to duplicate the frame default styling

Comment on lines 60 to 67
style={enableDefaultStyles
? {
width: '80vw',
height: '85vh',
maxWidth: '1200px',
borderStyle: 'none',
}
: undefined}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just pass enableDefaultStyles to AnvilSignatureFrame here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this here because the default borderStyle of the frame is groove. The groove borderStyle doesn't look good on the modal so here I've overridden it with borderStyle none.

Comment on lines +15 to +19
@media only screen and (max-width: 500px) {
#anvil-signature-modal {
width: calc(100vw - 10px);
height: 90vh;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added css here for small mobile devices mentioned earlier

@Winggo Winggo merged commit c904853 into main Dec 3, 2020
@Winggo Winggo deleted the wt/docs branch December 3, 2020 19:26
ReactModal.setAppElement('#root')
import AnvilSignatureFrame from '../../react-signature-frame/src/index.js'
import IconClose from './components/IconClose.js'
import './styles.css'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didnt we agree to leave the import out of here, but generate the css into dist, then let people import it on their own? I think that would be the most flexible approach

Copy link
Contributor Author

@Winggo Winggo Dec 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did agree on that. This generates a styles.css file into dist, and lets people import it if they choose. I can leave the import './styles.css' in the component file since MiniCssExctractPlugin does that for me. The plugin does what you're saying when it sees css imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tested this on the example app. When I remove import '@anvilco/react-signature-modal/dist/styles.css' the style tag in is removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok cool. I thought it injected it. Carry on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good on making sure I had it right 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants