Skip to content
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

Change default theme from a const object to a function that returns the object #2483

Merged
4 commits merged into from
Jan 6, 2023

Conversation

lyzhan7
Copy link
Contributor

@lyzhan7 lyzhan7 commented Jan 4, 2023

Platforms Impacted

  • iOS
  • macOS
  • win32 (Office)
  • windows
  • android

Description of changes

Update the default theme fluent object to be a method that returns an object.

This issue is blocking #2481:

  • the updated designs for iOS tokens include some new tokens that aren't in the default theme
  • mapPipelineToTheme.ios.ts was updated to reflect these designs
  • however, the default theme is still getting created and is trying to running the iOS code for mapPipelineToTheme, which causes failures because the iOS alias token set now includes tokens that aren't in the default theme (win32) token set
  • changing the default theme from a const object to a method prevents the default theme from getting created automatically

Verification

No visual changes
Check if CI passes

Pull request checklist

This PR has considered (when applicable):

  • Automated Tests
  • Documentation and examples
  • Keyboard Accessibility
  • Voiceover
  • Internationalization and Right-to-left Layouts

@lyzhan7 lyzhan7 requested a review from a team as a code owner January 4, 2023 21:16
@lyzhan7
Copy link
Contributor Author

lyzhan7 commented Jan 4, 2023

Maybe to be done in a future PR - we could potentially combine all three defaultFluentTheme methods into one method that takes the appearance as an argument. This is what we do on iOS and I think android

@lyzhan7 lyzhan7 added the AutoMerge 🔁 Automatically merge when PR requirements met label Jan 5, 2023
@ghost
Copy link

ghost commented Jan 5, 2023

Hello @lyzhan7!

Because this pull request has the AutoMerge :repeat: label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 4 hours 21 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ankraj12
Copy link
Contributor

ankraj12 commented Jan 5, 2023

Just to understand, the issue you hit is the same as android integrations which failed due to android being a different alias color set. The changes proposed in #2190 should fix this for iOS. Are you planning to pick that as part of ongoing color work? In which case this PR could be redundant.

Copy link
Contributor

@ankraj12 ankraj12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the question over change

@lyzhan7
Copy link
Contributor Author

lyzhan7 commented Jan 5, 2023

Just to understand, the issue you hit is the same as android integrations which failed due to android being a different alias color set. The changes proposed in #2190 should fix this for iOS. Are you planning to pick that as part of ongoing color work? In which case this PR could be redundant.

I see, I didn't know Android hit the same issue. Yes I'm about to update my iOS color tokens PR to match what Android did - I can see how that would also get rid of the issue, but regardless I think this is still a good change to make, because right now we're automatically creating the default theme on iOS. I think updating the iOS color tokens PR to move getTokens into one shared place won't prevent the default theme from getting created at startup, it'll just make the default theme get its values from iOS (my understanding is that the default theme should get its value from windows tokens)

@lyzhan7 lyzhan7 mentioned this pull request Jan 5, 2023
10 tasks
@lyzhan7
Copy link
Contributor Author

lyzhan7 commented Jan 5, 2023

Just updated the iOS color tokens PR to move/rename apple-theme/getiOSTokens.ts -> theme-tokens/getTokens.ios.ts and ran into a separate but related issue - right now we're creating all three variants of the default theme (light mode, dark mode, and high contrast mode) when iOS boots, so after the rename/move we hit an error in getTokens.ios.ts that high contrast is not available on iOS. Android didn't run into this because it doesn't have this error handling. I don't think we should remove the error handling on the iOS side to get this unblocked, updating how the default theme is created still seems like the right change to make overall so right now this PR is still blocking the iOS color tokens PR.

@ankraj12
Copy link
Contributor

ankraj12 commented Jan 5, 2023

(my understanding is that the default theme should get its value from windows tokens)

Just to understand, the issue you hit is the same as android integrations which failed due to android being a different alias color set. The changes proposed in #2190 should fix this for iOS. Are you planning to pick that as part of ongoing color work? In which case this PR could be redundant.

I see, I didn't know Android hit the same issue. Yes I'm about to update my iOS color tokens PR to match what Android did - I can see how that would also get rid of the issue, but regardless I think this is still a good change to make, because right now we're automatically creating the default theme on iOS. I think updating the iOS color tokens PR to move getTokens into one shared place won't prevent the default theme from getting created at startup, it'll just make the default theme get its values from iOS (my understanding is that the default theme should get its value from windows tokens)

I didn't get a chance to re-review the code again, but if this changes what default-theme gets created to always create from windows, I believe this would be incorrect. My understanding is that default-theme should

Just to understand, the issue you hit is the same as android integrations which failed due to android being a different alias color set. The changes proposed in #2190 should fix this for iOS. Are you planning to pick that as part of ongoing color work? In which case this PR could be redundant.

I see, I didn't know Android hit the same issue. Yes I'm about to update my iOS color tokens PR to match what Android did - I can see how that would also get rid of the issue, but regardless I think this is still a good change to make, because right now we're automatically creating the default theme on iOS. I think updating the iOS color tokens PR to move getTokens into one shared place won't prevent the default theme from getting created at startup, it'll just make the default theme get its values from iOS (my understanding is that the default theme should get its value from windows tokens)

Sorry I didn't get chance to review this part fully again post your response, but if this PR change what's the default theme returned for an endpoint to "always" by widows tokens - I believe this is incorrect. My understanding is that default-theme should return the platform default theme set of color values. Could you re-check and confirm if this behaviour still works?

@ankraj12
Copy link
Contributor

ankraj12 commented Jan 5, 2023

Just updated the iOS color tokens PR to move/rename apple-theme/getiOSTokens.ts -> theme-tokens/getTokens.ios.ts and ran into a separate but related issue - right now we're creating all three variants of the default theme (light mode, dark mode, and high contrast mode) when iOS boots, so after the rename/move we hit an error in getTokens.ios.ts that high contrast is not available on iOS. Android didn't run into this because it doesn't have this error handling. I don't think we should remove the error handling on the iOS side to get this unblocked, updating how the default theme is created still seems like the right change to make overall so right now this PR is still blocking the iOS color tokens PR.

got that! my only concern would remain if what's the default theme returning for android post this change per other comment.

@lyzhan7
Copy link
Contributor Author

lyzhan7 commented Jan 6, 2023

Asked about whether the default-theme should always be using windows tokens or be using tokens depending on the platform offline and I misunderstood - it should be using the right tokens for the platform, not always windows tokens. I think this raises some other questions: currently the default theme creation code assumes that there is high contrast mode, and tries to get high contrast tokens from the pipeline - but on iOS/Android we don't have a high contrast mode. I've started a thread for this offline.

On Android we're just returning the light mode theme when we're trying to create the high contrast default theme, but on iOS we throw an error, which is why I still need this PR to unblock the iOS color token work. I could also make iOS return its light mode tokens when we try to access high contrast theme instead of throwing an error, that's another way to unblock the iOS color tokens PR, but I still think the right thing is to not be creating the default theme automatically on boot.

This PR does not make any changes to which platform tokens get returned for the default theme. The iOS color alias does change this though - currently on iOS the default theme is trying to access windows tokens. After my change, the default theme on iOS will be trying to access iOS tokens.

I don't have any planned iterations to make to this PR - please let me know if there was a change you were expecting

@rurikoaraki
Copy link
Collaborator

Asked about whether the default-theme should always be using windows tokens or be using tokens depending on the platform offline and I misunderstood - it should be using the right tokens for the platform, not always windows tokens. I think this raises some other questions: currently the default theme creation code assumes that there is high contrast mode, and tries to get high contrast tokens from the pipeline - but on iOS/Android we don't have a high contrast mode. I've started a thread for this offline.

On Android we're just returning the light mode theme when we're trying to create the high contrast default theme, but on iOS we throw an error, which is why I still need this PR to unblock the iOS color token work. I could also make iOS return its light mode tokens when we try to access high contrast theme instead of throwing an error, that's another way to unblock the iOS color tokens PR, but I still think the right thing is to not be creating the default theme automatically on boot.

This PR does not make any changes to which platform tokens get returned for the default theme. The iOS color alias does change this though - currently on iOS the default theme is trying to access windows tokens. After my change, the default theme on iOS will be trying to access iOS tokens.

I don't have any planned iterations to make to this PR - please let me know if there was a change you were expecting

I might have phrased this in an unclear way but, for clarification, currently the default theme is meant to always use web tokens.

I think that it could be changed to be platform specific in the future, but it does not work that way today and is not meant to work that way right now.

@ankraj12
Copy link
Contributor

ankraj12 commented Jan 6, 2023

Asked about whether the default-theme should always be using windows tokens or be using tokens depending on the platform offline and I misunderstood - it should be using the right tokens for the platform, not always windows tokens. I think this raises some other questions: currently the default theme creation code assumes that there is high contrast mode, and tries to get high contrast tokens from the pipeline - but on iOS/Android we don't have a high contrast mode. I've started a thread for this offline.

On Android we're just returning the light mode theme when we're trying to create the high contrast default theme, but on iOS we throw an error, which is why I still need this PR to unblock the iOS color token work. I could also make iOS return its light mode tokens when we try to access high contrast theme instead of throwing an error, that's another way to unblock the iOS color tokens PR, but I still think the right thing is to not be creating the default theme automatically on boot.

This PR does not make any changes to which platform tokens get returned for the default theme. The iOS color alias does change this though - currently on iOS the default theme is trying to access windows tokens. After my change, the default theme on iOS will be trying to access iOS tokens.

I don't have any planned iterations to make to this PR - please let me know if there was a change you were expecting

Thanks for checking on this. For Android on high contrast, I did not try fixing/debugging on the flow as it's not applicable. If you have a use case for iOS on it that you would like to handle differently, that sounds good.

@ghost ghost merged commit 984ee82 into microsoft:main Jan 6, 2023
@lyzhan7 lyzhan7 deleted the change-default-theme-to-function branch January 6, 2023 18:49
lyzhan7 added a commit to lyzhan7/fluentui-react-native that referenced this pull request Feb 2, 2023
lyzhan7 added a commit that referenced this pull request Feb 2, 2023
* Revert "Change default theme from a const object to a function that returns the object #2483"

* Change files
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge 🔁 Automatically merge when PR requirements met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants