-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
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' |
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.
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
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.
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.
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.
Like this
<AnvilSignatureFrame
style={enableDefaultStyles
? {
width: '80vw',
height: '85vh',
maxWidth: '1200px',
borderStyle: 'none',
}
: undefined}
{...anvilFrameProps}
signURL={signURL}
onLoad={onLoad}
onFinish={onFinish}
anvilURL={anvilURL}
/>
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.
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
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.
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.
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.
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.
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.
In that case I'll add some CSS for media queries for mobile.
Looking good. I tried it out on the example repo and the styling on the modal is good too 👍 |
- @anvilco/[email protected] - @anvilco/[email protected]
Addressed all the feedback here and released them in v1.4.4. |
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.
Looks good, maybe just dont need to duplicate the frame default styling
style={enableDefaultStyles | ||
? { | ||
width: '80vw', | ||
height: '85vh', | ||
maxWidth: '1200px', | ||
borderStyle: 'none', | ||
} | ||
: undefined} |
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.
I think you can just pass enableDefaultStyles to AnvilSignatureFrame here...
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.
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
.
@media only screen and (max-width: 500px) { | ||
#anvil-signature-modal { | ||
width: calc(100vw - 10px); | ||
height: 90vh; | ||
} |
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.
Added css here for small mobile devices mentioned earlier
ReactModal.setAppElement('#root') | ||
import AnvilSignatureFrame from '../../react-signature-frame/src/index.js' | ||
import IconClose from './components/IconClose.js' | ||
import './styles.css' |
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.
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
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.
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.
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.
Also tested this on the example app. When I remove import '@anvilco/react-signature-modal/dist/styles.css'
the style tag in is removed.
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.
ah ok cool. I thought it injected it. Carry on
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.
Good on making sure I had it right 😉
Description of the change
@anvilco/react-signature-frame
and@anvilco/react-signature-modal
v1.4.3 are published. Finished up docs.AnvilSignatureFrame
ANVIL_URLS.includes()
AnvilSignatureFrame
@anvilco/react-signature-frame
component used within@anvilco/react-signature-modal
componentType of change
Related issues
Dev Checklist