forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ColorWithSystemEffectMacOS API to react-native-macos #751
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
harrieshin
reviewed
Mar 25, 2021
harrieshin
approved these changes
Apr 1, 2021
Saadnajmi
added a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Apr 4, 2021
* add pull yml * remove yml * Getting there.. * Closer.. * Remove commented out code * More simplification * remove typo * Make ColorWithSystemEffect it's own sub-object * It works! * Add examples of DynamicColorMacOS with a SystemEffect (currently broken) * Add None Effect too * Fix typo * Essentially feature complete * Rename API * Missed a file * Fix the bug where we call processColor too many times * Replace blah with the issue number * Change one more title * Stub out test on other platforms * Add ifdef macos check, some null checks, and fix up a bunch of the tags * Fix more of the tags * Fix lint errors * ifdef around colorWithEffect method
4 tasks
Saadnajmi
added a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Jun 1, 2021
* add pull yml * remove yml * Getting there.. * Closer.. * Remove commented out code * More simplification * remove typo * Make ColorWithSystemEffect it's own sub-object * It works! * Add examples of DynamicColorMacOS with a SystemEffect (currently broken) * Add None Effect too * Fix typo * Essentially feature complete * Rename API * Missed a file * Fix the bug where we call processColor too many times * Replace blah with the issue number * Change one more title * Stub out test on other platforms * Add ifdef macos check, some null checks, and fix up a bunch of the tags * Fix more of the tags * Fix lint errors * ifdef around colorWithEffect method
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please select one of the following
Summary
This PR addresses #750.
Starting from macOS 10.14, Apple introduced the API colorWithSystemEffect, which allows you to add system effects to colors like "pressed", "rollover" (mouse hover), and "disabled". This marks a change where Apple is telling us to use the System API to style our custom component's colors for various states, rather than coming up with the colors ourselves. Currently, this API is not accessible to react-native-macos, meaning our components won't look and feel right on the platform going forward.
Let's expose this API in a similar fashion to how we expose PlatformColor and DynamicColorMacOS. We do this by extending the
NativeColorValue
object to take in acolorWithSystemEffect
object with two keys:baseColor
(itself a ColorValue), andsystemEffect
(a string representing the system effect. The type of baseColor isColorValue
, meaning it can be a number, string, semantic color, or dynamic color. We also add the appropriate stubs so this API error out on other platforms (like DynamicColorMacOS). We then extend[RCTConvert UIColor:]
to handle the new case on the native side.Changelog
[macOS] [Added] - Added ColorWithSystemEffectMacOS API
Test Plan
I added a new section to the PlatformColor test in RNTester, and checked passing in strings, semantic colors, and dynamic colors to ColorWithSystemEffectMacOS and made sure they rendered correctly in light and dark mode
Microsoft Reviewers: Open in CodeFlow