From 6b7fd3f35e6cdb0abd6bc7bf5418e74a50f3ebce Mon Sep 17 00:00:00 2001 From: Frank Li Date: Wed, 27 Jun 2018 13:17:54 -0700 Subject: [PATCH 1/6] fix typings --- packages/material-ui/src/styles/createMuiTheme.d.ts | 6 ++++-- packages/material-ui/src/styles/createPalette.d.ts | 7 ++++--- packages/material-ui/src/styles/shape.d.ts | 2 -- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/material-ui/src/styles/createMuiTheme.d.ts b/packages/material-ui/src/styles/createMuiTheme.d.ts index 99aeb4ba24080b..19bd158a3edf2a 100644 --- a/packages/material-ui/src/styles/createMuiTheme.d.ts +++ b/packages/material-ui/src/styles/createMuiTheme.d.ts @@ -3,7 +3,7 @@ import { Mixins, MixinsOptions } from './createMixins'; import { Palette, PaletteOptions } from './createPalette'; import { Typography, TypographyOptions } from './createTypography'; import { Shadows } from './shadows'; -import { Shape, ShapeOptions } from './shape'; +import { Shape } from './shape'; import { Spacing, SpacingOptions } from './spacing'; import { Transitions, TransitionsOptions } from './transitions'; import { ZIndex, ZIndexOptions } from './zIndex'; @@ -13,7 +13,7 @@ import { ComponentsProps } from './props'; export type Direction = 'ltr' | 'rtl'; export interface ThemeOptions { - shape?: ShapeOptions; + shape?: Shape; breakpoints?: BreakpointsOptions; direction?: Direction; mixins?: MixinsOptions; @@ -25,6 +25,7 @@ export interface ThemeOptions { transitions?: TransitionsOptions; typography?: TypographyOptions | ((palette: Palette) => TypographyOptions); zIndex?: ZIndexOptions; + status?: Record; } export interface Theme { @@ -40,6 +41,7 @@ export interface Theme { transitions: Transitions; typography: Typography; zIndex: ZIndex; + status?: Record; } export default function createMuiTheme(options?: ThemeOptions): Theme; diff --git a/packages/material-ui/src/styles/createPalette.d.ts b/packages/material-ui/src/styles/createPalette.d.ts index 4a377efdeed77d..1ebf024980ebb3 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; @@ -85,6 +88,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/src/styles/shape.d.ts b/packages/material-ui/src/styles/shape.d.ts index fba5ed44f378a0..6a8d8817a9bb4f 100644 --- a/packages/material-ui/src/styles/shape.d.ts +++ b/packages/material-ui/src/styles/shape.d.ts @@ -2,8 +2,6 @@ export interface Shape { borderRadius: number; } -export type ShapeOptions = Partial; - declare const shape: Shape; export default shape; From 577fa284b0ac4aee9de33173de6c52cc466bb1a4 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Wed, 27 Jun 2018 13:34:09 -0700 Subject: [PATCH 2/6] fix --- packages/material-ui/src/styles/createMuiTheme.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/material-ui/src/styles/createMuiTheme.d.ts b/packages/material-ui/src/styles/createMuiTheme.d.ts index 19bd158a3edf2a..f1021a201fac84 100644 --- a/packages/material-ui/src/styles/createMuiTheme.d.ts +++ b/packages/material-ui/src/styles/createMuiTheme.d.ts @@ -25,7 +25,7 @@ export interface ThemeOptions { transitions?: TransitionsOptions; typography?: TypographyOptions | ((palette: Palette) => TypographyOptions); zIndex?: ZIndexOptions; - status?: Record; + [propName: string]: any; } export interface Theme { @@ -41,7 +41,7 @@ export interface Theme { transitions: Transitions; typography: Typography; zIndex: ZIndex; - status?: Record; + [propName: string]: any; } export default function createMuiTheme(options?: ThemeOptions): Theme; From 79755482f00809e0174b46a13b0b7ca9acf574fb Mon Sep 17 00:00:00 2001 From: Frank Li Date: Wed, 27 Jun 2018 13:45:27 -0700 Subject: [PATCH 3/6] revert --- packages/material-ui/src/styles/createMuiTheme.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/material-ui/src/styles/createMuiTheme.d.ts b/packages/material-ui/src/styles/createMuiTheme.d.ts index f1021a201fac84..eacc823ffdcdc1 100644 --- a/packages/material-ui/src/styles/createMuiTheme.d.ts +++ b/packages/material-ui/src/styles/createMuiTheme.d.ts @@ -25,7 +25,6 @@ export interface ThemeOptions { transitions?: TransitionsOptions; typography?: TypographyOptions | ((palette: Palette) => TypographyOptions); zIndex?: ZIndexOptions; - [propName: string]: any; } export interface Theme { @@ -41,7 +40,6 @@ export interface Theme { transitions: Transitions; typography: Typography; zIndex: ZIndex; - [propName: string]: any; } export default function createMuiTheme(options?: ThemeOptions): Theme; From d4b69f0975fd568eb9c335449c688d5b431223b6 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Wed, 27 Jun 2018 13:51:00 -0700 Subject: [PATCH 4/6] fix shape --- packages/material-ui/src/styles/createMuiTheme.d.ts | 4 ++-- packages/material-ui/src/styles/createMuiTheme.js | 2 +- packages/material-ui/src/styles/shape.d.ts | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/material-ui/src/styles/createMuiTheme.d.ts b/packages/material-ui/src/styles/createMuiTheme.d.ts index eacc823ffdcdc1..99aeb4ba24080b 100644 --- a/packages/material-ui/src/styles/createMuiTheme.d.ts +++ b/packages/material-ui/src/styles/createMuiTheme.d.ts @@ -3,7 +3,7 @@ import { Mixins, MixinsOptions } from './createMixins'; import { Palette, PaletteOptions } from './createPalette'; import { Typography, TypographyOptions } from './createTypography'; import { Shadows } from './shadows'; -import { Shape } from './shape'; +import { Shape, ShapeOptions } from './shape'; import { Spacing, SpacingOptions } from './spacing'; import { Transitions, TransitionsOptions } from './transitions'; import { ZIndex, ZIndexOptions } from './zIndex'; @@ -13,7 +13,7 @@ import { ComponentsProps } from './props'; export type Direction = 'ltr' | 'rtl'; export interface ThemeOptions { - shape?: Shape; + shape?: ShapeOptions; breakpoints?: BreakpointsOptions; direction?: Direction; mixins?: MixinsOptions; diff --git a/packages/material-ui/src/styles/createMuiTheme.js b/packages/material-ui/src/styles/createMuiTheme.js index fa684e37fb855b..9c047901cc7dba 100644 --- a/packages/material-ui/src/styles/createMuiTheme.js +++ b/packages/material-ui/src/styles/createMuiTheme.js @@ -33,13 +33,13 @@ function createMuiTheme(options: Object = {}) { palette, props: {}, // Inject custom properties shadows: shadowsInput || shadows, - shape, typography: createTypography(palette, typographyInput), ...deepmerge( { transitions, spacing, zIndex, + shape }, other, ), diff --git a/packages/material-ui/src/styles/shape.d.ts b/packages/material-ui/src/styles/shape.d.ts index 6a8d8817a9bb4f..fba5ed44f378a0 100644 --- a/packages/material-ui/src/styles/shape.d.ts +++ b/packages/material-ui/src/styles/shape.d.ts @@ -2,6 +2,8 @@ export interface Shape { borderRadius: number; } +export type ShapeOptions = Partial; + declare const shape: Shape; export default shape; From 542f2cf34943af43bfc34dcecb310b78edf01b05 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Wed, 27 Jun 2018 14:04:36 -0700 Subject: [PATCH 5/6] fix unit test --- packages/material-ui/src/styles/createMuiTheme.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui/src/styles/createMuiTheme.js b/packages/material-ui/src/styles/createMuiTheme.js index 9c047901cc7dba..f397a8fcec5867 100644 --- a/packages/material-ui/src/styles/createMuiTheme.js +++ b/packages/material-ui/src/styles/createMuiTheme.js @@ -39,7 +39,7 @@ function createMuiTheme(options: Object = {}) { transitions, spacing, zIndex, - shape + shape, }, other, ), From e832dae771beebbc829256c1339aa33538c34575 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Wed, 27 Jun 2018 23:24:51 +0200 Subject: [PATCH 6/6] add unit test --- packages/material-ui/src/styles/createMuiTheme.js | 4 ++-- packages/material-ui/src/styles/createPalette.d.ts | 6 ++++-- packages/material-ui/test/typescript/styles.spec.tsx | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/material-ui/src/styles/createMuiTheme.js b/packages/material-ui/src/styles/createMuiTheme.js index f397a8fcec5867..5d2f0221d2b1f9 100644 --- a/packages/material-ui/src/styles/createMuiTheme.js +++ b/packages/material-ui/src/styles/createMuiTheme.js @@ -36,10 +36,10 @@ function createMuiTheme(options: Object = {}) { typography: createTypography(palette, typographyInput), ...deepmerge( { - transitions, + shape, spacing, + transitions, zIndex, - shape, }, other, ), diff --git a/packages/material-ui/src/styles/createPalette.d.ts b/packages/material-ui/src/styles/createPalette.d.ts index 1ebf024980ebb3..887791ae668fa0 100644 --- a/packages/material-ui/src/styles/createPalette.d.ts +++ b/packages/material-ui/src/styles/createPalette.d.ts @@ -75,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; 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', },