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: create web components and handle web events #2312

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
54f5229
feat: add handle event from PanResponder
bohdanprog Jun 22, 2024
14f10f5
feat: create utils and types folder
bohdanprog Jun 25, 2024
13b00c5
feat: add babel.config.web.js update webpack, remove unused packages
bohdanprog Jun 25, 2024
f785ac6
feat: work version with PanResponder
bohdanprog Jun 25, 2024
230276e
feat: update PanResponder example, handle onPress event
bohdanprog Jun 26, 2024
9ce7e60
clean code
bohdanprog Jun 28, 2024
a1e9201
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Jul 10, 2024
c11f2a8
feat: update ReactNativeSvg.web
bohdanprog Jul 10, 2024
2f5d09e
feat: update WebShape component
bohdanprog Jul 11, 2024
9a6ed49
feat: reorganize file structure
bohdanprog Jul 11, 2024
4407c78
feat: create custom hook, add work version
bohdanprog Jul 11, 2024
b4b3483
feat: update types
bohdanprog Jul 11, 2024
bbe5469
feat: add more events to hook useHandleEvents
bohdanprog Jul 12, 2024
f820c08
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Jul 12, 2024
44496c0
fix: fix problem with reanimated and update prepare function
bohdanprog Jul 15, 2024
da95d53
feat: update Reanimated example
bohdanprog Jul 15, 2024
0667fc8
feat: remove unused file
bohdanprog Jul 15, 2024
bec9248
feat: extract setNativeProps function, update Svg component
bohdanprog Jul 17, 2024
2072a5c
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Jul 18, 2024
a8e6986
feat: update component, memorize prop data
bohdanprog Jul 18, 2024
e3b92b5
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Jul 18, 2024
9a16866
feat: update WebShape
bohdanprog Jul 19, 2024
bb369b4
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Jul 23, 2024
d659b75
fix: remove from prepeare function unused matching prop
bohdanprog Jul 23, 2024
13d3b50
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Aug 1, 2024
def72f4
feat: update after merge
bohdanprog Aug 1, 2024
5c615ba
fix: handle web events, update panResponder example, update imports
bohdanprog Aug 1, 2024
d93d7db
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Aug 20, 2024
bacece8
chore: remove babel.config.web and remove changes from babel.config i…
bohdanprog Aug 20, 2024
5f9cc2c
chore: remove unused changes
bohdanprog Aug 20, 2024
877299a
chore: add eslint-disable-next-line import/no-unresolved on useHandle…
bohdanprog Aug 20, 2024
8c52d98
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Aug 21, 2024
a303b63
feat: update SebShape component
bohdanprog Aug 21, 2024
607ce8e
feat: update WebShape component
bohdanprog Aug 21, 2024
3212a75
Merge branch '@bohdanprog/handle-web-events' of github.com:software-m…
bohdanprog Aug 21, 2024
3530912
feat: update webshape component, fixed problem with reseting props
bohdanprog Aug 22, 2024
1b91311
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Aug 23, 2024
0bebd9c
chore: sort alphabetically imports in elements.web.ts
bohdanprog Aug 26, 2024
ed8f0da
feat: create separate files for utils function
bohdanprog Aug 26, 2024
a34daf5
chore: update imports
bohdanprog Aug 26, 2024
4b52b02
chore: rename interace for prepare props
bohdanprog Aug 26, 2024
780d47c
feat: update hasResponderEvents function
bohdanprog Aug 26, 2024
0f42250
fix: problem with function toDataURL in web platform
bohdanprog Aug 27, 2024
cf864c2
feat: add hooks from react-native-web
bohdanprog Sep 4, 2024
027cce8
feat: update hooks
bohdanprog Sep 9, 2024
28a1de1
feat: migrate correct hooks from react-native-web, also convert them …
bohdanprog Sep 20, 2024
a0da998
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Sep 20, 2024
3fe42b5
fix: typescript problem, and update yarn.lock
bohdanprog Sep 20, 2024
41f2ea8
feat: remove import fr om elements.web.ts, remove unused component
bohdanprog Sep 23, 2024
01169bc
feat: update CreateComponentProps interface
bohdanprog Sep 23, 2024
04c0842
feat: update ResponderConfig type
bohdanprog Sep 23, 2024
b8f45d5
feat: update prepare function, remove type cast for ref
bohdanprog Sep 23, 2024
edf263d
chore: update imports
bohdanprog Sep 23, 2024
8b129a4
feat: add correctly toDataURL method to svg component
bohdanprog Sep 23, 2024
8418dcd
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Sep 23, 2024
95b295b
feat: update CreateComponentProps interface, and change prepare funct…
bohdanprog Sep 23, 2024
68e1bf5
chore: rename ref element
bohdanprog Sep 23, 2024
e339291
chore: remove unused function
bohdanprog Sep 23, 2024
91714f7
chore: change type imports
bohdanprog Sep 24, 2024
94e082c
chore: remove react-native-web from package.json
bohdanprog Sep 24, 2024
505c8b2
feat: removed from root library hooks from react-native-web
bohdanprog Sep 24, 2024
d9988fc
feat: add react-native-web library
bohdanprog Sep 24, 2024
629950d
feat: create types file for react-native-web hooks
bohdanprog Sep 24, 2024
919dced
feat: create react-native-web.d.ts file
bohdanprog Sep 24, 2024
ab17709
chore: declare module for useMergeRefs
bohdanprog Sep 24, 2024
1c1e296
feat: create webUtils.web and import hooks from react-native-web
bohdanprog Sep 24, 2024
d213c89
chore: update hooks and type imports
bohdanprog Sep 24, 2024
c011372
chore: restore TouchEvents example
bohdanprog Sep 24, 2024
f03f6db
chore: removed unnecessary changes
bohdanprog Oct 9, 2024
e4b01b5
Merge branch 'main' of github.com:software-mansion/react-native-svg i…
bohdanprog Oct 9, 2024
e468133
chore: update Podfile.lock
bohdanprog Oct 9, 2024
2890018
chore: update Podfile.lock
bohdanprog Oct 9, 2024
a462699
Merge branch 'main' into @bohdanprog/handle-web-events
jakex7 Nov 4, 2024
7cd7343
chore: deps
jakex7 Nov 4, 2024
01e4183
docs: simplify pan example
jakex7 Nov 4, 2024
0b507d3
chore: update web-example app config
jakex7 Nov 4, 2024
a282da3
Merge branch 'main' into @bohdanprog/handle-web-events
jakex7 Nov 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 44 additions & 59 deletions apps/examples/src/examples/PanResponder.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,57 @@
import React, {PureComponent} from 'react';
import {
Animated,
PanResponder,
TouchableWithoutFeedback,
View,
} from 'react-native';
import {G, Line, Path, Polyline, Svg, Text} from 'react-native-svg';
import React, {Component} from 'react';
import {Animated, PanResponder, View} from 'react-native';
import {G, Line, Path, Polyline, Text, Svg} from 'react-native-svg';

const AnimatedSvg = Animated.createAnimatedComponent(Svg as any);

const zeroDelta = {x: 0, y: 0};

class PanExample extends PureComponent {
class PanExample extends Component {
static title = 'Bind PanResponder on the SVG Shape';
panXY: any;
constructor(props: {}, context: {}) {
super(props, context);
const xy = new Animated.ValueXY();
const {x: dx, y: dy} = xy;
let offset = zeroDelta;
xy.addListener(flatOffset => {
offset = flatOffset;
});
const {panHandlers} = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onMoveShouldSetPanResponderCapture: () => true,
onPanResponderGrant: () => {
xy.setOffset(offset);
xy.setValue(zeroDelta);
},
onPanResponderMove: Animated.event([null, {dx, dy}], {
useNativeDriver: false,
}),
pan: Animated.ValueXY;
panResponder: any;
constructor(props: {}) {
super(props);

this.pan = new Animated.ValueXY();

this.panResponder = PanResponder.create({
onMoveShouldSetPanResponder: () => true,
onPanResponderMove: Animated.event(
[null, {dx: this.pan.x, dy: this.pan.y}],
{useNativeDriver: false},
),
onPanResponderRelease: () => {
xy.flattenOffset();
this.pan.extractOffset();
},
});
this.panXY = {
style: {
transform: xy.getTranslateTransform(),
},
...panHandlers,
};
}
render() {
return (
<TouchableWithoutFeedback>
<View>
<AnimatedSvg height="200" width="200" {...this.panXY}>
<Path
d="M50,5L20,99L95,39L5,39L80,99z"
stroke={'black'}
fill={'red'}
strokeWidth="6"
scale="0.8"
/>
<Text
fontSize="20"
fontWeight="bold"
fill="blue"
textAnchor="middle"
x="40"
y="80">
STAR
</Text>
</AnimatedSvg>
</View>
</TouchableWithoutFeedback>
<View>
<AnimatedSvg
height="200"
width="200"
style={{
transform: [{translateX: this.pan.x}, {translateY: this.pan.y}],
}}
{...this.panResponder.panHandlers}>
<Path
d="M50,5L20,99L95,39L5,39L80,99z"
stroke={'black'}
fill={'red'}
strokeWidth="6"
scale="0.8"
/>
<Text
fontSize="20"
fontWeight="bold"
fill="blue"
textAnchor="middle"
x="40"
y="80">
STAR
</Text>
</AnimatedSvg>
</View>
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/examples/src/examples/TouchEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class PressExample extends Component {
cy="50%"
r="38%"
fill="red"
onPress={() => Alert.alert('Press on Circle')}
onPress={() => console.log('Press on Circle')}
/>
<Rect
x="20%"
y="20%"
width="60%"
height="60%"
fill="blue"
onLongPress={() => Alert.alert('Long press on Rect')}
onLongPress={() => console.log('Long press on Rect')}
/>
<Path d="M50,5L20,99L95,39L5,39L80,99z" fill="pink" />
</Svg>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"react": "^18.2.0",
"react-native": "^0.72.3",
"react-native-builder-bob": "^0.20.4",
"react-native-web": "^0.19.10",
"react-native-windows": "^0.72.4",
"react-test-renderer": "^18.2.0",
"release-it": "^14.12.5",
Expand Down
Loading
Loading