Skip to content

Commit

Permalink
[typescript] [createMuiTheme] Fix typings & deepmerge shape (mui#11993)
Browse files Browse the repository at this point in the history
* fix typings

* fix

* revert

* fix shape

* fix unit test

* add unit test
  • Loading branch information
franklixuefei authored and Joe Shelby committed Jul 14, 2018
1 parent 8e6939d commit 4e4b7fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
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>;

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

0 comments on commit 4e4b7fb

Please sign in to comment.