Skip to content

Commit 22bb06a

Browse files
add react-figma platform resolver
1 parent bc2d041 commit 22bb06a

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"react-360": "^1.1.0",
6565
"react-art": "^16.5.2",
6666
"react-dom": "^16.5.2",
67+
"react-figma": "0.0.57",
6768
"react-native": "^0.52.0",
6869
"react-native-web": "^0.11.0",
6970
"react-sketchapp": "^2.0.0",

src/index.figma.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require('./injection/react-figma');
2+
3+
module.exports = require('./ReactPrimitives');

src/injection/react-figma.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const ReactPrimitives = require('../ReactPrimitives');
2+
const Animated = require('animated');
3+
const Easing = require('animated/lib/Easing');
4+
const {
5+
View,
6+
Text,
7+
Image,
8+
StyleSheet,
9+
// TODO(lmr): Dimensions
10+
} = require('react-figma');
11+
12+
const TouchableMixin = {
13+
componentWillUnmount() {},
14+
touchableGetInitialState() {
15+
return { touchable: { touchState: undefined, responderID: null } };
16+
},
17+
touchableHandleResponderTerminationRequest() { return false; },
18+
touchableHandleStartShouldSetResponder() { return false; },
19+
touchableLongPressCancelsPress() { return true; },
20+
touchableHandleResponderGrant() {},
21+
touchableHandleResponderRelease() {},
22+
touchableHandleResponderTerminate() {},
23+
touchableHandleResponderMove() {},
24+
};
25+
26+
Animated.inject.FlattenStyle(StyleSheet.flatten);
27+
28+
ReactPrimitives.inject({
29+
StyleSheet,
30+
View,
31+
Text,
32+
Image,
33+
Easing,
34+
Animated: {
35+
...Animated,
36+
View: Animated.createAnimatedComponent(View),
37+
Text: Animated.createAnimatedComponent(Text),
38+
Image: Animated.createAnimatedComponent(Image),
39+
},
40+
Platform: {
41+
OS: 'figma',
42+
Version: 1,
43+
},
44+
});
45+
46+
ReactPrimitives.inject({
47+
Touchable: require('../modules/Touchable')(
48+
Animated,
49+
StyleSheet,
50+
ReactPrimitives.Platform,
51+
TouchableMixin,
52+
),
53+
});

0 commit comments

Comments
 (0)