5.0.361 • Published 6 years ago

ibm-wch-sdk-theme v5.0.361

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

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

Added

  • 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): function

Defined in colors/colors.ts:72

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

Parameters:

ParamTypeDescription
aDocDocumentthe document

Returns: function the parser function


<Const> colorValue

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

Defined in colors/colors.ts:60

Parameters:

ParamType
aKeystring
aColorRGBA

Returns: Styles


<Const> colorVariations

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

Defined in colors/colors.ts:129

Parameters:

ParamType
aKeystring
aColorRGBA

Returns: Styles


<Const> decomposeColor

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

Defined in colors/colors.ts:111

Decompose the color string into color components

Parameters:

ParamTypeDescription
aKeystringthe name of the color
aColorRGBAthe actual color value

Returns: Styles the styles


<Const> noParser

noParser(color: string): RGBA

Defined in colors/colors.ts:64

Parameters:

ParamType
colorstring

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:

ParamType
rgbRGBA

Returns: HSLA Array The HSL representation


rgbaToString

rgbaToString(rgb: RGBA): string

Defined in colors/colors.ts:55

Parameters:

ParamType
rgbRGBA

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:

ParamType
namestring

Returns: string


<Const> stylesFromRenderingContext

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

Defined in theme/theme.ts:22

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:

ParamTypeDescription
aRenderingContextRenderingContextthe rendering context of the theme
aParserColorParser

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


5.0.361

6 years ago

5.0.341

6 years ago

5.0.340

6 years ago

5.0.334

6 years ago

5.0.321

6 years ago

5.0.325

6 years ago

5.0.316

6 years ago

5.0.314

6 years ago

5.0.300

6 years ago

5.0.269

6 years ago

5.0.265

6 years ago

5.0.258

6 years ago

5.0.254

6 years ago

5.0.240

6 years ago

5.0.238

6 years ago

5.0.233

6 years ago

5.0.226

6 years ago

5.0.217

6 years ago

5.0.216

6 years ago

5.0.215

6 years ago

5.0.212

6 years ago

5.0.211

6 years ago

5.0.210

6 years ago

5.0.207

6 years ago