Skip to content

Commit 1dfbbd3

Browse files
Merge pull request #143 from elemental-design/feat/figma-platform
Add react-figma platform
2 parents bc2d041 + 7584895 commit 1dfbbd3

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ You will also need to install the targets you want to support:
2424
```sh
2525
npm install --save react-sketchapp react-test-renderer
2626
```
27+
- figma:
28+
```sh
29+
npm install --save react-figma yoga-layout-prebuilt
30+
```
2731
- vr:
2832
```sh
2933
npm install --save react-360

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)