-
Notifications
You must be signed in to change notification settings - Fork 734
chore: infer SVG size from style #2742
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
b1c065d
to
64046f2
Compare
64046f2
to
9920c2b
Compare
src/components/svgImage/index.tsx
Outdated
@@ -28,7 +30,12 @@ function SvgImage(props: SvgImageProps) { | |||
if (isSvgUri(data)) { | |||
return <SvgCssUri {...others} uri={data.uri}/>; | |||
} else if (typeof data === 'string') { | |||
return <SvgXml xml={data} {...others}/>; | |||
const flattenStyle = StyleSheet.flatten(props.style) as Record<string, any>; |
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 use flatten
very rarely, why is this required 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.
to extract the width
and height
from the provided styles.
do you have suggestion how to do it differently?
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.
are we sure its coming with more than one style object ?
if not, and we always have just single style object (and not as array).?
we can remove that.
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.
yes i'm sure. we can't remove it
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.
Can you please provide the scenario this is used in?
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.
Yes, for example when using Button with SVG Icon, we're passing iconStyle
with width
& height
.
in this case it's been passed to the SVG component, and without this PR the height and width is not respected.
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.
<Button
id={id}
testID={TestIds.buttonElement}
style={style}
color={color}
iconSource={iconSource}
iconStyle={{width: Spacings.s6, height: Spacings.s6}}
round
size={Button.sizes.large}
/>
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.
As discussed, lets allow passing iconProps
to the Button
instead, which will allow sending width
and height
Description
Button
- support passingiconProps
Changelog
Button
- support passingiconProps
Additional info