From 05b59dbd3a099442980bae35204996f37c6ba198 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Wed, 27 Jun 2018 14:31:42 -0700 Subject: [PATCH] [typescript] [createMuiTheme] Fix typings & deepmerge shape (#11993) * fix typings * fix * revert * fix shape * fix unit test * add unit test --- packages/material-ui/src/styles/createMuiTheme.js | 4 ++-- packages/material-ui/src/styles/createPalette.d.ts | 13 ++++++++----- .../material-ui/test/typescript/styles.spec.tsx | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/material-ui/src/styles/createMuiTheme.js b/packages/material-ui/src/styles/createMuiTheme.js index fa684e37fb855b..5d2f0221d2b1f9 100644 --- a/packages/material-ui/src/styles/createMuiTheme.js +++ b/packages/material-ui/src/styles/createMuiTheme.js @@ -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, diff --git a/packages/material-ui/src/styles/createPalette.d.ts b/packages/material-ui/src/styles/createPalette.d.ts index 4a377efdeed77d..887791ae668fa0 100644 --- a/packages/material-ui/src/styles/createPalette.d.ts +++ b/packages/material-ui/src/styles/createPalette.d.ts @@ -21,6 +21,8 @@ interface TypeBackground { paper: string; } +type TypeDivider = string; + export type PaletteColorOptions = SimplePaletteColorOptions | Partial; export interface SimplePaletteColorOptions { @@ -40,6 +42,7 @@ export interface PaletteColor { export interface TypeObject { text: TypeText; action: TypeAction; + divider: TypeDivider; background: TypeBackground; } @@ -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; @@ -72,11 +75,13 @@ type PartialTypeObject = { [P in keyof TypeObject]?: Partial }; type ColorPartial = Partial; export interface PaletteOptions { - common?: Partial; - type?: PaletteType; primary?: PaletteColorOptions; secondary?: PaletteColorOptions; error?: PaletteColorOptions; + type?: PaletteType; + tonalOffset?: number; + contrastThreshold?: number; + common?: Partial; grey?: ColorPartial; text?: Partial; divider?: string; @@ -85,6 +90,4 @@ export interface PaletteOptions { getContrastText?: (background: string) => string; } -//export type PaletteOptions = DeepPartial; - export default function createPalette(palette: PaletteOptions): Palette; diff --git a/packages/material-ui/test/typescript/styles.spec.tsx b/packages/material-ui/test/typescript/styles.spec.tsx index f42913e7801884..c3a34c0360e3b2 100644 --- a/packages/material-ui/test/typescript/styles.spec.tsx +++ b/packages/material-ui/test/typescript/styles.spec.tsx @@ -77,6 +77,8 @@ const theme = createMuiTheme({ palette: { type: 'dark', primary: blue, + contrastThreshold: 3, + tonalOffset: 0.2, common: { white: '#ffffff', },