Skip to content

Commit

Permalink
Palette not optional (#1951)
Browse files Browse the repository at this point in the history
* Make palette and font required for theme

* Rush change

* Update ThemePage.tsx

* Rename theme to palette.
  • Loading branch information
christiango authored Jun 7, 2017
1 parent 3f42fef commit 58ebffa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/styling",
"comment": "ITheme: Make palette a required prop",
"type": "minor"
}
],
"packageName": "@uifabric/styling",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "ITheme: Make palette a required prop",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { loadTheme, FontClassNames, ITheme } from 'office-ui-fabric-react/lib/Styling';
import { loadTheme, FontClassNames, ITheme, IPalette } from 'office-ui-fabric-react/lib/Styling';
import { Highlight } from '@uifabric/example-app-base';
import { defaultTheme } from './defaultTheme';
import { Callout } from 'office-ui-fabric-react/lib/Callout';
Expand Down Expand Up @@ -115,17 +115,17 @@ export class ThemePage extends React.Component<any, any> {
private _onColorChanged(index: number, newColor: string) {
let { colors } = this.state;
let color = colors[index];
let theme: ITheme = {};
let palette: Partial<IPalette> = {};

color.value = newColor;

for (let i = 0; i < colors.length; i++) {
let themeColor = colors[i];

theme[themeColor.key] = themeColor.value;
palette[themeColor.key] = themeColor.value;
}

loadTheme({ palette: theme });
loadTheme({ palette });

// The theme has changed values, but color state is the same. Force an update on the list.
this.refs.list.forceUpdate();
Expand Down
8 changes: 4 additions & 4 deletions packages/styling/src/utilities/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
} from '../styles/index';
import { Customizer } from '@uifabric/utilities/lib/index';
export interface ITheme {
palette?: IPalette;
fonts?: IFontStyles;
palette: IPalette;
fonts: IFontStyles;
semanticColors?: ISemanticColors;
}
import { loadTheme as legacyLoadTheme } from '@microsoft/load-themed-styles';
Expand All @@ -33,7 +33,7 @@ export function getTheme(): ITheme {
/**
* Loads the default global theme definition.
*/
export function loadTheme(theme: ITheme): void {
export function loadTheme(theme: Partial<ITheme>): void {
_theme = createTheme(theme);

// Load the legacy theme from the palette.
Expand All @@ -45,7 +45,7 @@ export function loadTheme(theme: ITheme): void {
/**
* Creates a custom theme definition which can be used with the Customizer.
*/
export function createTheme(theme: ITheme): ITheme {
export function createTheme(theme: Partial<ITheme>): ITheme {
let newPalette = {
..._theme.palette,
...theme.palette
Expand Down

0 comments on commit 58ebffa

Please sign in to comment.