npm package: @ibm-wch-sdk/theme
Description: Module that implements @ngrx bindings to the login and logout functionality as offered by the @ibm-wch-sdk/ng modules.
Author: Dr. Carsten Leue
Latest version: 6.0.524

<a name="_6413c217ac070f0cc888ef237e5f77bca091ed14c4a6b017e8102394c2fc842d"></a>
# ibm-wch-sdk-theme

Module that implements utility functions to deal with theme like UI configuration in [WCH](https://www.ibm.com/products/watson-content-hub) for single page applications.

## Details

Refer to the [documentation](#_4f5f0d570547cc32a6c26a19831659ff187906f3e173dec4cc7caa8b01b03375).

## Changes

[CHANGELOG](#_20bdb6f8aeaf2e57d73cf0f8f7596ac3a05ab33429cf49a686e6738debcd4512)

## Class documentation

Refer to the [documentation](#_28a07594e891c43454fa39c2c573639385bbf768c0897d05c3db61d89570388b).

## Usage

Install the module via

```bash
npm install --save ibm-wch-sdk-theme
```

<a name="_4f5f0d570547cc32a6c26a19831659ff187906f3e173dec4cc7caa8b01b03375"></a>
# Theme Module

This module provides utility classes to compute UI customization based on content items.

## Usecase

Allow a business user to customize the color scheme of a single page application by making modifications to a content item using the WCH admin UI. Without having to touch the source code of the deployed application.

## Usage

* The [colors](#_ab167706d0c180e5d0d336ac95a46db61e3e70864d4dba0b474710237760db3c) sub module exposes functions to compute color variations based on a (configured) base color. This can be used to automatically build a color palette.
* The [theme](#_405ac4d6cb05a400c74edf2b4bf0019abf74607aece77bcd6b0e7ecb9aa72fa1) sub module computes CSS styles and [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables) based on a [RenderingContext](https://www.npmjs.com/package/ibm-wch-sdk-api).


<a name="_20bdb6f8aeaf2e57d73cf0f8f7596ac3a05ab33429cf49a686e6738debcd4512"></a>
# Changelog

## Current

## 6.0.69

### Added

* Decode color name directly from the browser
* Build theme styles from `RenderingContext` based on `Color` suffix
* Initial version

<a name="_28a07594e891c43454fa39c2c573639385bbf768c0897d05c3db61d89570388b"></a>

#  @ibm-wch-sdk/theme

## Index

### External modules

* ["colors/colors"](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)
* ["colors/index"](#_de08aaef1ac41dc80b670f1a414329c3a9194fc4d0056833b87e4bbff345a30e)
* ["index"](#_d53838c3180bb9a0e5494e993ceb8942c9866e807f2cfe89645b7e36005a0cf8)
* ["styles"](#_a0017d63397dbc31246d84d4a65fde40b7e938ce11200c55a314400ecc742d00)
* ["theme/index"](#_e29f368d111ff8c51a7065d3d0463a6e498b75a1f3c2e9775dfea806ae401cb5)
* ["theme/theme"](#_5a3c6b420ff7c43fc2376cdd8d181fe74fe375e37bbdb2a9f1826ff46c210d46)

---


<a name="_ab167706d0c180e5d0d336ac95a46db61e3e70864d4dba0b474710237760db3c"></a>
# Colors

A theme color palette typically consists of a set of base colors (such as `primary` or `secondary`) and derivations of these colors. Business users only want to customize the base colors, the variations can be computed.

## Functions

* the `colorVariations` method computes color variations for a base color by computing a set of darker and lighter colors. The result is provided as a mapping from [CSS variable](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables) to color value.

## Naming Scheme

The CSS variables are named using the following pattern: `--${basename}-${method}-${level}` where:

* `basename`: logical name of the color in the scheme
* `method`: variation, e.g. `darken` or `lighten`
* `level`: percent value of the application of the method. A value `darken-5` e.g. means that the base color has been darkened by 5%.


<a name="_405ac4d6cb05a400c74edf2b4bf0019abf74607aece77bcd6b0e7ecb9aa72fa1"></a>
# Theme Utilities

The utilities compute a full set of styles based on a [RenderingContext](https://www.npmjs.com/package/ibm-wch-sdk-api).

## Usage

Exposed functions:

* `stylesFromRenderingContext': accepts a rendering context and returns a set of derived styles.
<a name="_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328"></a>
[@ibm-wch-sdk/theme](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["colors/colors"](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)

# External module: "colors/colors"

## Index

### Interfaces

* [HSLA](#_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd)
* [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)

### Type aliases

* [ColorParser](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)

### Variables

* [colorToHSLA](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)
* [colorToRGBA](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)

### Functions

* [colorParser](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)
* [colorValue](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)
* [colorVariations](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)
* [decomposeColor](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)
* [noParser](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)
* [rgbaToHsla](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)
* [rgbaToString](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)

### Object literals

* [BLACK](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)

---

## Type aliases

<a id="colorparser"></a>

###  ColorParser

**Ƭ ColorParser**: *`UnaryFunction`<`string`, [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)>*

*Defined in colors/colors.ts:20*

___

## Variables

<a id="colortohsla"></a>

### `<Const>` colorToHSLA

**● colorToHSLA**: *`UnaryFunction`<[RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9), [HSLA](#_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd)>* =  rgbaToHsla

*Defined in colors/colors.ts:136*

___
<a id="colortorgba"></a>

### `<Const>` colorToRGBA

**● colorToRGBA**: *`UnaryFunction`<[RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9), [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)>* =  identity

*Defined in colors/colors.ts:135*

___

## Functions

<a id="colorparser-1"></a>

### `<Const>` colorParser

▸ **colorParser**(aDoc: *`Document`*): `UnaryFunction`<`string`, [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)>

*Defined in colors/colors.ts:72*

Constructs a function that parses a color value using the DOM APIs

**Parameters:**

| Name | Type | Description |
| ------ | ------ | ------ |
| aDoc | `Document` |  the document |

**Returns:** `UnaryFunction`<`string`, [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)>
the parser function

___
<a id="colorvalue"></a>

### `<Const>` colorValue

▸ **colorValue**(aKey: *`string`*, aColor: *[RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)*): [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)

*Defined in colors/colors.ts:60*

**Parameters:**

| Name | Type |
| ------ | ------ |
| aKey | `string` |
| aColor | [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9) |

**Returns:** [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)

___
<a id="colorvariations"></a>

### `<Const>` colorVariations

▸ **colorVariations**(aKey: *`string`*, aColor: *[RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)*): [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)

*Defined in colors/colors.ts:129*

**Parameters:**

| Name | Type |
| ------ | ------ |
| aKey | `string` |
| aColor | [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9) |

**Returns:** [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)

___
<a id="decomposecolor"></a>

### `<Const>` decomposeColor

▸ **decomposeColor**(aKey: *`string`*, aColor: *[RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)*): [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)

*Defined in colors/colors.ts:111*

Decompose the color string into color components

**Parameters:**

| Name | Type | Description |
| ------ | ------ | ------ |
| aKey | `string` |  the name of the color |
| aColor | [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9) |  the actual color value |

**Returns:** [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)
the styles

___
<a id="noparser"></a>

### `<Const>` noParser

▸ **noParser**(color: *`string`*): [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)

*Defined in colors/colors.ts:64*

**Parameters:**

| Name | Type |
| ------ | ------ |
| color | `string` |

**Returns:** [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)

___
<a id="rgbatohsla"></a>

###  rgbaToHsla

▸ **rgbaToHsla**(rgb: *[RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)*): [HSLA](#_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd)

*Defined in colors/colors.ts:33*

Converts an RGB color value to HSL. Conversion formula adapted from [http://en.wikipedia.org/wiki/HSL\_color\_space](http://en.wikipedia.org/wiki/HSL_color_space). Assumes r, g, and b are contained in the set \[0, 255\] and returns h, s, and l in the set \[0, 1\].

**Parameters:**

| Name | Type |
| ------ | ------ |
| rgb | [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9) |

**Returns:** [HSLA](#_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd)
Array The HSL representation

___
<a id="rgbatostring"></a>

###  rgbaToString

▸ **rgbaToString**(rgb: *[RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)*): `string`

*Defined in colors/colors.ts:55*

**Parameters:**

| Name | Type |
| ------ | ------ |
| rgb | [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9) |

**Returns:** `string`

___

## Object literals

<a id="black"></a>

### `<Const>` BLACK

**BLACK**: *`object`*

*Defined in colors/colors.ts:62*

<a id="black.a"></a>

####  a

**● a**: *`number`* = 1

*Defined in colors/colors.ts:62*

___
<a id="black.b"></a>

####  b

**● b**: *`number`* = 0

*Defined in colors/colors.ts:62*

___
<a id="black.g"></a>

####  g

**● g**: *`number`* = 0

*Defined in colors/colors.ts:62*

___
<a id="black.r"></a>

####  r

**● r**: *`number`* = 0

*Defined in colors/colors.ts:62*

___

___


<a name="_de08aaef1ac41dc80b670f1a414329c3a9194fc4d0056833b87e4bbff345a30e"></a>
[@ibm-wch-sdk/theme](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["colors/index"](#_de08aaef1ac41dc80b670f1a414329c3a9194fc4d0056833b87e4bbff345a30e)

# External module: "colors/index"

## Index

---


<a name="_d53838c3180bb9a0e5494e993ceb8942c9866e807f2cfe89645b7e36005a0cf8"></a>
[@ibm-wch-sdk/theme](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["index"](#_d53838c3180bb9a0e5494e993ceb8942c9866e807f2cfe89645b7e36005a0cf8)

# External module: "index"

## Index

---


<a name="_a0017d63397dbc31246d84d4a65fde40b7e938ce11200c55a314400ecc742d00"></a>
[@ibm-wch-sdk/theme](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["styles"](#_a0017d63397dbc31246d84d4a65fde40b7e938ce11200c55a314400ecc742d00)

# External module: "styles"

## Index

### Interfaces

* [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)

---


<a name="_e29f368d111ff8c51a7065d3d0463a6e498b75a1f3c2e9775dfea806ae401cb5"></a>
[@ibm-wch-sdk/theme](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["theme/index"](#_e29f368d111ff8c51a7065d3d0463a6e498b75a1f3c2e9775dfea806ae401cb5)

# External module: "theme/index"

## Index

---


<a name="_5a3c6b420ff7c43fc2376cdd8d181fe74fe375e37bbdb2a9f1826ff46c210d46"></a>
[@ibm-wch-sdk/theme](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["theme/theme"](#_5a3c6b420ff7c43fc2376cdd8d181fe74fe375e37bbdb2a9f1826ff46c210d46)

# External module: "theme/theme"

## Index

### Variables

* [COLOR_SUFFIX](#_5a3c6b420ff7c43fc2376cdd8d181fe74fe375e37bbdb2a9f1826ff46c210d46)
* [NULL_COLOR](#_5a3c6b420ff7c43fc2376cdd8d181fe74fe375e37bbdb2a9f1826ff46c210d46)

### Functions

* [_colorName](#_5a3c6b420ff7c43fc2376cdd8d181fe74fe375e37bbdb2a9f1826ff46c210d46)
* [stylesFromRenderingContext](#_5a3c6b420ff7c43fc2376cdd8d181fe74fe375e37bbdb2a9f1826ff46c210d46)

---

## Variables

<a id="color_suffix"></a>

### `<Const>` COLOR_SUFFIX

**● COLOR_SUFFIX**: *"Color"* = "Color"

*Defined in theme/theme.ts:7*

___
<a id="null_color"></a>

### `<Const>` NULL_COLOR

**● NULL_COLOR**: *[RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)* =  null

*Defined in theme/theme.ts:11*

___

## Functions

<a id="_colorname"></a>

### `<Const>` _colorName

▸ **_colorName**(name: *`string`*): `string`

*Defined in theme/theme.ts:9*

**Parameters:**

| Name | Type |
| ------ | ------ |
| name | `string` |

**Returns:** `string`

___
<a id="stylesfromrenderingcontext"></a>

### `<Const>` stylesFromRenderingContext

▸ **stylesFromRenderingContext**(aRenderingContext: *`RenderingContext`*, aParser: *[ColorParser](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)*): [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)

*Defined in theme/theme.ts:23*

Derives styles based on a rendering context assuming that the contet represents a theme configuration. Color names are expected to be represented as elements of type 'text'. The element label has to end with the term 'Color', the prefix will be the name of the actual CSS color variable (e.g. 'primaryColor').

**Parameters:**

| Name | Type | Description |
| ------ | ------ | ------ |
| aRenderingContext | `RenderingContext` |  the rendering context of the theme |
| aParser | [ColorParser](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328) |

**Returns:** [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)
a styles object with the computed styles

___


<a name="_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0"></a>

#  @ibm-wch-sdk/theme

## Index

### External modules

* ["colors/colors"](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328)
* ["colors/index"](#_de08aaef1ac41dc80b670f1a414329c3a9194fc4d0056833b87e4bbff345a30e)
* ["index"](#_d53838c3180bb9a0e5494e993ceb8942c9866e807f2cfe89645b7e36005a0cf8)
* ["styles"](#_a0017d63397dbc31246d84d4a65fde40b7e938ce11200c55a314400ecc742d00)
* ["theme/index"](#_e29f368d111ff8c51a7065d3d0463a6e498b75a1f3c2e9775dfea806ae401cb5)
* ["theme/theme"](#_5a3c6b420ff7c43fc2376cdd8d181fe74fe375e37bbdb2a9f1826ff46c210d46)

---


<a name="_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd"></a>
[@ibm-wch-sdk/theme](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["colors/colors"](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328) > [HSLA](#_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd)

# Interface: HSLA

## Hierarchy

**HSLA**

## Index

### Properties

* [a](#_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd)
* [h](#_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd)
* [l](#_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd)
* [s](#_119ab58c2e785b954cf95078e327fb09fa1369e29c6f1adf2ee31f9e1d1d85cd)

---

## Properties

<a id="a"></a>

###  a

**● a**: *`number`*

*Defined in colors/colors.ts:10*

___
<a id="h"></a>

###  h

**● h**: *`number`*

*Defined in colors/colors.ts:7*

___
<a id="l"></a>

###  l

**● l**: *`number`*

*Defined in colors/colors.ts:9*

___
<a id="s"></a>

###  s

**● s**: *`number`*

*Defined in colors/colors.ts:8*

___


<a name="_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9"></a>
[@ibm-wch-sdk/theme](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["colors/colors"](#_27d9ed63d38d04aa64f589999d02c54f8a9dd90bf3b610867a6b31fb8af42328) > [RGBA](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)

# Interface: RGBA

## Hierarchy

**RGBA**

## Index

### Properties

* [a](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)
* [b](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)
* [g](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)
* [r](#_94272c8b2c6ff81e6d8f95006c3d0a0401c7ee3bfe18ae44f478e7dd5f87d4d9)

---

## Properties

<a id="a"></a>

###  a

**● a**: *`number`*

*Defined in colors/colors.ts:17*

___
<a id="b"></a>

###  b

**● b**: *`number`*

*Defined in colors/colors.ts:16*

___
<a id="g"></a>

###  g

**● g**: *`number`*

*Defined in colors/colors.ts:15*

___
<a id="r"></a>

###  r

**● r**: *`number`*

*Defined in colors/colors.ts:14*

___


<a name="_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a"></a>
[@ibm-wch-sdk/theme](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["styles"](#_a0017d63397dbc31246d84d4a65fde40b7e938ce11200c55a314400ecc742d00) > [Styles](#_4201729d7b798e9e43e7f02c99334ca1b5fa4b83c970d1cedfb0a18a2882552a)

# Interface: Styles

## Hierarchy

**Styles**

## Indexable

\[key: `string`\]:&nbsp;`string` \| `number`
## Index

---