Skip to content
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

Introduce enlargedImagePosition prop #5

Merged

Conversation

damien916
Copy link
Contributor

Hello @ethanselzer
I just add optional prop enlargedImagePosition to choose position of enlarged image :

beside (default for ReactImageMagnify) : enlarged image will be next to the small image
over (default for ReactImageMagnifyTouch) : enlarged image will be over the small image

Have a nice day :)


let defaultLensStyle = {};

switch (enlargedImagePosition) {
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think about changing this to something like the following? It seems simpler to me.

    let defaultLensStyle = {
        backgroundColor: 'rgba(0,0,0,.4)'
    };
    
    if (enlargedImagePosition === 'over') {
        defaultLensStyle = {};
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right, it's simpler.

@@ -123,13 +141,15 @@ ReactImageMagnify.propTypes = {
largeImage: ImageShape,
lensStyle: PropTypes.object,
smallImage: ImageShape,
style: PropTypes.object
style: PropTypes.object,
enlargedImagePosition: PropTypes.string
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think about changing the prop validation to React.PropTypes.oneOf(['beside', 'over'])? I'm thinking It helps to document the API and it might give valuable feedback in the scenario where a developer has a typo or uses the wrong word by mistake. If using oneOf breaks the test for prop types (it has correct prop types), then I think I am okay with removing the test, or finding a different (better) way to test prop types. The current test for prop types is not supported by React and is not a standard method in the community. Please let me know your thoughts!

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's a very good idea, I did not think about that, I'll change that quickly.

@@ -91,11 +93,13 @@ ReactImageMagnifyTouch.propTypes = {
pressDuration: PropTypes.number,
pressMoveThreshold: PropTypes.number,
smallImage: ImageShape,
style: PropTypes.object
style: PropTypes.object,
enlargedImagePosition: PropTypes.string
Copy link
Owner

Choose a reason for hiding this comment

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

Please see my comment above.

@ethanselzer
Copy link
Owner

@damien916 I think this is a great feature! Thank you very much for creating it! I left a couple comments on your PR. Please let me know what you think about them. ~Ethan

@damien916
Copy link
Contributor Author

@ethanselzer I just add two commits to the PR. I don't finded solution to test oneOf PropType with enzyme, so I commented them. Thank you again. Damien

@ethanselzer ethanselzer merged commit f19b422 into ethanselzer:master Feb 17, 2017
@ethanselzer
Copy link
Owner

@damien916 - Thanks for making the adjustments I suggested! I really appreciate it. The npm package has been updated and a new release has been created on GitHub. You are awesome! ✨💫

@damien916
Copy link
Contributor Author

@ethanselzer Thank you so much 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants