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

feat!: Svg intrinsic size, auto and custom shadow nodes for RNSVGSvg #2577

Closed
wants to merge 7 commits into from

Conversation

jakex7
Copy link
Member

@jakex7 jakex7 commented Dec 13, 2024

Summary

BREAKING CHANGE / NEW ARCH ONLY

Implement intrinsic and auto value for width and height on Svg component based on the specification.

Initial ‘svg’ element width and height are set to 'auto' [...]

To resolve 'auto' value on ‘svg’ element if the ‘viewBox’ attribute is not specified:

  • Use author specified width and height ‘svg’ element attributes.
  • If any of the sizing attributes are missing, resolve the missing ‘svg’ element width to '300px' and missing height to '150px' (using CSS 2.1 replaced elements size calculation).

To resolve 'auto' value on ‘svg’ element if the ‘viewBox’ attribute is specified:

  • Use the ‘viewBox’ attribute to calculate the intrinsic aspect ratio of the ‘svg’ element.
  • If the width or height attributes are not specified - keep not specified width or height as 'auto'.

A huge thanks to @janicduplessis for #1720 with a similar concept. However, it needed to be implemented slightly different for some edge cases and the RNSVGImage implementation, which requires being a yoga node.

Test Plan

Example app -> Svg examples

image

Compatibility

OS Implemented
iOS
MacOS
Android
Web

Checklist

  • I have tested this on a device and a simulator
  • I added documentation in README.md
  • I updated the typed files (typescript)

@jakex7 jakex7 changed the title feat!: introduce Svg auto width and custom shadow nodes for RNSVGSvg feat!: Svg intrinsic size, auto and custom shadow nodes for RNSVGSvg Dec 13, 2024
@jakex7 jakex7 marked this pull request as draft December 16, 2024 12:46
@jakex7
Copy link
Member Author

jakex7 commented Dec 20, 2024

Closing it for now as it's not compatible with paper and would be a huge breaking change.

@jakex7 jakex7 closed this Dec 20, 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.

1 participant