Skip to content

Commit 2f2b17c

Browse files
committed
Merge branch 'master' into feat/incubator-dialog-fixes-and-improvements
2 parents 654249b + d080195 commit 2f2b17c

File tree

24 files changed

+236
-85
lines changed

24 files changed

+236
-85
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ buck-out/
4343
\.buckd/
4444
*.keystore
4545

46+
lib/
47+
.vscode
48+
4649
# fastlane
4750
#
4851
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the

docs/foundation/modifiers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ The last type of modifiers is for styling your components
112112
```
113113

114114

115-
! all styling modifiers are based on our [`Colors` & `Typography` presets](/react-native-ui-lib/foundation/style).
115+
! all styling modifiers are based on our [`Colors` & `Typography` presets](/docs/foundation/style).
116116
You can load your own presets and use them as modifiers.
117117

118118

119119

120-
Check out [this example](/react-native-ui-lib/getting-started/usage) where we use most of these props.
120+
Check out [this example](/docs/getting-started/usage) where we use most of these props.

docs/getting-started/setup.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import {KeyboardTrackingView, KeyboardAwareInsetsView, KeyboardRegistry, Keyboar
2424

2525
## Install UILib
2626

27-
First, run `npm install react-native-ui-lib`
27+
- Run `npm install react-native-ui-lib`
28+
- Install mandatory [peer dependencies](#peer-dependencies), `npm i react-native-reanimated react-native-gesture-handler`
29+
- Install ios pods, `cd ios && pod install`
2830

2931
If you plan on using specific components, see **UILib Packages** above.
3032
*For some packages you might still need to install one of the peer dependencies*
@@ -62,10 +64,9 @@ Some of the components are using the native dependencies listed below - those ar
6264

6365
## Demo App
6466

65-
Our demo app is located [here](https://github.com/wix/react-native-ui-lib/tree/master/demo). To run it:
66-
67-
- Clone the repo
68-
- Install dependencies: `npm install`
69-
- (for iOS) `cd ios && pod install && cd ..`
70-
- Start the packager: `npm start`
71-
- Build the app: `npm run ios` or `npm run android` (or from Xcode or Android Studio).
67+
- Clone the project `git clone [email protected]:wix/react-native-ui-lib.git`
68+
- `cd react-native-ui-lib`
69+
- Install dependencies `npm install`
70+
- (for iOS) `cd ios && pod install`
71+
- Start the packager `npm start`
72+
- Build the app `npm run ios` or `npm run android` (or from Xcode or Android Studio).

docuilib/docusaurus.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula');
77
module.exports = {
88
title: 'RNUILib',
99
tagline: 'React Native UI Lib',
10-
url: 'https://github.com/wix/react-native-ui-lib',
11-
baseUrl: '/',
10+
url: 'https://wix.github.io',
11+
baseUrl: '/react-native-ui-lib/',
1212
onBrokenLinks: 'throw',
1313
onBrokenMarkdownLinks: 'warn',
1414
favicon: 'img/favicon.ico',
1515
organizationName: 'wix', // Usually your GitHub org/user name.
1616
projectName: 'react-native-ui-lib', // Usually your repo name.
17+
trailingSlash: false,
1718
customFields: {
1819
expoSnackLink: 'https://snack.expo.io/@ethanshar/rnuilib_snack?platform=ios&supportedPlatforms=ios,android',
19-
stars: '3.8'
20+
stars: '3.9'
2021
},
2122
plugins: ['docusaurus-plugin-sass'],
2223
presets: [

docuilib/src/components/ComponentsSection.module.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
flex-direction: column;
77
align-items: center;
88
width: 100%;
9-
9+
padding-left: 40px;
10+
padding-right: 40px;
11+
1012
.componentsInner {
1113
text-align: center;
1214
display: flex;
1315
flex-direction: column;
1416
align-items: center;
1517
width: 100%;
18+
padding: 0;
1619

1720
p {
1821
@include desktop {

docuilib/src/components/FeatureSection.module.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
padding-bottom: 100px;
88
width: 100%;
99
text-align: center;
10+
padding-left: 40px;
11+
padding-right: 40px;
1012

1113
.cards {
1214
display: flex;

docuilib/src/components/MainSection.module.scss

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
.main {
44
position: relative;
5-
height: 75vh;
65
width: 100%;
76
display: flex;
87
justify-content: center;
8+
margin-bottom: 40px;
99

1010
@include desktop {
1111
height: 100vh;
@@ -22,16 +22,16 @@
2222
}
2323

2424
.mainContent {
25-
position: absolute;
2625
z-index: 1;
2726
display: flex;
2827
flex-direction: column;
2928
align-items: flex-start;
3029
top: 15vh;
3130
text-align: center;
32-
padding: 0 40px;
31+
padding: 40px;
3332

3433
@include desktop() {
34+
position: absolute;
3535
padding: 0;
3636
top: 15vw;
3737
left: 7vw;
@@ -40,9 +40,15 @@
4040
}
4141

4242
> p {
43-
font-size: 3em;
43+
font-size: 2.5em;
4444
font-weight: 600;
4545
margin: 0;
46+
line-height: 1.2;
47+
48+
@include desktop {
49+
font-size: 3em;
50+
line-height: 1.5;
51+
}
4652

4753
> .libName {
4854
color: $primary;
@@ -55,8 +61,10 @@
5561
border: 1px solid;
5662
border-radius: 2px;
5763
align-self: center;
58-
64+
margin-top: 20px;
65+
5966
@include desktop {
67+
margin-top: 0;
6068
align-self: flex-start;
6169
}
6270

docuilib/src/components/MainSection.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import GoldStarSvg from '@site/static/img/goldStar.svg';
88

99
export default () => {
1010
const {siteConfig} = useDocusaurusContext();
11-
console.warn('ethan - siteConfig', siteConfig.customFields.stars)
1211

1312
return (
1413
<div className={styles.main}>

generatedTypes/src/components/carousel/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ declare class Carousel extends Component<CarouselProps, CarouselState> {
4646
stopAutoPlay(): void;
4747
resetAutoPlay(): void;
4848
goToPage(pageIndex: number, animated?: boolean): void;
49+
goToNextPage(): void;
4950
getCalcIndex(index: number): number;
5051
getSnapToOffsets: () => number[] | undefined;
5152
shouldUsePageWidth(): number | false | undefined;
5253
shouldEnablePagination(): boolean | undefined;
53-
onContainerLayout: ({ nativeEvent: { layout: { width: containerWidth, height: containerHeight } } }: LayoutChangeEvent) => void;
5454
shouldAllowAccessibilityLayout(): boolean | undefined;
5555
onContentSizeChange: () => void;
56+
onContainerLayout: ({ nativeEvent: { layout: { width: containerWidth, height: containerHeight } } }: LayoutChangeEvent) => void;
5657
onMomentumScrollEnd: () => void;
57-
goToNextPage(): void;
5858
onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
5959
onScrollEvent: (...args: any[]) => void;
6060
renderChild: (child: ReactNode, key: Key) => JSX.Element | undefined;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from '@testing-library/react-native';
22
import { findStyle } from './helper';
3-
export { findStyle };
3+
import { fireOnMomentumScrollEnd, fireOnScroll } from './scrollViewHelper';
4+
export { findStyle, fireOnMomentumScrollEnd, fireOnScroll };
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
declare const fireOnMomentumScrollEnd: (component: any, { x, y }: {
2+
x?: number | undefined;
3+
y?: number | undefined;
4+
}) => void;
5+
declare const fireOnScroll: (component: any, { x, y }: {
6+
x?: number | undefined;
7+
y?: number | undefined;
8+
}) => void;
9+
export { fireOnMomentumScrollEnd, fireOnScroll };

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"docs:deploy": "(cd ./uilib-docs && gatsby build --prefix-paths && gh-pages -d public --branch gh-pages)",
3939
"docs:build": "(cd ./uilib-docs && npm install && gatsby build --prefix-paths && gh-pages -d public --branch gh-pages)",
4040
"docs:develop": "(cd ./uilib-docs && gatsby develop)",
41+
"build:docs": "node scripts/build-docs.js",
4142
"bump:patch": "npm version patch",
4243
"demo": "./scripts/demo.sh",
4344
"release": "node ./scripts/release.js",

scripts/build-docs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ components.forEach(component => {
4747
if (component.extendsLink) {
4848
extendsText = `[${extendsText}](${component.extendsLink})`;
4949
} else {
50-
extendsText = `[${extendsText}](${extendsText})`;
50+
const extendedComponentName = _.last(_.split(extendsText, '/')); // Incubator/TextField -> TextField
51+
extendsText = `[${extendedComponentName}](/docs/components/${extendsText})`;
5152
}
5253
content += `:::info\n`;
5354
content += `This component extends **${extendsText}** props.\n`;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import {map} from 'lodash';
2+
import React from 'react';
3+
import {render} from '@testing-library/react-native';
4+
import {Text, View} from 'react-native';
5+
import {fireOnScroll, fireOnMomentumScrollEnd} from '../../../uilib-test-renderer';
6+
import {Constants} from '../../../helpers';
7+
import Carousel from '../index';
8+
9+
const numberOfPagesShown = 5;
10+
const onChangePageMock = jest.fn();
11+
const onScrollMock = jest.fn();
12+
13+
const TestCase = props => {
14+
return (
15+
<Carousel
16+
testID={'carousel'}
17+
onChangePage={onChangePageMock}
18+
onScroll={onScrollMock}
19+
{...props}
20+
>
21+
{map([...Array(numberOfPagesShown)], (_, index) => (
22+
<Page key={index}>
23+
<Text testID={`page-${index}`}>Page #{index}</Text>
24+
</Page>
25+
))}
26+
</Carousel>
27+
);
28+
};
29+
30+
const Page = ({children, ...others}) => {
31+
return (
32+
<View {...others} style={{flex: 1}}>
33+
{children}
34+
</View>
35+
);
36+
};
37+
38+
describe('Carousel render tests', () => {
39+
40+
describe('initialPage', () => {
41+
it('should be set to default initialPage', () => {
42+
const {getByTestId} = render(<TestCase/>);
43+
const scrollView = getByTestId('carousel');
44+
45+
expect(scrollView.props.contentOffset.x).toBe(0);
46+
});
47+
48+
it('should be set to initialPage = 2', () => {
49+
const {getByTestId} = render(<TestCase initialPage={2}/>);
50+
const scrollView = getByTestId('carousel');
51+
52+
expect(scrollView.props.contentOffset.x).toBe(Constants.screenWidth * 2);
53+
});
54+
});
55+
56+
describe('onScroll', () => {
57+
it('should trigger onScroll from the second scroll', () => {
58+
const {getByTestId} = render(<TestCase/>);
59+
const scrollView = getByTestId('carousel');
60+
61+
fireOnScroll(scrollView, {x: Constants.screenWidth}); //NOTE: first scroll doesn't fire onScroll
62+
expect(onScrollMock).not.toHaveBeenCalled();
63+
64+
fireOnScroll(scrollView, {x: Constants.screenWidth});
65+
expect(onScrollMock).toHaveBeenCalled();
66+
});
67+
});
68+
69+
describe('onChangePage', () => {
70+
it('should trigger onChangePage with current page', async () => {
71+
const {getByTestId} = render(<TestCase/>);
72+
const scrollView = getByTestId('carousel');
73+
74+
fireOnScroll(scrollView, {x: Constants.screenWidth}); //NOTE: first scroll doesn't fire onScroll
75+
fireOnScroll(scrollView, {x: Constants.screenWidth});
76+
expect(onChangePageMock).not.toHaveBeenCalled();
77+
78+
// await new Promise(r => setTimeout(r, 1000));
79+
fireOnMomentumScrollEnd(scrollView, {x: Constants.screenWidth});
80+
expect(onChangePageMock).toHaveBeenCalledWith(1, 0, {isAutoScrolled: false});
81+
});
82+
});
83+
});

0 commit comments

Comments
 (0)