Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/variants",
"comment": "add a usage example to the readme",
"type": "patch"
}
],
"packageName": "@uifabric/variants",
"email": "[email protected]"
}
25 changes: 18 additions & 7 deletions packages/variants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@

Variants are [themes](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/ghdocs/Theming.md) generated from an existing theme, as opposed to [from raw colors](https://developer.microsoft.com/en-us/fabric#/styles/themegenerator). A variant will share the same colors as the original theme it was generated from, but will use those colors differently. For example, the background color and text color might be swapped. Variants can be used to highlight or de-emphasize portions of the page.

This project provides helper functions to create variants of a given theme, which are intended for use with the [Customizer](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/utilities/src/Customizer.tsx) component. Each function takes in an [IPartialTheme](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/styling/src/interfaces/ITheme.ts) and returns an [ITheme](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/styling/src/interfaces/ITheme.ts).
Example of normal, soft, and strong variants:

The available variants are:
![example of variants](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/variants/example.png)

* Neutral (not yet implemented) - a soft neutral color is used as the background (light gray in the default theme), most other colors are changed very little or not at all
* Soft - a soft shade of the primary color is used as the background (light blue in the default theme), most other colors are changed very little or not at all, but input controls look different
* Strong - a strong shade of the primary color is used as the background (blue in the default theme), almost all colors are changed
This project provides helper functions to create variants of a given theme, which can be used with the [Customizer](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/utilities/src/Customizer.tsx) component to theme a specific portion of the page. Each function takes in an [IPartialTheme](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/styling/src/interfaces/ITheme.ts) and returns an [ITheme](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/styling/src/interfaces/ITheme.ts).

Example of normal, soft, and strong variants:
The following example uses [getTheme()](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/styling/src/styles/theme.ts) to grab the current global theme, then creates a strong variant of the that theme, and applies that strong variant to the components wrapped by Customizer.

```
<Customizer settings={ { theme: getStrongVariant(getTheme()) } }>
<components... />
</Customizer>
```

The available variants are:

![example of variants](https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/variants/example.png)
* ``` getNeutralVariant(theme: IPartialTheme): ITheme ```
* Neutral - a soft neutral color is used as the background (light gray in the default theme), most other colors are changed very little or not at all
* ``` getSoftVariant(theme: IPartialTheme): ITheme ```
* Soft - a soft shade of the primary color is used as the background (light blue in the default theme), most other colors are changed very little or not at all, but input controls look different
* ``` getStrongVariant(theme: IPartialTheme): ITheme ```
* Strong - a strong shade of the primary color is used as the background (blue in the default theme), almost all colors are changed