react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[JS] Add support for CSS4 color() functions

Open ryanlntn opened this issue 2 years ago • 5 comments

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:

Screenshot_20240131-100112

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>
+      </>
     );
   },
 },

ryanlntn avatar Feb 03 '24 03:02 ryanlntn

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

analysis-bot avatar Feb 03 '24 03:02 analysis-bot

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Feb 03 '24 10:02 facebook-github-bot

/rebase

cortinico avatar Mar 13 '24 10:03 cortinico

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Mar 15 '24 11:03 facebook-github-bot