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

Fluent-theme: clean the fluent styles so no hard coded colors are used #8098

Merged
merged 17 commits into from
Feb 26, 2019

Conversation

Vitalius1
Copy link
Contributor

@Vitalius1 Vitalius1 commented Feb 23, 2019

Pull request checklist

Description of changes

  1. Cleaning all the hard-coded fluent color values with the ones coming from the theme. This required bringing back the neutralSecondaryAlt from the deprecation status. All the colors swaps changes were approved by designers (@betrue-final-final ) and @phkuo might have to change the ThemeGenerator logic to take into account the neutralSecondaryAlt resurrection from death.
  2. Make the buttons styles to be functions so that we can access the theme palette and not use the hard-coded colors which were blocking OWA team from testing the package (thanks to Button: Updating Customizable to evaluate style function callbacks #7748). (@MLoughry FYI)
  3. Clean up the use of hard-coded boxShadow and borderRadius values from FluentDepths and styleConstants with the ones passed through theme.effects
  4. Adjust the types on IEffects properties to allow more flexibility for what to pass and making it easier to use in styles. (discussed with @phkuo )
Microsoft Reviewers: Open in CodeFlow

@Vitalius1 Vitalius1 requested a review from dzearing as a code owner February 23, 2019 02:12
Copy link
Contributor

@phkuo phkuo left a comment

Choose a reason for hiding this comment

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

see comments


export const BasePickerStyles = (props: IBasePickerStyleProps): Partial<IBasePickerStyles> => {
const { theme } = props;
if (!theme) {
throw new Error('Theme is undefined or null.');
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this never happen? isn't a base part of fabric that we guarantee the theme?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of the components don't follow this pattern in their style props to make the theme required and this happens. I believe that is something that needs to be cleaned up as well to have a consistent API across all components.

Copy link
Member

Choose a reason for hiding this comment

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

Whether or not theming is required via props typing doesn't affect whether it's actually available. This is actually determined by the use of styled helper which will automatically inject themes prop, even if the component has made theme prop optional. I've modified this approach in Foundation by making theme prop required as part of an inherited interface.

For now, no other components are actually checking for theme's existence in styles functions, so I think it's consistent to assume it's available in styles functions.

Copy link
Member

Choose a reason for hiding this comment

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

(The assumption here is that 'some of the components' are all components using styled. Components that use customizable or other methods cannot technically have styles functions called.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JasonGore if I remove the theme check on this components I get this lint message:
screen shot 2019-02-25 at 10 50 11 am
Also, there are a couple of components in OUFR that are still doing the same thing. And I know that in Foundation this is fixed 👍 Thanks for the consisitency in the API that it will bring to our repo.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this is because of the typing on the component making it optional. Other styles functions do this:

const { effects } = theme!;

Which of course isn't ideal either. In either case an exception would occur. Maybe your approach is best for communicating the actual issue.

packages/styling/src/interfaces/IEffects.ts Outdated Show resolved Hide resolved
@size-auditor
Copy link

size-auditor bot commented Feb 23, 2019

Size Auditor did not detect a change in bundle size for any component!

Copy link
Member

@Jahnp Jahnp left a comment

Choose a reason for hiding this comment

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

A mighty effort! Code changes look great @Vitalius1 . Did you do a run-through of the components during or after making all these changes? I'm happy to do that for another round of validation.

@Vitalius1
Copy link
Contributor Author

@Jahnp I did look through the components both during making the changes and after I've done them. There is still one more PR I want to submit with passing the font type ramp through the theme and after will need to make another full pass through the components in pair with Ben to make sure we have followed the redlines in full (minus the components that are still waiting for design).

@Vitalius1
Copy link
Contributor Author

@dzearing do you mind to take a look, please?

@Vitalius1 Vitalius1 mentioned this pull request Feb 26, 2019
10 tasks
@dzearing dzearing merged commit 4f0b6ed into microsoft:master Feb 26, 2019
@msft-github-bot
Copy link
Contributor

🎉@uifabric/[email protected] has been released which incorporates this pull request.:tada:

Handy links:

@msft-github-bot
Copy link
Contributor

🎉@uifabric/[email protected] has been released which incorporates this pull request.:tada:

Handy links:

@msft-github-bot
Copy link
Contributor

🎉[email protected] has been released which incorporates this pull request.:tada:

Handy links:

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

Fluent styles should use palette colors
8 participants