Skip to content

Commit 7a890f4

Browse files
committed
Merge remote-tracking branch 'origin' into release
2 parents 6a20d87 + d95738e commit 7a890f4

File tree

27 files changed

+293
-129
lines changed

27 files changed

+293
-129
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ dist
6666
dist-ts
6767
package-lock.json
6868
docs/components/**
69+
scripts/token.js
6970

7071
# Ruby / CocoaPods
7172
/ios/Pods/

demo/src/screens/componentScreens/SegmentedControlScreen.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const segments: Record<string, Array<SegmentedControlItemProps>> = {
1818
fifth: [{label: 'Full'}, {label: 'Width'}],
1919
sixth: [{label: 'Full'}, {label: 'Width'}, {label: 'With'}, {label: 'A'}, {label: 'Very Long Segment'}],
2020
seventh: [{label: '$'}, {label: '%'}],
21-
eighth: [{label: 'Plus', iconSource: Assets.icons.plusSmall}, {label: 'Minus', iconSource: Assets.icons.minusSmall}, {label: 'Check', iconSource: Assets.icons.checkSmall}]
21+
eighth: [{label: 'Plus', iconSource: Assets.icons.plusSmall}, {label: 'Minus', iconSource: Assets.icons.minusSmall}, {label: 'Check', iconSource: Assets.icons.checkSmall}],
22+
ninth: [{label: 'with'}, {label: 'a'}, {label: 'label'}]
2223
};
2324

2425
const SegmentedControlScreen = () => {
@@ -87,6 +88,15 @@ const SegmentedControlScreen = () => {
8788
style={styles.customStyle}
8889
segmentsStyle={styles.customSegmentsStyle}
8990
/>
91+
<Text marginT-s4 center>
92+
With a label
93+
</Text>
94+
<SegmentedControl
95+
containerStyle={styles.container}
96+
segments={segments.ninth}
97+
preset={screenPreset}
98+
label="Control label"
99+
/>
90100
</View>
91101
</View>
92102
);

demo/src/screens/componentScreens/StackAggregatorScreen.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import React, {Component} from 'react';
33
import {ScrollView} from 'react-native';
44
import {Colors, View, Text, Button, StackAggregator} from 'react-native-ui-lib';
55

6-
76
const TEXTS = [
87
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
98
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
@@ -12,28 +11,28 @@ const TEXTS = [
1211
];
1312

1413
export default class StackAggregatorScreen extends Component {
15-
state = {
14+
state = {
1615
contents: TEXTS,
1716
collapsed: true
1817
};
1918

2019
onItemPress = (index: number) => {
2120
console.warn('item pressed: ', index);
22-
}
21+
};
2322

2423
onPress = (index: number) => {
2524
console.warn('item\'s button pressed: ', index);
26-
}
25+
};
2726

2827
refreshItems = () => {
2928
const newItems = _.clone(this.state.contents);
3029
newItems.push('New Item');
3130
this.setState({contents: newItems});
32-
}
31+
};
3332

3433
toggleCollapsed = () => {
3534
this.setState({collapsed: !this.state.collapsed});
36-
}
35+
};
3736

3837
renderItem = (_: string, index: number) => {
3938
return (
@@ -42,7 +41,7 @@ export default class StackAggregatorScreen extends Component {
4241
<Text>{this.state.contents[index]}</Text>
4342
</View>
4443
);
45-
}
44+
};
4645

4746
render() {
4847
const {collapsed} = this.state;
@@ -53,18 +52,18 @@ export default class StackAggregatorScreen extends Component {
5352
<Button link label={collapsed ? 'Open Stack' : 'Close Stack'} onPress={this.toggleCollapsed}/>
5453
<Button link label="Update content" onPress={this.refreshItems}/>
5554
</View>
56-
<Text center grey40 text90 marginT-20>Thu, 10 Dec, 11:29</Text>
57-
<StackAggregator
58-
containerStyle={{marginTop: 12}}
59-
onItemPress={this.onItemPress}
60-
collapsed={collapsed}
61-
>
55+
<Text center grey40 text90 marginT-20>
56+
Thu, 10 Dec, 11:29
57+
</Text>
58+
<StackAggregator containerStyle={{marginTop: 12}} onItemPress={this.onItemPress} collapsed={collapsed}>
6259
{_.map(this.state.contents, (item, index) => {
6360
return this.renderItem(item, index);
6461
})}
6562
</StackAggregator>
6663

67-
<Text center grey40 text90 marginT-20>Thu, 11 Dec, 13:03</Text>
64+
<Text center grey40 text90 marginT-20>
65+
Thu, 11 Dec, 13:03
66+
</Text>
6867
<StackAggregator
6968
containerStyle={{marginTop: 12}}
7069
onItemPress={this.onItemPress}

scripts/prReleaseNotes.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
const GITHUB_TOKEN = 'xxxx';
1+
const GITHUB_TOKEN = require('./token');
2+
// scripts/token.js:
3+
// const token = 'XXX';
4+
// module.exports = token;
5+
26
const LATEST_VERSION = '7.10.0';
37
const NEW_VERSION = '7.11.0';
48
const FILE_PREFIX = 'uilib';

src/assets/icons/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export const icons = {
1717
get x() {
1818
return require('./x.png');
1919
},
20+
get xMedium() {
21+
return require('./xMedium.png');
22+
},
2023
get xFlat() {
2124
return require('./xFlat.png');
2225
}

src/assets/icons/xMedium.png

218 Bytes
Loading

src/assets/icons/[email protected]

256 Bytes
Loading

src/assets/icons/[email protected]

290 Bytes
Loading

src/assets/icons/[email protected]

390 Bytes
Loading

src/assets/icons/[email protected]

483 Bytes
Loading

src/components/badge/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export type BadgeProps = ViewProps &
6565
/**
6666
* Additional styles for the badge label
6767
*/
68-
labelStyle?: TextStyle;
68+
labelStyle?: StyleProp<TextStyle>;
6969
/**
7070
* Receives a number from 1 to 4, representing the label's max digit length.
7171
* Beyond the max number for that digit length, a "+" will show at the end.

src/components/button/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class Button extends PureComponent<Props, ButtonState> {
227227
let outlineStyle;
228228
if ((outline || outlineColor) && !this.isLink) {
229229
outlineStyle = {
230-
borderWidth: outlineWidth || 1,
230+
borderWidth: outlineWidth ?? 1,
231231
borderColor: outlineColor || Colors.$outlinePrimary
232232
};
233233

src/components/colorSwatch/index.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {PureComponent} from 'react';
22
import {StyleSheet, Animated, Easing, LayoutChangeEvent, StyleProp, ViewStyle} from 'react-native';
33
import Assets from '../../assets';
44
import {BorderRadiuses, Colors} from '../../style';
5-
import {Constants} from '../../commons/new';
5+
import {asBaseComponent, BaseComponentInjectedProps, Constants, ColorsModifiers} from '../../commons/new';
66
import View from '../view';
77
import TouchableOpacity from '../touchableOpacity';
88
import Image from '../image';
@@ -50,7 +50,7 @@ interface Props {
5050
*/
5151
size?: number;
5252
}
53-
export type ColorSwatchProps = Props;
53+
export type ColorSwatchProps = Props & ColorsModifiers;
5454

5555
const transparentImage = require('./assets/transparentSwatch/TransparentSwatch.png');
5656
const DEFAULT_SIZE = Constants.isTablet ? 44 : 36;
@@ -62,7 +62,7 @@ export const SWATCH_SIZE = DEFAULT_SIZE;
6262
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/ColorPickerScreen.tsx
6363
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/ColorPalette/ColorPalette.gif?raw=true
6464
*/
65-
class ColorSwatch extends PureComponent<Props> {
65+
class ColorSwatch extends PureComponent<Props & BaseComponentInjectedProps> {
6666
static displayName = 'ColorSwatch';
6767

6868
state = {
@@ -71,7 +71,7 @@ class ColorSwatch extends PureComponent<Props> {
7171
animatedScale: new Animated.Value(0.5)
7272
};
7373

74-
styles = createStyles(this.props);
74+
styles = createStyles({...this.props, color: this.color});
7575
layout = {x: 0, y: 0};
7676

7777
componentDidMount() {
@@ -85,6 +85,11 @@ class ColorSwatch extends PureComponent<Props> {
8585
}
8686
}
8787

88+
get color() {
89+
const {color, modifiers} = this.props;
90+
return color || modifiers?.color;
91+
}
92+
8893
animateSwatch(newValue: number) {
8994
const {animatedOpacity, animatedScale} = this.state;
9095

@@ -118,7 +123,8 @@ class ColorSwatch extends PureComponent<Props> {
118123
}
119124

120125
onPress = () => {
121-
const {color = '', value, index} = this.props;
126+
const {value, index} = this.props;
127+
const color = this.color ?? '';
122128
const tintColor = this.getTintColor(value);
123129
const result = value || color;
124130
const hexString = Colors.getHexString(result);
@@ -135,7 +141,7 @@ class ColorSwatch extends PureComponent<Props> {
135141
}
136142

137143
getAccessibilityInfo() {
138-
const {color} = this.props;
144+
const color = this.color;
139145

140146
return {
141147
accessibilityLabel: color && Colors.getColorName(color),
@@ -152,7 +158,8 @@ class ColorSwatch extends PureComponent<Props> {
152158
};
153159

154160
renderContent() {
155-
const {style, color, onPress, unavailable, size = DEFAULT_SIZE, ...others} = this.props;
161+
const {style, onPress, unavailable, size = DEFAULT_SIZE, ...others} = this.props;
162+
const color = this.color;
156163
const {isSelected} = this.state;
157164
const Container = onPress ? TouchableOpacity : View;
158165
const tintColor = this.getTintColor(color);
@@ -213,7 +220,7 @@ class ColorSwatch extends PureComponent<Props> {
213220
}
214221
}
215222

216-
export default ColorSwatch;
223+
export default asBaseComponent<ColorSwatchProps>(ColorSwatch);
217224

218225
function createStyles({color = Colors.grey30}) {
219226
return StyleSheet.create({

src/components/hint/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ class Hint extends Component<HintProps, HintState> {
534534
}
535535

536536
renderMockChildren() {
537-
const {children} = this.props;
537+
const {children, backdropColor} = this.props;
538+
const isBackdropColorPassed = backdropColor !== undefined;
538539
if (children && React.isValidElement(children)) {
539540
const layout = {
540541
...this.getContainerPosition(),
@@ -545,7 +546,7 @@ class Hint extends Component<HintProps, HintState> {
545546
};
546547

547548
return (
548-
<View style={[styles.mockChildrenContainer, layout]}>
549+
<View style={[styles.mockChildrenContainer, layout, !isBackdropColorPassed && styles.hidden]}>
549550
{React.cloneElement<any>(children, {
550551
collapsable: false,
551552
key: 'mock',
@@ -609,6 +610,7 @@ const styles = StyleSheet.create({
609610
container: {
610611
position: 'absolute'
611612
},
613+
hidden: {opacity: 0},
612614
overlayContainer: {
613615
zIndex: 10,
614616
elevation: 10

src/components/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ export default {
134134
get ProgressBar() {
135135
return require('./progressBar').default;
136136
},
137+
get ProgressiveImage() {
138+
return require('./progressiveImage').default;
139+
},
137140
get StateScreen() {
138141
return require('./stateScreen').default;
139142
},

src/components/picker/PickerItemsList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const PickerItemsList = (props: PickerItemsListProps) => {
3636
} = props;
3737
const context = useContext(PickerContext);
3838

39-
const [wheelPickerValue, setWheelPickerValue] = useState<PickerSingleValue>(context.value ?? items?.[0].value);
39+
const [wheelPickerValue, setWheelPickerValue] = useState<PickerSingleValue>(context.value ?? items?.[0]?.value);
4040
// TODO: Might not need this memoized style, instead we can move it to a stylesheet
4141
const wrapperContainerStyle = useMemo(() => {
4242
// const shouldFlex = Constants.isWeb ? 1 : useDialog ? 1 : 1;
Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types';
32
import {View, StyleSheet, Animated} from 'react-native';
4-
import AnimatedImage from '../animatedImage';
3+
import AnimatedImage, {AnimatedImageProps} from '../animatedImage';
54
import {Colors} from '../../style';
65

76
/**
8-
* @description: Image component that loads first a small thumbnail of the images,
7+
* @description: Image component that loads first a small thumbnail of the images,
98
* and fades-in the full-sized image with animation once it's loaded
109
* @extends: AnimatedImage
1110
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/ProgressiveImageScreen.js
1211
*/
13-
class ProgressiveImage extends React.Component {
12+
13+
export type ProgressiveImageProps = {
14+
/**
15+
* small thumbnail source to display while the full-size image is loading
16+
*/
17+
thumbnailSource: AnimatedImageProps['source'];
18+
};
19+
20+
class ProgressiveImage extends React.Component<ProgressiveImageProps, {}> {
1421
static displayName = 'ProgressiveImage';
15-
static propTypes = {
16-
/**
17-
* small thumbnail source to display while the full-size image is loading
18-
*/
19-
thumbnailSource: PropTypes.object
20-
};
2122

2223
thumbnailAnimated = new Animated.Value(0);
2324
imageAnimated = new Animated.Value(0);
2425

2526
getThumbnail = () => {
2627
const {thumbnailSource, ...props} = this.props;
2728

28-
return (
29-
<AnimatedImage
30-
{...props}
31-
source={thumbnailSource}
32-
loader={<View style={styles.container}/>}
33-
/>
34-
);
29+
return <AnimatedImage {...props} source={thumbnailSource} loader={<View style={styles.container}/>}/>;
3530
};
3631

37-
render() {
38-
return (
39-
<AnimatedImage
40-
{...this.props}
41-
loader={this.getThumbnail()}
42-
/>
43-
);
32+
render() {
33+
//@ts-ignore
34+
return <AnimatedImage {...this.props} loader={this.getThumbnail()}/>;
4435
}
4536
}
4637

@@ -50,5 +41,4 @@ const styles = StyleSheet.create({
5041
}
5142
});
5243

53-
5444
export default ProgressiveImage;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import {render} from '@testing-library/react-native';
3+
import SegmentedControl, {type SegmentedControlProps} from '../index';
4+
5+
const testSegmentes = [{label: 'Segmented 1'}, {label: 'Segmented 2'}, {label: 'Segmented 3'}, {label: 'Segmented 4'}];
6+
7+
const TestCase = (props: Partial<SegmentedControlProps>) => {
8+
return <SegmentedControl segments={testSegmentes} {...props}/>;
9+
};
10+
11+
describe('SegmentedControl', () => {
12+
it('should render', () => {
13+
const renderTree = render(<TestCase/>);
14+
expect(renderTree).toBeTruthy();
15+
});
16+
it('should render with a label', () => {
17+
const renderTree = render(<TestCase label="Test Label"/>);
18+
expect(renderTree.queryByText('Test Label')).toBeTruthy();
19+
});
20+
});

0 commit comments

Comments
 (0)