Skip to content

Commit d39a96a

Browse files
Merge branch 'master' into kkemple/support-react-360
2 parents d88d960 + 7d8e6b4 commit d39a96a

File tree

82 files changed

+197
-5168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+197
-5168
lines changed

.eslintrc

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
{
22
"parser": "babel-eslint",
33
"extends": "airbnb",
4-
"plugins": [
5-
"prefer-object-spread"
6-
],
7-
"ecmaFeatures": {
8-
"arrowFunctions": true,
9-
"blockBindings": true,
10-
"classes": true,
11-
"defaultParams": true,
12-
"destructuring": true,
13-
"forOf": false,
14-
"generators": false,
15-
"modules": true,
16-
"experimentalObjectRestSpread": true,
17-
"objectLiteralComputedProperties": true,
18-
"objectLiteralDuplicateProperties": false,
19-
"objectLiteralShorthandMethods": true,
20-
"objectLiteralShorthandProperties": true,
21-
"restParams": true,
22-
"spread": true,
23-
"superInFunctions": true,
24-
"templateStrings": true
25-
},
264
"rules": {
275
"prefer-template": 0,
286
"new-cap": 0,
@@ -34,6 +12,11 @@
3412
"no-console": 0,
3513
// Disable `arrow-parens` because it conflicts with Flow.
3614
"arrow-parens": 0,
37-
"prefer-object-spread/prefer-object-spread": 2
15+
"global-require": 0,
16+
"react/jsx-filename-extension": 0,
17+
"no-underscore-dangle": 0,
18+
"import/no-extraneous-dependencies": 0,
19+
"react/no-unused-prop-types": 0,
20+
"react/require-default-props": 0
3821
}
3922
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ node_modules
2828

2929
# Optional npm cache directory
3030
.npm
31+
package-lock.json
3132

3233
# Optional REPL history
3334
.node_repl_history

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
sudo: false
2+
os: osx
3+
osx_image: xcode8.2
24
language: node_js
35
node_js:
46
- "6"
5-
addons:
6-
# This is the latest version of Firefox that currently supports Happo.
7-
# https://github.com/SeleniumHQ/selenium/issues/2559
8-
firefox: "47.0.1"
9-
before_script:
10-
- 'sh -e /etc/init.d/xvfb start'
117
script:
128
- 'npm run travis'

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,32 @@ Primitive React Interfaces Across Targets
55
## Installation
66

77
```sh
8-
npm i --save react-primitives
8+
npm install --save react-primitives
99
```
1010

11+
You will also need to install the targets you want to support:
12+
13+
- web:
14+
```sh
15+
npm install --save react-dom react-native-web react-art
16+
```
17+
- native iOS and Android:
18+
```sh
19+
npm install --save react-native
20+
```
21+
- sketch:
22+
```sh
23+
npm install --save react-sketchapp react-test-renderer
24+
```
25+
- vr:
26+
```sh
27+
npm install --save react-vr
28+
```
29+
- Windows:
30+
```sh
31+
npm install --save react-native-windows
32+
```
33+
1134
### Usage
1235

1336
```jsx
@@ -33,7 +56,6 @@ const styles = StyleSheet.create({
3356
});
3457
```
3558

36-
3759
## What is this?
3860

3961
This library attempts to propose an ideal set of primitives around building
@@ -44,20 +66,24 @@ don't use platform-specific APIs.
4466
Importantly, this includes `StyleSheet` for declaring styles, as well as
4567
`Animated` for doing declarative Animations.
4668

47-
The exported interface thus far is:
69+
The exported APIs thus far are:
4870

4971
1. `Animated`: Pulled from the [animated](https://github.com/animatedjs/animated) project.
5072
2. `StyleSheet`: Follows React Native's StyleSheet API.
5173
3. `View`: A base component for Layout.
5274
4. `Text`: A base component for Text rendering.
5375
5. `Image`: A base component for Image rendering.
5476
6. `Touchable`: A base component for interaction.
77+
7. `Easing`: A base set of easing functions.
78+
8. `Dimensions`: Get the devices dimensions.
79+
9. `PixelRatio`: Get the devices pixel density.
80+
10. `Platform`: Get information about the platform. (iOS, Android, Web, Sketch, VR,...)
5581

5682
In the future, a `TextInput` component may also be added.
5783

5884

5985
## Props where props are due
6086

61-
This library was largely inspired from the work done by [Nicolas Gallager](https://github.com/necolas)
87+
This library was largely inspired from the work done by [Nicolas Gallager](https://github.com/necolas)
6288
and his great work on the [react-native-web](https://github.com/necolas/react-native-web) library. A few of the files
6389
in this repo are even copied directly from his project.

example/AllStories.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { getStories } from './StoryManager';
66
import './stories/View';
77
import './stories/Image';
88
import './stories/Text';
9+
import './stories/Touchable';
10+
import './stories/Animated';
911

1012
const styles = StyleSheet.create({
1113
app: {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React from 'react';
2+
import { make } from '../../StoryManager';
3+
import { View, Text, Animated, Touchable } from '../../../src/index';
4+
5+
make('Animated 1', () => {
6+
class Example extends React.Component{
7+
constructor(props) {
8+
super(props)
9+
10+
this.state = {
11+
anim: new Animated.Value(0),
12+
on: false
13+
}
14+
15+
this.handleClick = this.handleClick.bind(this)
16+
}
17+
18+
render() {
19+
return (
20+
<Animated.View style={{left: this.state.anim}}>
21+
<Touchable onPress={this.handleClick}>
22+
<View style={{ borderWidth: 1, borderColor: '#000' }}>
23+
<Text
24+
style={{
25+
fontFamily: 'Helvetica',
26+
fontSize: 14,
27+
lineHeight: 16,
28+
}}
29+
>
30+
Touch Me!
31+
</Text>
32+
</View>
33+
</Touchable>
34+
</Animated.View>
35+
)
36+
}
37+
38+
handleClick() {
39+
if (this.state.on) {
40+
Animated.timing(this.state.anim, {toValue: 0}).start();
41+
this.setState({
42+
on: false
43+
})
44+
} else {
45+
Animated.timing(this.state.anim, {toValue: 400}).start();
46+
this.setState({
47+
on: true
48+
})
49+
}
50+
}
51+
}
52+
53+
return <Example />
54+
});

example/stories/Animated/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './Animated1';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import { make } from '../../StoryManager';
3+
import { View, Text, Touchable } from '../../../src/index';
4+
5+
make('Touchable 1', () => (
6+
<Touchable onPress={() => console.log('pressed')}>
7+
<View style={{ borderWidth: 1, borderColor: '#000' }}>
8+
<Text
9+
style={{
10+
fontFamily: 'Helvetica',
11+
fontSize: 14,
12+
lineHeight: 16,
13+
}}
14+
>
15+
Touch Me!
16+
</Text>
17+
</View>
18+
</Touchable>
19+
));

example/stories/Touchable/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './Touchable1';

example/web/example.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>Title</title>
6+
<style>
7+
html {
8+
background: white;
9+
}
10+
</style>
611
</head>
712
<body>
813
<div class="root"></div>

0 commit comments

Comments
 (0)