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

Fix image svg #2727

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Fix image svg #2727

wants to merge 24 commits into from

Conversation

mendyEdri
Copy link
Contributor

@mendyEdri mendyEdri commented Aug 28, 2023

Description

Until now, all images with url used SvgImage component, because source was a url and isSvg returned true.

Changelog

Added support for Image web

Additional info

@mendyEdri mendyEdri changed the title fix image svg Fix image svg Aug 30, 2023
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 its good to add a demo item to the webDemo app

Copy link
Contributor

Choose a reason for hiding this comment

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

also can you create a version, so we can test it before the merge ? in our Editor
@AmitShwarts, can you give it a try once, @mendyEdri shares a version ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

7.8.0-snapshot.3463

Copy link
Contributor

Choose a reason for hiding this comment

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

@mendyEdri as we just talked, we're getting lot's of issues of width, height and resizeMode.
all of the page layout breaks for some reason because of this.. not sure why

useImageInsideContainer && styles.shrink
];

if (!this.shouldUseImageBackground() && Constants.isWeb) {
Copy link
Contributor

@OrenZak OrenZak Sep 4, 2023

Choose a reason for hiding this comment

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

Constants.isWebwill be always false, as you have index.web.tsx

<img
{...others}
src={finalSource}
style={StyleSheet.flatten([imageViewStyle, styles.containImage]) as CSSProperties}
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to always flat this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as you guys did, thought it's for flattening any sort of imageProps passed etc

Copy link
Contributor

Choose a reason for hiding this comment

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

i'm not sure we need it here, on the Icon comp it was because the button passes some default styles as array.
not sure its the case here.

Copy link
Contributor

@lidord-wix lidord-wix left a comment

Choose a reason for hiding this comment

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

I added some comments, but... I have to say that I don't like this solution, it'll require Uilib to maintain two image files, and I'm confident that it will be forgotten.
react-native-web supports RN's Image, so we should re-check what doesn't work and close the gaps.
Until now we added the .web files only when something isn't supported on the web and I think we should keep doing it instead of duplicating to code.

@@ -119,7 +119,7 @@
"react-test-renderer": "18.2.0",
"reassure": "^0.4.1",
"shell-utils": "^1.0.10",
"typescript": "4.9.5"
"typescript": "^4.9.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it part of this PR in purpose?

src/components/image/index.web.tsx Show resolved Hide resolved
Comment on lines +74 to +81
isGif() {
if (Constants.isAndroid) {
const {source} = this.props;
const url = _.get(source, 'uri');
const isGif = /(http(s?):)([/|.|\w|\s|-])*\.gif/.test(url ?? '');
return isGif;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we can remove it here

Copy link
Contributor

Choose a reason for hiding this comment

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

Something looks different in the webDemo project in the Animated Image example, when I run it with the changes from this PR.


return (
// @ts-expect-error
<View style={imageViewStyle}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you add this extra View and not pass the style to the img component?

Copy link
Contributor

Choose a reason for hiding this comment

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

i guess because of the overlay, but it seems that both have the same imageViewStyle which is wired a bit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@OrenZak is right

@mendyEdri
Copy link
Contributor Author

I added some comments, but... I have to say that I don't like this solution, it'll require Uilib to maintain two image files, and I'm confident that it will be forgotten. react-native-web supports RN's Image, so we should re-check what doesn't work and close the gaps. Until now we added the .web files only when something isn't supported on the web and I think we should keep doing it instead of duplicating to code.

I don't mind. atm in production sources with type of string (either source={url} or images actual data) are rendering the SVG component which causes issues and left us with production bugs.

Also, the current mobile image implementation cannot render ImageBackground properly in web.
moreover, using the mobile image, rendered styling weird, and wasn't affecting by image-ratio prop.

I suggest to assign someone from the team to address it :)
thanks!

@OrenZak
Copy link
Contributor

OrenZak commented Sep 7, 2023

I added some comments, but... I have to say that I don't like this solution, it'll require Uilib to maintain two image files, and I'm confident that it will be forgotten. react-native-web supports RN's Image, so we should re-check what doesn't work and close the gaps. Until now we added the .web files only when something isn't supported on the web and I think we should keep doing it instead of duplicating to code.

I don't mind. atm in production sources with type of string (either source={url} or images actual data) are rendering the SVG component which causes issues and left us with production bugs.

Also, the current mobile image implementation cannot render ImageBackground properly in web. moreover, using the mobile image, rendered styling weird, and wasn't affecting by image-ratio prop.

I suggest to assign someone from the team to address it :) thanks!

@ethanshar can you help ?

Copy link
Collaborator

@ethanshar ethanshar left a comment

Choose a reason for hiding this comment

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

I don't think we want to go with a duplicate file for the Image component just for web.
These type of solutions won't scale, we can't maintain two identical files for two platforms..

Either we come up with a better solution, or please open a detailed ticket and we'll tailor this properly.

@ethanshar
Copy link
Collaborator

Is this PR still relevant? can we close it?

@mendyEdri
Copy link
Contributor Author

Is this PR still relevant? can we close it?

It is.
Removing it, still breaking images in web-editor

@ethanshar
Copy link
Collaborator

But we don't use this fix, it's not merged.
Is there still an issue with SVG?

@mendyEdri
Copy link
Contributor Author

But we don't use this fix, it's not merged.

Is there still an issue with SVG?

We do, we use this version in web-editor.
And yes, there is still an issue

Copy link

stale bot commented Mar 13, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 13, 2024
@stale stale bot removed the wontfix label Apr 3, 2024
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

5 participants