fluentui-apple icon indicating copy to clipboard operation
fluentui-apple copied to clipboard

[Draft] Make `GlobalTokens` immutable

Open mischreiber opened this issue 3 years ago • 0 comments

Note: this PR is paused for a future release, but is open for feedback now

Platforms Impacted

  • [x] iOS
  • [ ] macOS

Description of changes

In order to align with the broader goals of Fluent UI design customization, this change makes all global tokens fully immutable. I've done so via the following:

  • GlobalTokens is now a struct composed of only pure static functions that return prebaked token values. It cannot be initialized (init is marked as unavailable).
  • brandColors, which can be customized, have been moved to AliasTokens.
  • FluentTheme, AliasTokens, and ControlTokens all lose their references to an instance of GlobalTokens and instead will refer to the static global values.
  • All components that pulled values from an instance of GlobalTokens have been updated to use the new static lookup APIs.

Verification

Sanity pass of all tokenized controls demonstrates no changes in appearance or behavior. Existing customization continues as expected.

Additionally, we've got a big binary size savings!

Before After
30,446,587 bytes (29,733 kB) 30,304,923 bytes (29,595 kB)

Improvement: 138 kB 🥳

Pull request checklist

This PR has considered:

  • [ ] Light and Dark appearances
  • [ ] iOS supported versions (all major versions greater than or equal current target deployment version)
  • [ ] VoiceOver and Keyboard Accessibility
  • [ ] Internationalization and Right to Left layouts
  • [ ] Different resolutions (1x, 2x, 3x)
  • [ ] Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • [ ] iPad Pointer interaction
  • [ ] SwiftUI consumption (validation or new demo scenarios needed)
  • [ ] Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

mischreiber avatar Aug 11 '22 20:08 mischreiber