Skip to content

fix/svg image respect width height props on web #2748

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

Closed

Conversation

AmitShwarts
Copy link
Contributor

@AmitShwarts AmitShwarts commented Sep 18, 2023

Description

on web, SvgImage didn't respect width & height props.
currently we need to provide the width & height as props and also in style, so it would be respected both in web and mobile.

Changelog

SvgImage now respects width & height props on web

Additional info

in order to see the changes in the web demo you need to apply the changes manually in node_modules of the web-demo

@AmitShwarts AmitShwarts force-pushed the chore/SvgImage_respect-width-height-props-on-web branch 2 times, most recently from cf4c9b8 to d6cfb67 Compare September 18, 2023 17:27
@AmitShwarts AmitShwarts force-pushed the chore/SvgImage_respect-width-height-props-on-web branch from d6cfb67 to 202066e Compare September 18, 2023 17:28
@@ -25,13 +27,13 @@ function SvgImage(props: SvgImageProps) {
const {postcss, cssjs} = PostCssPackage;
const styleObj: Record<string, any> = StyleSheet.flatten(style);
postcss()
.process(styleObj, {parser: cssjs})
.process({width, height, ...styleObj}, {parser: cssjs})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add someone that looked at web recently for this part

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@M-i-k-e-l M-i-k-e-l self-assigned this Sep 19, 2023
Copy link
Contributor

@adids1221 adids1221 left a comment

Choose a reason for hiding this comment

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

I wrote a few small comments

width: size,
height: size,
// width: size,
// height: size,
Copy link
Contributor

Choose a reason for hiding this comment

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

If the iconStyle object isn't relevant anymore let's remove it.
Delete the commented lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

relevant for the tint.
i'll remove the commented lines

/**
* the icon height
*/
height?: number | string;
Copy link
Contributor

@adids1221 adids1221 Sep 19, 2023

Choose a reason for hiding this comment

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

About the string type, when I pass the string I get this error:

JSON value of type NSString cannot be converted to a YGValue.

To get over this error the user should pass value% as the width or height value and this is not the result we want.

Let's make it only a number type.

git issue

Copy link
Collaborator

@M-i-k-e-l M-i-k-e-l Sep 19, 2023

Choose a reason for hiding this comment

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

@adids1221 what string did you use?
It is working for me with width={'10%'} for example

@@ -11,6 +11,8 @@
{"name": "assetGroup", "type": "string", "description": "the asset group, default is icons"},
{"name": "tintColor", "type": "string", "description": "The icon tint"},
{"name": "size", "type": "number", "description": "The icon size"},
{"name": "height", "type": "number | string", "description": "The icon height"},
Copy link
Contributor

Choose a reason for hiding this comment

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

also change the type here to number.

@adids1221
Copy link
Contributor

Also, snapshot version to check in the webDemo: 7.8.0-snapshot.3520

@AmitShwarts
Copy link
Contributor Author

something messed up with git in this PR.
closing and opening new one

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.

3 participants