Pickers: convert to CSS-in-JS Part 1#7353
Conversation
|
Have no idea what are those screener changes mean. It doesn't look like they changed how they look. |
|
But what is |
cliffkoh
left a comment
There was a problem hiding this comment.
As far as I can tell, looks great. I agree with your approach. Thanks for the thoughtfulness here.
Having a fallback to scss is, as far as I can tell, unfortunately necessary primarily for theming purposes if someone were indeed to extend the BasePicker.
Thanks for the very detailed documentation of your approach and for the comments.
|
Thank you @cliffkoh for reviewing. Would appreciate a little bit more of your time in hearing your thoughts regarding the number 5 in my list of changes and the questions under the Focus areas to test section of the description. |
|
@Vitalius1 I don't see any issue with number 5 :) It seems sound to me. |
There was a problem hiding this comment.
The majority of the code changes here seem sound, kudos to the thoroughness done here.
Regarding allowPhoneInitials it seems like it may be shared between Persona and Picker code, but I'm having difficulty following. Its my only hesitation to sign-off on this PR.
It might be worth involving the Persona folks to double check.
Otherwise I don't see any breaking API contract changes... Nice approach with maintaining backwards-compat with SCSS for the time-being.
Edit: Read thru the code locally and came to the conclusion that allowPhoneInitials is unused across Picker code.
|
🎉 Handy Links: |

Pull request checklist
$ npm run changeDescription of changes
This PR brings the first part of the pickers' conversion to use CSS-in-JS. Things that were done in this part:
Add
BasePicker.styles.tsto provide CSS-in-JS styling for the already existing pickers (TagPicker, PeoplePicker) and still leave support for Sass styles for custom pickers implemented by extending fromBasePickerclass without injecting the default styles.Added comments on explaining why the above is needed.
Add
stylesandthemeoptional props toIBasePickerPropsinterface.Changed tests in
BasePicker.test.tsto use correctly a public method on the component instance by accessing itscomponentRef(this surfaced after wrapping the pickers with thestyledfunction and the linter giving me red lines).Removing this parameter in the
PeoplePicker'screateGenericItemdefault prop added by Initials for phone numbers #4376https://github.com/OfficeDev/office-ui-fabric-react/blob/31783e67b172c645d15e169b54c84e8bfed5d6ca/packages/office-ui-fabric-react/src/components/pickers/PeoplePicker/PeoplePicker.tsx#L64
It was never actually working and for some reason, this was not caught by types because this prop is only allowing to pass 2 arguments:
https://github.com/OfficeDev/office-ui-fabric-react/blob/31783e67b172c645d15e169b54c84e8bfed5d6ca/packages/office-ui-fabric-react/src/components/pickers/BasePicker.types.ts#L120
... and later is called only with those 2 arguments in here:
https://github.com/OfficeDev/office-ui-fabric-react/blob/31783e67b172c645d15e169b54c84e8bfed5d6ca/packages/office-ui-fabric-react/src/components/pickers/BasePicker.tsx#L795
After wrapping the Base classes with the
styledfunction I started to get type errors. So I discussed it with @joschect and I consider it's safe to be removed. If later this functionality needs to be added (it was never actually working in the first place) this should be done in a separate PR with more changes than the initial mentioned PR introduced. @cliffkoh would appreciate your input with this surface API change as this function was exported even though it's just a default prop provided byPeoplePicker. Even if someone did import to use it I don't see a way to pass that argument in it.A little cleanup of the TagPicker example by moving a state interface into the same file as the example for user visibility and some more type fixes. Plus fixing the same issue as in tests file with the improper use of the public method of the component instance. This was causing the linter to complain that property
itemsdoes not exist onTagPicker. Changing it toTagPickerBasewas solving the errors but user should not care about the Base and use thecomponentRefprop instead.Updated the API file and snapshots to reflect the current changes
Part 2 PR will consist of converting the picker items (Tags, Personas).
Focus areas to test
Need some feedback on moving the string classNames from being always on the component elements to the styles file, where in case globalClassNames are disabled in the Theme, might break some already existing custom Sass overrides in consumers apps. Should I skip the step of
getGlobalClassNames(GlobalClassNames, theme)?Also, regarding the number 6 in my list above, because we had this example displayed for a long time for users to see, now that accessing those methods is not working that way, we might get into breaking someone's app with this change in case they used this example. Should we still go with this change?
Microsoft Reviewers: Open in CodeFlow