ChoiceGroup: getStyles conversion#4852
Conversation
… split out ChoiceGroupOption into subcomponent. Everything working except Focus rect right now
…c-react into ChoiceGroup # Conflicts: # packages/office-ui-fabric-react/src/components/ChoiceGroup/ChoiceGroup.tsx # packages/office-ui-fabric-react/src/components/ChoiceGroup/ChoiceGroup.types.ts
package.json
Outdated
| "@microsoft/rush": "4.3.0" | ||
| }, | ||
| "dependencies": { | ||
| "npm": "^6.0.0" |
There was a problem hiding this comment.
This is actually unintentional. npm told me at some point to run a command, which I diligently obeyed, and this edit got auto-added. Commentary is welcome on why npm thought this was necessary... ?
There was a problem hiding this comment.
I believe npm was telling you that a new version of npm is available and prompting you to upgrade :) But.. you might have entered incorrectly (specifically, missed the -g option so it became a local install that was written to package.json)
You probably want to revert this.
| <div className={ this._classNames.root }> | ||
| <div className={ this._classNames.choiceFieldWrapper }> | ||
| <input | ||
| { ...getNativeProps(this.props, inputProperties) } |
There was a problem hiding this comment.
My understanding here is that stomping over getNativeProps is undesirable and the spread should really be at the end of the tag. I ran into issues with that ordering, but I want to leave this comment here to solicit commentary and to remind myself to revisit whether or not I'm still seeing issues with this ordering.
| import { ChoiceGroupOption } from './ChoiceGroupOption'; | ||
|
|
||
| describe('ChoiceGroupOption', () => { | ||
|
|
There was a problem hiding this comment.
I don't know if there's a best practice for authoring snapshot tests, so I just picked a bunch of interesting permutations of the ChoiceGroupOption props.
cliffkoh
left a comment
There was a problem hiding this comment.
Going to close/reopen the PR to force a re-base
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "Deprecate Persona's primaryText prop and add replacement text prop.", | ||
| "comment": "ChoiceGroup getStyles conversion", |
There was a problem hiding this comment.
As we are targeting the 6.0 branch, we should rename all the changefiles to 6_0_choiceGroupGetStyles.json manually
|
Issue #4836 should now also be addressed by this PR |
| theme?: ITheme; | ||
|
|
||
| /** | ||
| * Call to provide customized styling that will layeron top of the variant rules. |
There was a problem hiding this comment.
layeron [](start = 50, length = 7)
layer on
| theme?: ITheme; | ||
|
|
||
| /** | ||
| * Call to provide customized styling that will layeron top of the variant rules. |
There was a problem hiding this comment.
layeron [](start = 50, length = 7)
layer on
| @@ -0,0 +1,2 @@ | |||
| export * from './ChoiceGroupOption'; | |||
| export * from './ChoiceGroupOption.types'; | |||
There was a problem hiding this comment.
why is ChoiceGroupOption at components level? can this be used as an independent component outside of ChoiceGroup? if not, can you put it under ChoiceGroup folder?
There was a problem hiding this comment.
I think there is value in letting this be used as an independent component, though that might be good to do at a later date once everyone is happy with this current abstraction.
| /** | ||
| * Call to provide customized styling that will layeron top of the variant rules. | ||
| */ | ||
| getStyles?: IStyleFunction<IChoiceGroupStyleProps, IChoiceGroupStyles>; |
There was a problem hiding this comment.
getStyles? [](start = 2, length = 10)
Since you are introducing it here, it would be nice to have an example around its usage in the example pages we have for ChoiceGroup.
There was a problem hiding this comment.
In 6.0 we're decided to stick with "styles" as the prop name, and allow it to support a function or simple style object as a value. Can we get inline with that approach?
| /** | ||
| * Call to provide customized styling that will layeron top of the variant rules. | ||
| */ | ||
| getStyles?: IStyleFunction<IChoiceGroupOptionStyleProps, IChoiceGroupOptionStyles>; |
There was a problem hiding this comment.
same here...new 'styles' approach set to IStyleFunction<> || IChoiceGroupOptionStyles
micahgodbolt
left a comment
There was a problem hiding this comment.
I'd like to hold this PR until we resolve styles vs getStyles. I'm also curious if optionAs needs to be used as well. @dzearing i noticed crumbAs was eventually removed, is this still a pattern we want to follow?
|
Per our discussion, this PR should make sure the IChoiceGroupOption "output" props labelId, checked, and id are still working properly. I will make a separate issue to deal with removing the "output" props so that props no longer have to be mutated. |
|
Hi @micahgodbolt, as the change targets 5.0, she should check in |
|
Hey all. As far as I know the only outstanding issue is the concern raised by @JasonGore regarding the mutation of output props. I think that some sort of "breaking" design change here may be necessary, either in the IChoiceGroupOption we pass in as argument to the callbacks or the mutating behavior. I'll follow up later with more on this point, but I wanted to at least commit the move of CGO to a subdirectory of CG. |
|
I broke the output props as a separate issue because I was fairly certain that, even though using output props is unorthodox, we probably don't want to yank them out entirely on 5.0 or without deprecating them first. I think the best course of action is to have this PR continue providing those props unless this is prohibitive to do in this refactor. (In which case we can discuss how to introduce breaking changes, whether by targeting 6.0 or some other method.) |
* master: (67 commits) Applying package updates. Revert ChoiceGroup change in 5.0 to minimize potential partner impact. (microsoft#4962) Applying package updates. ChoiceGroup: getStyles conversion (microsoft#4852) Export SASS variables and mixins (microsoft#4959) Variants: update algorithm (microsoft#4949) Allow for customization of keycodes that cause the focus rect to appear (microsoft#4948) Mergestyles facepile (microsoft#4950) Fixing circular dependency and non-AMD references in ContextualMenu (microsoft#4946) Clean up semantic slots (microsoft#4932) Added missing merge-styles background-size typing (microsoft#4935) Applying package updates. Split menu button styles (microsoft#4922) Experimental Chiclet Component (microsoft#4678) Remove hover and pressed background colors (microsoft#4908) Remove @cschleiden as Rating code owner (microsoft#4929) Addressing Issue microsoft#3691 - SplitButton: In Safari, the SplitButton has mismatched heights (microsoft#4797) Applying package updates. Adding option for focus on tags in disabled picker (microsoft#4833) Jest merge-styles serialization fix for animation-name (microsoft#4927) ...
Pull request checklist
$ npm run changeDescription of changes
Splits ChoiceGroup into two components, ChoiceGroup and ChoiceGroupOption
Migrates from scss styling to javascript-based getStyles
Adds support for conditionally applying global class names
Focus areas to test
ChoiceGroup visuals