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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/material-ui/src/styles/createMuiTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function createMuiTheme(options: Object = {}) {
palette,
props: {}, // Inject custom properties
shadows: shadowsInput || shadows,
shape,
typography: createTypography(palette, typographyInput),
...deepmerge(
{
transitions,
shape,
spacing,
transitions,
zIndex,
},
other,
Expand Down
13 changes: 8 additions & 5 deletions packages/material-ui/src/styles/createPalette.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface TypeBackground {
paper: string;
}

type TypeDivider = string;

export type PaletteColorOptions = SimplePaletteColorOptions | Partial<Color>;

export interface SimplePaletteColorOptions {
Expand All @@ -40,6 +42,7 @@ export interface PaletteColor {
export interface TypeObject {
text: TypeText;
action: TypeAction;
divider: TypeDivider;
background: TypeBackground;
}

Expand All @@ -56,7 +59,7 @@ export interface Palette {
error: PaletteColor;
grey: Color;
text: TypeText;
divider: string;
divider: TypeDivider;
action: TypeAction;
background: TypeBackground;
getContrastText: (background: string) => string;
Expand All @@ -72,11 +75,13 @@ type PartialTypeObject = { [P in keyof TypeObject]?: Partial<TypeObject[P]> };
type ColorPartial = Partial<Color>;

export interface PaletteOptions {
common?: Partial<CommonColors>;
type?: PaletteType;
primary?: PaletteColorOptions;
secondary?: PaletteColorOptions;
error?: PaletteColorOptions;
type?: PaletteType;
tonalOffset?: number;
contrastThreshold?: number;
common?: Partial<CommonColors>;
grey?: ColorPartial;
text?: Partial<TypeText>;
divider?: string;
Expand All @@ -85,6 +90,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 :)


export default function createPalette(palette: PaletteOptions): Palette;
2 changes: 2 additions & 0 deletions packages/material-ui/test/typescript/styles.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ const theme = createMuiTheme({
palette: {
type: 'dark',
primary: blue,
contrastThreshold: 3,
tonalOffset: 0.2,
common: {
white: '#ffffff',
},
Expand Down