Skip to content

added Marker component to definition file#1209

Merged
msand merged 1 commit intosoftware-mansion:developfrom
SaeedZhiany:FixMarkerTypeDefinition
Dec 9, 2019
Merged

added Marker component to definition file#1209
msand merged 1 commit intosoftware-mansion:developfrom
SaeedZhiany:FixMarkerTypeDefinition

Conversation

@SaeedZhiany
Copy link
Copy Markdown
Contributor

Summary

This PR adding missing Marker related type definition. fixes #1208

Test Plan

What's required for testing (prerequisites)?

What are the steps to reproduce (after prerequisites)?

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I mentioned this change in CHANGELOG.md
  • I updated the typed files (TS and Flow)
  • I added a sample use of the API in the example project (example/App.js)

@SaeedZhiany
Copy link
Copy Markdown
Contributor Author

@msand
Please review this and tell me where is the Marker props you supported to add them to Path, line, Polyline, and Polygon classes.

@msand
Copy link
Copy Markdown
Contributor

msand commented Dec 7, 2019

Great, thanks for this! The marker props apply to all shapes: https://www.w3.org/TR/SVG/shapes.html#TermShapeElement
https://www.w3.org/TR/SVG/painting.html#MarkerProperty
The property handling is here:
https://github.com/react-native-community/react-native-svg/blob/8c1a1737b052000569662d6f2539ffe3c47564ba/src/lib/extract/extractProps.ts#L66-L69
https://github.com/react-native-community/react-native-svg/blob/8c1a1737b052000569662d6f2539ffe3c47564ba/src/lib/extract/extractProps.ts#L102-L110
Which is used in: Circle, ClipPath, Ellipse, G, Image, Line, Mask, Path, Rect, Text, TextPath, TSpan and Use elements, so they'll be processed in more places than they should at the moment, but that's essentially bugs / unspecified behaviour. They should only apply to: ‘circle’, ‘ellipse’, ‘line’, ‘path’, ‘polygon’, ‘polyline’ and ‘rect’. And g elements, as the property should be inherited.

@SaeedZhiany
Copy link
Copy Markdown
Contributor Author

SaeedZhiany commented Dec 9, 2019

@msand
I'm just a little bit confused, are you want to refactor extractProps function to only return the props for the shapes you mentioned?

My concern on this PR is fixing the building crash when using of Marker component and the typescript error TS2322 when passing marker(Start/Mid/End) props to a shape component like Path.

@msand
Copy link
Copy Markdown
Contributor

msand commented Dec 9, 2019

No need to refactor at this point, they shouldn't hurt afaik, can make another pr/issue if anything shows up. Thanks for this!

@msand msand changed the base branch from master to develop December 9, 2019 19:19
@msand msand marked this pull request as ready for review December 9, 2019 19:19
@msand msand merged commit 353eddc into software-mansion:develop Dec 9, 2019
@msand
Copy link
Copy Markdown
Contributor

msand commented Dec 9, 2019

🎉 This PR is included in version 9.13.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@msand msand added the released label Dec 9, 2019
@SaeedZhiany
Copy link
Copy Markdown
Contributor Author

SaeedZhiany commented Dec 10, 2019

@msand
Actually, my work was not completed yet. this change only fixes the build crash. the TS2322 still remains. (however, I'm glad at least I can build my project in my CI server).

My question was about the Marker props that already supported in code and must be added to props of components like Path and the other shapes you mentioned before to fix TS2322 error message.

The props I could find are markerStart, markerMid, and markerEnd that their types should be a string.

@msand
Copy link
Copy Markdown
Contributor

msand commented Dec 10, 2019

Oh, my mistake, was rushing thru the PRs as I barely have any time to dedicate to this project atm.
There's also the marker prop in addition to the start, mid and end, it's used as a default, and the three others take precedence over it. Could make a new interface like CommonMaskProps but called CommonMarkerProps instead and add it to CommonPathProps here: https://github.com/SaeedZhiany/react-native-svg/blob/cf150875a0554d32d89e0a486e859af322960715/src/index.d.ts#L209-L222

@SaeedZhiany
Copy link
Copy Markdown
Contributor Author

SaeedZhiany commented Dec 10, 2019

@msand
Thanks,
are you mean is this enough for users using a marker with Path (and other shapes)?

export interface CommonMarkerProps {
  markerStart?: string;
  markerMid?: string;
  markerEnd?: string;
}

I'll make another draft PR with your suggestion and I'll inform you.

@msand
Copy link
Copy Markdown
Contributor

msand commented Dec 10, 2019

yeah, or with the addition of the default marker prop:

export interface CommonMarkerProps {
  marker?: string;
  markerStart?: string;
  markerMid?: string;
  markerEnd?: string;
}

export interface CommonPathProps
  extends FillProps,
    StrokeProps,
    ClipProps,
    TransformProps,
    VectorEffectProps,
    ResponderProps,
    TouchableProps,
    DefinitionProps,
    CommonMarkerProps,
    CommonMaskProps {}

@SaeedZhiany
Copy link
Copy Markdown
Contributor Author

I'll send you a PR in a few seconds.

@SaeedZhiany SaeedZhiany deleted the FixMarkerTypeDefinition branch December 10, 2019 12:48
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.

2 participants