Skip to content

ChoiceGroup: getStyles conversion#4852

Merged
dzearing merged 16 commits intomicrosoft:masterfrom
FalseLobster:ChoiceGroup
May 23, 2018
Merged

ChoiceGroup: getStyles conversion#4852
dzearing merged 16 commits intomicrosoft:masterfrom
FalseLobster:ChoiceGroup

Conversation

@FalseLobster
Copy link
Copy Markdown
Contributor

Pull request checklist

Description 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

package.json Outdated
"@microsoft/rush": "4.3.0"
},
"dependencies": {
"npm": "^6.0.0"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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... ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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', () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 cliffkoh changed the base branch from master to new_6.0 May 14, 2018 19:46
Copy link
Copy Markdown
Contributor

@cliffkoh cliffkoh left a comment

Choose a reason for hiding this comment

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

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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As we are targeting the 6.0 branch, we should rename all the changefiles to 6_0_choiceGroupGetStyles.json manually

@cliffkoh cliffkoh closed this May 14, 2018
@cliffkoh cliffkoh reopened this May 14, 2018
@cliffkoh cliffkoh changed the base branch from new_6.0 to master May 14, 2018 22:13
@cliffkoh cliffkoh changed the base branch from master to new_6.0 May 14, 2018 22:13
@dzearing dzearing changed the title Choice group getStyles conversion ChoiceGroup: getStyles conversion May 15, 2018
@FalseLobster FalseLobster changed the base branch from new_6.0 to master May 15, 2018 20:32
@FalseLobster
Copy link
Copy Markdown
Contributor Author

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

layeron [](start = 50, length = 7)

layer on

theme?: ITheme;

/**
* Call to provide customized styling that will layeron top of the variant rules.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

layeron [](start = 50, length = 7)

layer on

@@ -0,0 +1,2 @@
export * from './ChoiceGroupOption';
export * from './ChoiceGroupOption.types';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here...new 'styles' approach set to IStyleFunction<> || IChoiceGroupOptionStyles

Copy link
Copy Markdown
Member

@micahgodbolt micahgodbolt left a comment

Choose a reason for hiding this comment

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

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?

@JasonGore
Copy link
Copy Markdown
Member

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.

@cliffkoh
Copy link
Copy Markdown
Contributor

Hi @micahgodbolt, as the change targets 5.0, she should check in getStyles. When we do the merge into 6.0 though, we'll rename on @FalseLobster 's behalf to styles.

@FalseLobster
Copy link
Copy Markdown
Contributor Author

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.

@JasonGore
Copy link
Copy Markdown
Member

JasonGore commented May 18, 2018

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.)

@dzearing dzearing merged commit d152bb7 into microsoft:master May 23, 2018
dzearing added a commit that referenced this pull request May 23, 2018
#4962)

* Revert "ChoiceGroup: getStyles conversion (#4852)"

This reverts commit d152bb7.

* Adding change files.
Markionium added a commit to Markionium/office-ui-fabric-react that referenced this pull request May 23, 2018
* 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)
  ...
@JasonGore JasonGore mentioned this pull request May 23, 2018
2 tasks
@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.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow customization of ChoiceGroup styles

6 participants