@ibm-wch-sdk/theme

Module that implements @ngrx bindings to the login and logout functionality as offered by the @ibm-wch-sdk/ng modules.

Usage no npm install needed!

<script type="module">
  import ibmWchSdkTheme from 'https://cdn.skypack.dev/@ibm-wch-sdk/theme';
</script>

README

ibm-wch-sdk-theme

Module that implements utility functions to deal with theme like UI configuration in WCH for single page applications.

Details

Refer to the documentation.

Changes

CHANGELOG

Class documentation

Refer to the documentation.

Usage

Install the module via

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

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 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 sub module computes CSS styles and CSS variables based on a RenderingContext.

Changelog

Current

6.0.69

Added

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

@ibm-wch-sdk/theme

Index

External modules


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 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%.

Theme Utilities

The utilities compute a full set of styles based on a RenderingContext.

Usage

Exposed functions:

External module: "colors/colors"

Index

Interfaces

Type aliases

Variables

Functions

Object literals


Type aliases

ColorParser

Ƭ ColorParser: UnaryFunction<string, RGBA>

Defined in colors/colors.ts:20


Variables

<Const> colorToHSLA

● colorToHSLA: UnaryFunction<RGBA, HSLA> = rgbaToHsla

Defined in colors/colors.ts:136


<Const> colorToRGBA

● colorToRGBA: UnaryFunction<RGBA, RGBA> = identity

Defined in colors/colors.ts:135


Functions

<Const> colorParser

colorParser(aDoc: Document): UnaryFunction<string, RGBA>

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> the parser function


<Const> colorValue

colorValue(aKey: string, aColor: RGBA): Styles

Defined in colors/colors.ts:60

Parameters:

Name Type
aKey string
aColor RGBA

Returns: Styles


<Const> colorVariations

colorVariations(aKey: string, aColor: RGBA): Styles

Defined in colors/colors.ts:129

Parameters:

Name Type
aKey string
aColor RGBA

Returns: Styles


<Const> decomposeColor

decomposeColor(aKey: string, aColor: RGBA): Styles

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 the actual color value

Returns: Styles the styles


<Const> noParser

noParser(color: string): RGBA

Defined in colors/colors.ts:64

Parameters:

Name Type
color string

Returns: RGBA


rgbaToHsla

rgbaToHsla(rgb: RGBA): HSLA

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. 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

Returns: HSLA Array The HSL representation


rgbaToString

rgbaToString(rgb: RGBA): string

Defined in colors/colors.ts:55

Parameters:

Name Type
rgb RGBA

Returns: string


Object literals

<Const> BLACK

BLACK: object

Defined in colors/colors.ts:62

a

● a: number = 1

Defined in colors/colors.ts:62


b

● b: number = 0

Defined in colors/colors.ts:62


g

● g: number = 0

Defined in colors/colors.ts:62


r

● r: number = 0

Defined in colors/colors.ts:62



@ibm-wch-sdk/theme > "colors/index"

External module: "colors/index"

Index


@ibm-wch-sdk/theme > "index"

External module: "index"

Index


@ibm-wch-sdk/theme > "styles"

External module: "styles"

Index

Interfaces


@ibm-wch-sdk/theme > "theme/index"

External module: "theme/index"

Index


@ibm-wch-sdk/theme > "theme/theme"

External module: "theme/theme"

Index

Variables

Functions


Variables

<Const> COLOR_SUFFIX

● COLOR_SUFFIX: "Color" = "Color"

Defined in theme/theme.ts:7


<Const> NULL_COLOR

● NULL_COLOR: RGBA = null

Defined in theme/theme.ts:11


Functions

<Const> _colorName

_colorName(name: string): string

Defined in theme/theme.ts:9

Parameters:

Name Type
name string

Returns: string


<Const> stylesFromRenderingContext

stylesFromRenderingContext(aRenderingContext: RenderingContext, aParser: ColorParser): Styles

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

Returns: Styles a styles object with the computed styles


@ibm-wch-sdk/theme

Index

External modules


@ibm-wch-sdk/theme > "colors/colors" > HSLA

Interface: HSLA

Hierarchy

HSLA

Index

Properties


Properties

a

● a: number

Defined in colors/colors.ts:10


h

● h: number

Defined in colors/colors.ts:7


l

● l: number

Defined in colors/colors.ts:9


s

● s: number

Defined in colors/colors.ts:8


@ibm-wch-sdk/theme > "colors/colors" > RGBA

Interface: RGBA

Hierarchy

RGBA

Index

Properties


Properties

a

● a: number

Defined in colors/colors.ts:17


b

● b: number

Defined in colors/colors.ts:16


g

● g: number

Defined in colors/colors.ts:15


r

● r: number

Defined in colors/colors.ts:14


@ibm-wch-sdk/theme > "styles" > Styles

Interface: Styles

Hierarchy

Styles

Indexable

[key: string]: string | number

Index