Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResizeGroup SCSS to MergeStyles Part 2: Style Conversion #4072

Merged

Conversation

oengusmacinog-zz
Copy link
Collaborator

@oengusmacinog-zz oengusmacinog-zz commented Feb 22, 2018

Pull request checklist

  • Include a change request file using $ npm run change

Description of changes

Convert all SCSS to MergeStyles in ResizeGroup component.

data={ initialData }
onReduceData={ onReduceScalingData }
onRenderData={ onRenderData }
/>
);
).first().shallow().first().shallow();
Copy link
Member

@dzearing dzearing Feb 22, 2018

Choose a reason for hiding this comment

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

we should try to use that helper here, or, use mount.

Copy link
Member

@dzearing dzearing left a comment

Choose a reason for hiding this comment

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

Overall fine, but that test... can you add a utility to avoid doing this everywhere?

@dzearing dzearing self-assigned this Feb 23, 2018
Copy link
Contributor

@jordandrako jordandrako left a comment

Choose a reason for hiding this comment

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

Nice work. My only suggestion from here would be to document how to use the shallowUntilTarget test.

Copy link
Contributor

@joschect joschect left a comment

Choose a reason for hiding this comment

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

Approved with some suggestions

if (typeof root.type() === 'string') {
// If type() is a string then it's a DOM Node.
// If it were wrapped, it would be a React component.
throw new Error('Cannot unwrap this component because it is not wrapped');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that we shouldn't throw in this case. I should be able to use this function anywhere that shallow can be used. If the TargetComponent is a div, and the root is a div then that's a fine case. If this should only be used in the case of a decorated component, then the name should reflect that. Something like shallowDecoratedComponent

return root.first().shallow(shallowOptions);
}
// Unwrap the next component in the hierarchy.
root = root.first().shallow(shallowOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

While I don't think that any decorators we currently have render multiple siblings, it is possible that this will miss a component that isn't the first child.

*/
export function shallowUntilTarget<P, S>(
componentInstance: React.ReactElement<P>,
TargetComponent: string,
Copy link
Contributor

Choose a reason for hiding this comment

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

You could have target component be type of Function, and then users could pass in the actual class that they care about. You could then access the string by calling TargetComponent.name and it would work out fine. That way it keeps things a bit more type safe since they would need to import the actual class they care about. This is just a suggestion, if you feel like trying it out that would be cool, otherwise no worries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was the original way that I had implemented this, but specifically for decorated functions like ResizeGroupBase, the name becomes 'ComponentWithInjectedProps' so it returns before it should. Passing a string name into the function was a way to avoid this.

@micahgodbolt
Copy link
Member

This is fine, but we might want to note that the component relies on some of those styles to function properly. Changing the visibility of the 'measured' div, or the position, will have really nasty side effects. Do we want to move those into the component rather than being considered "themed styles".

@jordandrako
Copy link
Contributor

@micahgodbolt That's a good point. Should we create a baseStyles pattern to use for essential styling properties?

@micahgodbolt
Copy link
Member

inline works fine for me. We should be making those styles hard to override as doing so might break the functionality.

@oengusmacinog-zz oengusmacinog-zz merged commit 9b0294a into microsoft:master Mar 1, 2018
@oengusmacinog-zz oengusmacinog-zz deleted the resizegroup-scss2ms-pt2 branch March 1, 2018 01:10
Markionium added a commit to Markionium/office-ui-fabric-react that referenced this pull request Mar 1, 2018
* master:
  ResizeGroup SCSS to MergeStyles Part 2: Style Conversion (microsoft#4072)
  Applying package updates.
  Import Unstyled Component for Layer, Nav, Image, ScrollablePane, ResizeGroup,  and Rating (microsoft#4135)
  FocusZone: isDefaultPrevented is now respected (microsoft#4133)
  Website: Left nav scroll improvements (microsoft#4132)
  AutoFill: Component should also listen to onInput, just like the other input components do (microsoft#4129)
  GroupedList: Fixed chevron animation (microsoft#4123)
  CoachMarkStyles: Use ... instead of assign for IE compatibility" (microsoft#4130)
  Applying package updates.
chrismohr pushed a commit to chrismohr/office-ui-fabric-react that referenced this pull request Apr 17, 2018
)

* convert scss to mergeStyles

* rush change

* updated snapshots

* update experiments snapshots

* temp fix for shallow test with decorator usage

* added shallowUntilTarget function to Utilities for use with decorated components

* cleanup

* moved shallowUntilTarget into fabrics common folder

* clean up imports

* remove scss

* added base to index

* shallowUntilTarget default shallow functionality

* removing base from index so styles are not optional

* moved measured styles to inline

* updated snapshots

* missing semicolon

* updated experiments snapshots
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 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.

5 participants