Skip to content

Commit 5b5e024

Browse files
committed
Merge branch 'master' into release
2 parents 2e7ae8e + 07df924 commit 5b5e024

File tree

14 files changed

+421
-179
lines changed

14 files changed

+421
-179
lines changed

demo/src/screens/foundationScreens/ColorsScreen.js

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import {
1111
Icon,
1212
Button,
1313
TextField,
14-
Incubator
14+
Incubator,
15+
ColorPalette,
16+
ColorPickerDialog
1517
} from 'react-native-ui-lib';
18+
import {renderBooleanOption} from '../ExampleScreenPresenter';
1619

1720
const {Toast} = Incubator;
1821

@@ -42,7 +45,14 @@ class ColorsScreen extends Component {
4245
searchValue: '',
4346
filteredTokens: [],
4447
showToast: false,
45-
message: undefined
48+
message: undefined,
49+
currentColor: Colors.$textPrimary,
50+
showPicker: false,
51+
isDefaultOptions: false,
52+
adjustLightness: false,
53+
adjustSaturation: false,
54+
addDarkestTints: true,
55+
avoidReverseOnDark: true
4656
};
4757

4858
scrollViewRef = React.createRef();
@@ -281,13 +291,102 @@ class ColorsScreen extends Component {
281291
);
282292
}
283293

294+
/** Color Palette */
295+
296+
showColorPicker = () => {
297+
this.setState({showPicker: true});
298+
};
299+
300+
onValueChange = (color) => {
301+
this.setState({currentColor: color});
302+
};
303+
304+
onSubmit = (color) => {
305+
this.setState({currentColor: color});
306+
};
307+
308+
onDismiss = () => {
309+
this.setState({showPicker: false});
310+
};
311+
312+
setDefaultOptions = () => {
313+
const designKitsOptions = {adjustLightness: false, adjustSaturation: false, addDarkestTints: true, avoidReverseOnDark: true};
314+
const defaultOptions = {adjustLightness: true, adjustSaturation: true, addDarkestTints: false, avoidReverseOnDark: false};
315+
if (this.state.isDefaultOptions) {
316+
this.setState({...designKitsOptions, isDefaultOptions: false});
317+
} else {
318+
this.setState({...defaultOptions, isDefaultOptions: true});
319+
}
320+
};
321+
322+
renderColorPicker = () => {
323+
const {showPicker, currentColor} = this.state;
324+
return (
325+
<ColorPickerDialog
326+
visible={showPicker}
327+
initialColor={currentColor}
328+
key={currentColor}
329+
onDismiss={this.onDismiss}
330+
onSubmit={this.onSubmit}
331+
/>
332+
);
333+
};
334+
335+
renderOptions = () => {
336+
return (
337+
<View padding-20>
338+
{renderBooleanOption.call(this, 'adjustLightness', 'adjustLightness')}
339+
{renderBooleanOption.call(this, 'adjustSaturation', 'adjustSaturation')}
340+
{renderBooleanOption.call(this, 'addDarkestTints', 'addDarkestTints')}
341+
{renderBooleanOption.call(this, 'avoidReverseOnDark', 'avoidReverseOnDark')}
342+
<Button label={this.state.isDefaultOptions ? 'Reset example' : 'Set defaults'} onPress={this.setDefaultOptions}/>
343+
</View>
344+
);
345+
};
346+
347+
renderColorPalette = () => {
348+
const {currentColor, adjustLightness, adjustSaturation, addDarkestTints, avoidReverseOnDark} = this.state;
349+
const paletteOptions = {adjustLightness, adjustSaturation, addDarkestTints, avoidReverseOnDark};
350+
const palette = Colors.generateColorPalette(currentColor, paletteOptions);
351+
return (
352+
<View margin-12 br40 style={{borderWidth: 1}}>
353+
{this.renderOptions()}
354+
<View center row>
355+
<TouchableOpacity
356+
marginH-10
357+
style={[styles.colorBox, {backgroundColor: currentColor}]}
358+
onPress={this.showColorPicker}
359+
/>
360+
<ColorPalette
361+
colors={palette}
362+
value={currentColor}
363+
swatchStyle={styles.swatchStyle}
364+
containerStyle={{marginLeft: -10}}
365+
onValueChange={this.onValueChange}
366+
/>
367+
</View>
368+
</View>
369+
);
370+
};
371+
372+
renderColorPaletteExample = () => {
373+
return (
374+
<>
375+
<Text text50 marginL-20>Generate Color Palette</Text>
376+
{this.renderColorPalette()}
377+
{this.renderColorPicker()}
378+
</>
379+
);
380+
};
381+
284382
render() {
285383
return (
286384
<>
287385
{this.renderSearch()}
288386
<ScrollView ref={this.scrollViewRef}>
289387
{this.renderDesignTokens()}
290388
{this.renderColors(SYSTEM_COLORS, 'SYSTEM COLORS')}
389+
{this.renderColorPaletteExample()}
291390
</ScrollView>
292391
{this.renderToast()}
293392
</>
@@ -303,6 +402,19 @@ const styles = StyleSheet.create({
303402
searchField: {
304403
padding: Spacings.s3,
305404
borderRadius: 8
405+
},
406+
colorBox: {
407+
width: 60,
408+
height: 60,
409+
borderWidth: 1,
410+
borderRadius: 30
411+
},
412+
swatchStyle: {
413+
width: 18,
414+
height: 40,
415+
borderRadius: 10,
416+
marginLeft: 4,
417+
marginRight: 4
306418
}
307419
});
308420

scripts/prReleaseNotesCommon.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,21 @@ async function fetchMergedPRs(postMergedDate, repo, githubToken) {
4848
const relevantPRs = _.flow(prs => _.filter(prs, pr => !!pr.merged_at && new Date(pr.merged_at) > postMergedDate),
4949
prs => _.sortBy(prs, 'merged_at'),
5050
prs =>
51-
_.map(prs, pr => ({
52-
state: pr.state,
53-
merged_at: pr.merged_at,
54-
html_url: pr.html_url,
55-
branch: pr.head.ref,
56-
number: pr.number,
57-
title: pr.title,
58-
info: parsePR(pr.body)
59-
})))(PRs);
51+
_.map(prs, pr => {
52+
try {
53+
return {
54+
state: pr.state,
55+
merged_at: pr.merged_at,
56+
html_url: pr.html_url,
57+
branch: pr.head.ref,
58+
number: pr.number,
59+
title: pr.title,
60+
info: parsePR(pr.body)
61+
};
62+
} catch {
63+
console.error('Failed parsing PR: ', pr.html_url);
64+
}
65+
}))(PRs);
6066

6167
return relevantPRs;
6268
}
@@ -182,7 +188,13 @@ async function _generateReleaseNotes(latestVersion, newVersion, githubToken, fil
182188
console.log(`\x1b[1m\x1b[32m✔\x1b[0m \x1b[32m${fileNamePrefix}-release-notes.txt was successfully written to ${process.env.HOME}/Downloads\x1b[0m \x1b[1m\x1b[32m✔\x1b[0m`);
183189
}
184190

185-
async function generateReleaseNotes(latestVersion, newVersion, githubToken, fileNamePrefix, repo, header = '', tagPrefix = '') {
191+
async function generateReleaseNotes(latestVersion,
192+
newVersion,
193+
githubToken,
194+
fileNamePrefix,
195+
repo,
196+
header = '',
197+
tagPrefix = '') {
186198
let latestVer, newVer;
187199
const rl = readline.createInterface({
188200
input: process.stdin,

src/components/dash/index.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, {useState, useCallback, useMemo} from 'react';
22
import {StyleSheet, StyleProp, ViewProps, ViewStyle, LayoutChangeEvent} from 'react-native';
33
import View from '../view';
4-
import {Colors} from '../../style';
54

65
//TODO: move to some global types (shared with Timeline component)
76
export type Layout = {
@@ -35,11 +34,10 @@ const Dash = (props: DashProps) => {
3534
width: vertical ? thickness : length,
3635
height: vertical ? length : thickness,
3736
marginRight: vertical ? 0 : gap,
38-
marginBottom: vertical ? gap : 0,
39-
backgroundColor: color
37+
marginBottom: vertical ? gap : 0
4038
};
4139
return [style, _style];
42-
}, [vertical, length, thickness, gap, color, style]);
40+
}, [vertical, length, thickness, gap, style]);
4341

4442
const lineStyle = useMemo(() => {
4543
const directionStyle = vertical ? styles.column : styles.row;
@@ -56,7 +54,7 @@ const Dash = (props: DashProps) => {
5654
const dash = [];
5755

5856
for (let i = 0; i < n; i++) {
59-
dash.push(<View key={i} style={dashStyle}/>);
57+
dash.push(<View key={i} bg-$outlineDefault backgroundColor={color} style={dashStyle}/>);
6058
}
6159

6260
return dash;
@@ -73,8 +71,7 @@ export default Dash;
7371
Dash.defaultProps = {
7472
gap: 6,
7573
length: 6,
76-
thickness: 2,
77-
color: Colors.black
74+
thickness: 2
7875
};
7976

8077
const styles = StyleSheet.create({

src/components/dateTimePicker/dateTimePicker.api.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@
6161
"name": "themeVariant",
6262
"type": "LIGHT | DARK",
6363
"description": "Override system theme variant (dark or light mode) used by the date picker"
64+
},
65+
{
66+
"name": "display",
67+
"type": "string",
68+
"description": "Defines the visual display of the picker. The default value is 'spinner' on iOS and 'default' on Android. The list of all possible values are default, spinner, calendar or clock on Android and default, spinner, compact or inline for iOS. Full list can be found here: https://github.com/react-native-datetimepicker/datetimepicker#display-optional"
6469
}
6570
],
6671
"snippet": ["<DateTimePicker title={'Select time'$1} placeholder={'Placeholder'$2} mode={'time'$3}/>"]
67-
}
72+
}

src/components/dateTimePicker/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ export type DateTimePickerProps = OldApiProps & Omit<TextFieldProps, 'value' | '
9090
* The component testID
9191
*/
9292
testID?: string;
93+
/**
94+
* Allows changing the visual display of the picker
95+
*/
96+
display?: string;
9397
};
9498

9599
type DateTimePickerPropsInternal = DateTimePickerProps & BaseComponentInjectedProps;
@@ -126,6 +130,7 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
126130
dialogProps,
127131
headerStyle,
128132
testID,
133+
display = Constants.isIOS ? 'spinner' : undefined,
129134
...others
130135
} = props;
131136

@@ -255,7 +260,7 @@ const DateTimePicker = forwardRef((props: DateTimePickerPropsInternal, ref: Forw
255260
is24Hour={is24Hour}
256261
minuteInterval={minuteInterval}
257262
timeZoneOffsetInMinutes={timeZoneOffsetInMinutes}
258-
display={Constants.isIOS ? 'spinner' : undefined}
263+
display={display}
259264
themeVariant={themeVariant}
260265
testID={`${testID}.picker`}
261266
/>

src/components/slider/ColorSlider.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
3+
import Text from '../text';
4+
import GradientSlider, {GradientSliderTypes} from './GradientSlider';
5+
import {ColorSliderGroupProps} from './ColorSliderGroup';
6+
7+
type ColorSliderProps = Pick<
8+
ColorSliderGroupProps,
9+
'sliderContainerStyle' | 'showLabels' | 'labelsStyle' | 'accessible' | 'labels' | 'migrate' | 'initialColor'
10+
> & {
11+
type: GradientSliderTypes;
12+
};
13+
14+
const ColorSlider = (props: ColorSliderProps) => {
15+
const {
16+
labels = {hue: 'Hue', lightness: 'Lightness', saturation: 'Saturation', default: ''},
17+
type,
18+
sliderContainerStyle,
19+
showLabels,
20+
labelsStyle,
21+
accessible,
22+
migrate,
23+
initialColor
24+
} = props;
25+
return (
26+
<>
27+
{showLabels && labels && (
28+
<Text recorderTag={'unmask'} $textNeutral text80 style={labelsStyle} accessible={accessible}>
29+
{labels[type]}
30+
</Text>
31+
)}
32+
<GradientSlider
33+
color={initialColor}
34+
type={type}
35+
containerStyle={sliderContainerStyle}
36+
accessible={accessible}
37+
migrate={migrate}
38+
/>
39+
</>
40+
);
41+
};
42+
43+
export default ColorSlider;

0 commit comments

Comments
 (0)