@ibm-wch-sdk/theme

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

Stats

stars šŸŒŸissues āš ļøupdated šŸ› created šŸ£size šŸ‹ļøā€ā™€ļø
@ibm-wch-sdk/theme
Minified + gzip package size for @ibm-wch-sdk/theme in KB

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


If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.