[JS] Add support for CSS4 color() functions
Summary:
This adds support for color() function syntax per the W3C CSS Color Module Level 4 spec and the Add Support for Wide Gamut (DisplayP3) Colors to React Native RFC. When combined with #42830 it allows specifying colors in both sRGB and DisplayP3 color space on iOS. It does not yet support using color() function syntax in animations.
Changelog:
[GENERAL] [ADDED] - Add support for CSS4 color() functions
Test Plan:
Pull the changes from https://github.com/facebook/react-native/pull/42830
Update RNTester ViewExamples with colors using color function syntax.
{
title: 'Background Color',
name: 'background-color',
render(): React.Node {
return (
+ <>
<View
testID="view-test-background-color"
style={{backgroundColor: '#527FE4', padding: 5}}>
<Text style={{fontSize: 11}}>Blue background</Text>
</View>
+ <View
+ testID="view-test-background-color1"
+ style={{backgroundColor: 'red', borderColor: 'color(display-p3 1 0 0)', borderWidth: 15, padding: 5}}>
+ <Text style={{color: 'color(display-p3 1 0 0)', fontSize: 11}}>sRGB Red Background</Text>
+ </View>
+ <View
+ testID="view-test-background-color2"
+ style={{backgroundColor: 'color(display-p3 1 0 0)', borderColor: 'red', borderWidth: 15, padding: 5}}>
+ <Text style={{color: 'red', fontSize: 11}}>DisplayP3 Red background</Text>
+ </View>
+ </>
);
},
},
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| android | hermes | arm64-v8a | 17,234,648 | -2,895 |
| android | hermes | armeabi-v7a | n/a | -- |
| android | hermes | x86 | n/a | -- |
| android | hermes | x86_64 | n/a | -- |
| android | jsc | arm64-v8a | 20,600,909 | -3,384 |
| android | jsc | armeabi-v7a | n/a | -- |
| android | jsc | x86 | n/a | -- |
| android | jsc | x86_64 | n/a | -- |
Base commit: fbc090d070c2701c279214e88096672425272b3b Branch: main
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
/rebase
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.