Skip to content

Pickers: convert to CSS-in-JS Part 2.3(final) - Suggestions#7452

Merged
Vitalius1 merged 19 commits into
microsoft:masterfrom
Vitalius1:v-vibr/SuggestionsConversion
Jan 10, 2019
Merged

Pickers: convert to CSS-in-JS Part 2.3(final) - Suggestions#7452
Vitalius1 merged 19 commits into
microsoft:masterfrom
Vitalius1:v-vibr/SuggestionsConversion

Conversation

@Vitalius1

@Vitalius1 Vitalius1 commented Dec 20, 2018

Copy link
Copy Markdown
Contributor

Pull request checklist

Description of changes

This PR is the last in the series of converting pickers to use CSS-in-JS. as in the previous PRs, I moved again 🙄 some stuff around and of course, I, again 🙄 couldn't stop myself for a little bit of clean up and TSDocs addition. Changes made in this PR:

  1. Moved some interfaces in their appropriate files and made sure they are still exported to the public API. Added a bunch of documentation to them so feel free to comment on any grammar mistakes.
  2. The biggest change and probably somewhat controversial is renaming some components. Before jumping and blasting me with request changes PR blockers 😠 , let me first make my case and hopefully my analysis is not wrong. The components renamed are the ones I needed to convert to CSS-in-JS (Suggestions and SuggestionsItem). These are some generic components that expect a type argument in order for them to be used and preserve some type safety.
    https://github.com/OfficeDev/office-ui-fabric-react/blob/f2922d6242b952e8d76dea1a9a6d056c5f58f843/packages/office-ui-fabric-react/src/components/pickers/Suggestions/Suggestions.tsx#L54
    https://github.com/OfficeDev/office-ui-fabric-react/blob/f2922d6242b952e8d76dea1a9a6d056c5f58f843/packages/office-ui-fabric-react/src/components/pickers/BasePicker.tsx#L59
    In order to pass that T to them, I had to make sure we can pass it to the styled function all the way to that components props type. So my implementation of this dilemma was to create a function which required a type parameter when invoked and returned a functional component from the styled HOC. To use each component now you have to do something like const StyledTypedComponent = styledComponent<T>();. Because these components are not intended to be used as standalone components and in fact be used only internally with anything which extends BasePicker and then passing from it the T to -> Suggestions -> SuggestionsItem.
    Alternatives to that would mean to keep the old implementation along with its SCSS files, plus my changes that would bring lots of code duplication and confusion (and probably bundle size increase).

    There is always a chance that someone used these subComponents separately as FloatingPicker did in its SuggestionsCore, but that would require to build your entire picker from scratch (which FloatingPicker kinda does by 🤧 copy/pasting lots of stuff from BasePicker)
    https://github.com/OfficeDev/office-ui-fabric-react/blob/f2922d6242b952e8d76dea1a9a6d056c5f58f843/packages/office-ui-fabric-react/src/components/FloatingPicker/Suggestions/SuggestionsCore.tsx#L3
    ..., so I kinda feel not sure about this change and that is why I expect some feedback and maybe ideas on how to better do it for this scenario. I am very open to changes 😄 .

EDIT:

Had another look and decided not to risk with a breaking change and leave everything as is and just add support for both styling approaches. In case someone used these components individually and outside the context of BasePicker, then he can still have .scss styles applied. On the other side when someone is just using a picker which extends from BasePicker without changing any of its internal subComponents, then the CSS-in-JS styles will be applied. To preserve the T passed all the way to down to these subComponents I wrap them with styled right before render and due to them being intended for internal use only, for now, I am not exporting these JS styled versions to the public API. Left some comments and hope when a rewrite of the pickers will be performed all these workarounds can be cleaned up.
3. Cleaned up some example pages and removed unused .scss files for them.

P.S. 2960 lines of these changes are just a snapshot I added. So everyone is welcome for reviews. Don't hit the back button 😄

screen shot 2018-12-21 at 12 39 25 pm

Microsoft Reviewers: Open in CodeFlow

@size-auditor

size-auditor Bot commented Dec 21, 2018

Copy link
Copy Markdown
Component Baseline Size PR Size Size Change Bundle Size Tolerance Level
Pickers 309259 314518 5259 🔺
FloatingPicker 334431 339690 5259 🔺
Panel 231726 231730 4 🔺 ✔️
SearchBox 220654 220658 4 🔺 ✔️
Dialog 234332 234336 4 🔺 ✔️
DetailsList 251919 251923 4 🔺 ✔️
Pivot 223191 223195 4 🔺 ✔️
DocumentCard 263625 263629 4 🔺 ✔️
Nav 223982 223986 4 🔺 ✔️
CommandBar 235506 235510 4 🔺 ✔️
ComboBox 273566 273570 4 🔺 ✔️
Dropdown 260988 260992 4 🔺 ✔️
MessageBar 223683 223687 4 🔺 ✔️
SelectedItemsList 273338 273342 4 🔺 ✔️
Facepile 250886 250890 4 🔺 ✔️
ShimmeredDetailsList 266827 266831 4 🔺 ✔️
SpinButton 227953 227957 4 🔺 ✔️
Grid 217743 217747 4 🔺 ✔️
SwatchColorPicker 232689 232693 4 🔺 ✔️
TeachingBubble 225533 225537 4 🔺 ✔️
Breadcrumb 235212 235216 4 🔺 ✔️
Keytip 184862 184865 3 🔺 ✔️
PersonaCoin 151991 151994 3 🔺 ✔️
GroupedList 176132 176135 3 🔺 ✔️

@Vitalius1

Vitalius1 commented Dec 21, 2018

Copy link
Copy Markdown
Contributor Author

@aftab-hassan can't wait to have the ability to click and see what files are causing this blocker...
If not taking the snapshot, the API and the changelog files into consideration I added to the bundle only 444 lines of code... I am assuming these additions can cause a 5is KB ❓

@Vitalius1

Copy link
Copy Markdown
Contributor Author

@joschect 🙄 feel free to review this last PR for converting the Suggestions any time. Will address the feedback when back from vacation.

Comment thread packages/office-ui-fabric-react/src/components/pickers/BasePicker.tsx Outdated
@Vitalius1
Vitalius1 merged commit d3baf56 into microsoft:master Jan 10, 2019
@msft-github-bot

Copy link
Copy Markdown
Contributor

🎉office-ui-fabric-react@v6.124.0 has been released which incorporates this pull request.:tada:

Handy links:

evlevy pushed a commit to evlevy/office-ui-fabric-react that referenced this pull request Jan 11, 2019
…t#7452)

* Suggestion start conversion

* Adjust hover state

* Font size to iconButton through styles

* Fix import in test file

* Suggestions conversion almost done

* More changes

* Fix tests, imports and renaming stuff

* Rush change log

* Remove scss file

* Remove unnecessary scss file and exported const from example page

* Bring back support for scss styles

* Add snapshot test for CSS-in-JS styles

* Add some comments for future reference

* Bring back SCSS styles support for SuggestionsItems

* Update documentation and add comments

* Rename back some protected members of BasePicker for backward compatibility.

* Remove unnecesary ternary

* API file update
@microsoft microsoft deleted a comment from msft-github-bot Jun 12, 2019
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pickers: Convert to css-in-js

7 participants