Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
408542c
Removing some of the deprecated components flaged when turning the ts…
khmakoto Oct 22, 2018
9a70bf7
Adding corresponding change file.
khmakoto Oct 22, 2018
9ad7683
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
khmakoto Oct 23, 2018
8e5a757
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
khmakoto Oct 23, 2018
9e4a643
Reverting changes that affected backwards compatibility because it re…
khmakoto Oct 23, 2018
146d37a
Adding missing deprecation reversion in BaseButton.
khmakoto Oct 23, 2018
06c99b4
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
khmakoto Oct 23, 2018
efd8396
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
khmakoto Oct 24, 2018
4dfa320
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
khmakoto Oct 29, 2018
e5e4743
Adding changes in oufr api.
khmakoto Oct 29, 2018
2b418eb
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
khmakoto Oct 29, 2018
28fd352
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
khmakoto Oct 30, 2018
4a49869
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
khmakoto Nov 29, 2018
64f2b45
Lifting the resolution of default and user provided style variables t…
khmakoto Nov 29, 2018
b058c6b
Adding change file.
khmakoto Nov 29, 2018
0511664
Delete master_2018-10-22-23-24.json
khmakoto Nov 29, 2018
12c1e81
Camel casing variable processing utility file.
khmakoto Nov 30, 2018
5e8e30f
Simplifying resolveStyleVariables to one line with less repeat.
khmakoto Nov 30, 2018
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/experiments",
"comment": "Lifting the resolution of default and user provided style variables to Utilities.",
"type": "patch"
}
],
"packageName": "@uifabric/experiments",
"email": "[email protected]"
}
11 changes: 10 additions & 1 deletion packages/experiments/src/components/Button/Button.styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IButtonComponent, IButtonStyles, IButtonStyleVariablesTypes, IButtonStates } from './Button.types';
import { getFocusStyle, getGlobalClassNames, concatStyleSets } from '../../Styling';
import { processVariables } from '../../utilities/VariableProcessing';
import { merge } from '../../Utilities';

export const getButtonStyles: IButtonComponent['styles'] = props => {
const { theme, disabled, expanded, className, circular, primary, styleVariables } = props;
Expand Down Expand Up @@ -222,3 +222,12 @@ export const getButtonStyles: IButtonComponent['styles'] = props => {
}
);
};

export type IProcessedVariables<T> = { [P in keyof T]-?: IProcessedVariables<T[P]> };

export function processVariables<T>(partialVariables: T, customVariables?: T): IProcessedVariables<T> {
// tslint:disable-next-line:no-any
const result = customVariables ? merge({}, partialVariables, customVariables) : partialVariables;

return result as IProcessedVariables<T>;
}
11 changes: 3 additions & 8 deletions packages/experiments/src/components/Toggle/Toggle.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IToggleComponent, IToggleStyles, IToggleStyleVariablesTypes, IToggleStyleVariables, IToggleViewProps } from './Toggle.types';
import { getFocusStyle, getGlobalClassNames, HighContrastSelector, concatStyleSets } from '../../Styling';
import { resolveStyleVariables } from '../../utilities/variableProcessing';

const GlobalClassNames = {
root: 'ms-Toggle',
Expand Down Expand Up @@ -214,15 +215,9 @@ export const ToggleStyles: IToggleComponent['styles'] = props => {
}

function getToggleStyles(userStyleVariables: IToggleStyleVariables): Partial<IToggleStyles> {
let toggleVariables: IToggleStyleVariablesTypes;
let toggleVariables = getToggleViewStyleVariables(props);

toggleVariables = getToggleViewStyleVariables(props);

if (typeof userStyleVariables === 'function') {
toggleVariables = { ...toggleVariables, ...userStyleVariables(props) };
} else if (userStyleVariables !== undefined) {
toggleVariables = { ...toggleVariables, ...userStyleVariables };
}
toggleVariables = resolveStyleVariables(props, toggleVariables, userStyleVariables);

return getToggleStylesFromState(toggleVariables);
}
Expand Down
10 changes: 0 additions & 10 deletions packages/experiments/src/utilities/VariableProcessing.ts

This file was deleted.

15 changes: 15 additions & 0 deletions packages/experiments/src/utilities/variableProcessing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export type IComponentStyleVariables<TComponentViewProps, TComponentStyleVariablesTypes> =
| TComponentStyleVariablesTypes
| ((props: TComponentViewProps) => TComponentStyleVariablesTypes)
| undefined;

export function resolveStyleVariables<
TViewProps,
TStyleVariablesTypes,
TStyleVariables extends IComponentStyleVariables<TViewProps, TStyleVariablesTypes>
>(props: TViewProps, ...variableArray: TStyleVariables[]): TStyleVariablesTypes {
return Object.assign(
{},
...variableArray.map(variables => (typeof variables === 'function' ? (variables as Function)(props) : variables))
);
}