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

[typescript] [createMuiTheme] Fix typings & deepmerge shape #11993

Merged
merged 6 commits into from
Jun 27, 2018

Conversation

franklixuefei
Copy link
Contributor

fixes #11853

@@ -25,6 +25,7 @@ export interface ThemeOptions {
transitions?: TransitionsOptions;
typography?: TypographyOptions | ((palette: Palette) => TypographyOptions);
zIndex?: ZIndexOptions;
status?: Record<string, string>;
Copy link
Member

@oliviertassinari oliviertassinari Jun 27, 2018

Choose a reason for hiding this comment

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

No, it's too specific.

@@ -13,7 +13,7 @@ import { ComponentsProps } from './props';
export type Direction = 'ltr' | 'rtl';

export interface ThemeOptions {
shape?: ShapeOptions;
shape?: Shape;
Copy link
Member

@oliviertassinari oliviertassinari Jun 27, 2018

Choose a reason for hiding this comment

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

Don't we still need the partial? Like we do for the Spacing.

Copy link
Contributor Author

@franklixuefei franklixuefei Jun 27, 2018

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@franklixuefei franklixuefei Jun 27, 2018

Choose a reason for hiding this comment

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

FYI - if you take a look at shadow type definition under the ThemeOptions interface, it is not Partial<> either.
https://github.com/mui-org/material-ui/blob/ca33d9773581a8b0ff37c92260b48c9f72b42de9/packages/material-ui/src/styles/createMuiTheme.d.ts#L23

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for raising the issue! Should we fix the implementation over the TypeScript definition then? I have missed this part. I think that spacing and shape should behave the same way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. I'll do this. BTW, what about shadows? Should it also be a partial in the ThemeOptions?

Copy link
Member

@oliviertassinari oliviertassinari Jun 27, 2018

Choose a reason for hiding this comment

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

we need to specify the full props

I don't think that it's the behavior people expect. We need to fix the shape key :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NVM. shadows is different.

Copy link
Member

Choose a reason for hiding this comment

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

Regarding the shadows, yeah it's fine. Relative values are important, people need to provide the full property.

@@ -85,6 +88,4 @@ export interface PaletteOptions {
getContrastText?: (background: string) => string;
}

//export type PaletteOptions = DeepPartial<Palette>;
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was commented out. Why do we want to preserve the commented out code?

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering why it was commented out; Let's remove it then :)

@@ -40,6 +41,7 @@ export interface Theme {
transitions: Transitions;
typography: Typography;
zIndex: ZIndex;
status?: Record<string, string>;
Copy link
Member

Choose a reason for hiding this comment

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

No, it's too specific.

@oliviertassinari oliviertassinari changed the title [typescript] fixed typings [typescript] Fix typings Jun 27, 2018
@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Jun 27, 2018
@franklixuefei franklixuefei changed the title [typescript] Fix typings [typescript] [createMuiTheme] Fix typings & deepmerge shape Jun 27, 2018
@oliviertassinari oliviertassinari merged commit 05b59db into mui:master Jun 27, 2018
@oliviertassinari
Copy link
Member

@franklixuefei So many bug fixes in a single pull request 🎉!

@franklixuefei
Copy link
Contributor Author

@oliviertassinari Thanks for taking care of this! I actually left out those two props tonalOffset and contrastThreshold under ThemeOptions. Thanks for adding them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants