-
Notifications
You must be signed in to change notification settings - Fork 734
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
fix/svg image respect width height props on web #2748
Conversation
cf4c9b8
to
d6cfb67
Compare
d6cfb67
to
202066e
Compare
@@ -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}) |
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.
Maybe add someone that looked at web recently for this part
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.
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 wrote a few small comments
webDemo/src/App.tsx
Outdated
width: size, | ||
height: size, | ||
// width: size, | ||
// height: size, |
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.
If the iconStyle
object isn't relevant anymore let's remove it.
Delete the commented lines.
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.
relevant for the tint.
i'll remove the commented lines
src/components/icon/index.tsx
Outdated
/** | ||
* the icon height | ||
*/ | ||
height?: number | string; |
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.
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.
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.
@adids1221 what string did you use?
It is working for me with width={'10%'}
for example
src/components/icon/icon.api.json
Outdated
@@ -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"}, |
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 change the type here to number
.
Also, snapshot version to check in the webDemo: |
something messed up with git in this PR. |
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 webAdditional 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