Skip to content

Commit a04f788

Browse files
committed
feat(codebase): react native support (danilowoz#153)
re danilowoz#148, re danilowoz#137, re danilowoz#106, re danilowoz#89, re danilowoz#16, re danilowoz#6 * build(rollup): native bundle * feat(native): stylized components * build(typescript): react native check * feat(typing): improves * build(tsconfig): by environment * test(web native): setup * test(native): support * docs(readme): native documentation
1 parent 578ee06 commit a04f788

Some content is hidden

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

54 files changed

+26503
-220
lines changed

.eslintrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "react-app",
3+
"rules": {
4+
"@typescript-eslint/no-angle-bracket-type-assertion": 0 // I don't know wtf it is
5+
}
6+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ yarn-error.log
99
node_modules
1010
dist
1111
coverage
12+
/native
1213
.docz/
1314
.rpt2_cache
1415
settings.json

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
language: node_js
22
sudo: false
33
node_js:
4-
- 9
4+
- 10
55
cache:
66
directories:
77
- node_modules
88
install:
99
- npm install
10-
- npm install -g codecov
1110
script:
1211
- npm run test
1312
- npm run build
1413
after_success:
15-
- npm run coverage
1614
- npm run release

README.md

Lines changed: 122 additions & 84 deletions
Large diffs are not rendered by default.

__mocks__/jestSetupFile.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
jest.mock('Animated', () => {
2+
return {
3+
Value: () => {
4+
return {
5+
addListener: callback => callback({ value: 0 }),
6+
setValue: () => {},
7+
}
8+
},
9+
timing: (value, config) => {
10+
return {
11+
start: callback => {
12+
value.setValue(config.toValue)
13+
callback && callback()
14+
},
15+
}
16+
},
17+
}
18+
})

__mocks__/react-native-svg.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import React from 'react';
2+
3+
const createComponent = function(name) {
4+
return class extends React.Component {
5+
// overwrite the displayName, since this is a class created dynamically
6+
static displayName = name;
7+
8+
render() {
9+
return React.createElement(name, this.props, this.props.children);
10+
}
11+
};
12+
};
13+
14+
// Mock all react-native-svg exports
15+
// from https://github.com/magicismight/react-native-svg/blob/master/index.js
16+
const Svg = createComponent('Svg');
17+
const Circle = createComponent('Circle');
18+
const Ellipse = createComponent('Ellipse');
19+
const G = createComponent('G');
20+
const Text = createComponent('Text');
21+
const TextPath = createComponent('TextPath');
22+
const TSpan = createComponent('TSpan');
23+
const Path = createComponent('Path');
24+
const Polygon = createComponent('Polygon');
25+
const Polyline = createComponent('Polyline');
26+
const Line = createComponent('Line');
27+
const Rect = createComponent('Rect');
28+
const Use = createComponent('Use');
29+
const Image = createComponent('Image');
30+
const Symbol = createComponent('Symbol');
31+
const Defs = createComponent('Defs');
32+
const LinearGradient = createComponent('LinearGradient');
33+
const RadialGradient = createComponent('RadialGradient');
34+
const Stop = createComponent('Stop');
35+
const ClipPath = createComponent('ClipPath');
36+
const Pattern = createComponent('Pattern');
37+
const Mask = createComponent('Mask');
38+
39+
export {
40+
Svg,
41+
Circle,
42+
Ellipse,
43+
G,
44+
Text,
45+
TextPath,
46+
TSpan,
47+
Path,
48+
Polygon,
49+
Polyline,
50+
Line,
51+
Rect,
52+
Use,
53+
Image,
54+
Symbol,
55+
Defs,
56+
LinearGradient,
57+
RadialGradient,
58+
Stop,
59+
ClipPath,
60+
Pattern,
61+
Mask,
62+
};
63+
64+
export default Svg;
File renamed without changes.

docs/usage.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ContentLoader, {
1515

1616
## Usage
1717

18-
## Different Type of Loaders
18+
## Presets
1919

2020
### Facebook Style Loader
2121

jest.native.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { defaults: tsjPreset } = require('ts-jest/presets')
2+
3+
module.exports = {
4+
...tsjPreset,
5+
preset: "react-native",
6+
collectCoverage: true,
7+
coverageDirectory: './coverage/native',
8+
"transformIgnorePatterns": [
9+
"/node_modules/(?!react-native|react-clone-referenced-element|react-navigation)"
10+
],
11+
transform: {
12+
...tsjPreset.transform,
13+
'^.+\\.js$': require.resolve('react-native/jest/preprocessor.js'),
14+
},
15+
testRegex: '/src/native/__tests__/.*(\\.|/)(test|spec)\\.[jt]sx?$',
16+
setupFiles: ['./__mocks__/jestSetupFile.js'],
17+
globals: {
18+
'ts-jest': {
19+
babelConfig: false,
20+
tsConfig: 'tsconfig.test.json',
21+
},
22+
},
23+
};

jest.web.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
verbose: true,
3+
collectCoverage: true,
4+
coverageDirectory: './coverage/',
5+
transform: {
6+
'^.+\\.(t|j)sx?$': 'ts-jest',
7+
},
8+
testRegex: '/src/__tests__/.*(\\.|/)(test|spec)\\.[jt]sx?$',
9+
roots: ['<rootDir>/src'],
10+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
11+
globals: {
12+
'ts-jest': {
13+
babelConfig: false,
14+
tsConfig: 'tsconfig.test.json',
15+
},
16+
},
17+
}

0 commit comments

Comments
 (0)