6.0.524 • Published 5 years ago

@ibm-wch-sdk/theme v6.0.524

Weekly downloads
1
License
MIT
Repository
-
Last release
5 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

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:

NameTypeDescription
aDocDocumentthe document

Returns: UnaryFunction<string, RGBA> the parser function


<Const> colorValue

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

Defined in colors/colors.ts:60

Parameters:

NameType
aKeystring
aColorRGBA

Returns: Styles


<Const> colorVariations

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

Defined in colors/colors.ts:129

Parameters:

NameType
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:

NameTypeDescription
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:

NameType
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:

NameType
rgbRGBA

Returns: HSLA Array The HSL representation


rgbaToString

rgbaToString(rgb: RGBA): string

Defined in colors/colors.ts:55

Parameters:

NameType
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:

NameType
namestring

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:

NameTypeDescription
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


6.0.524

5 years ago

7.2.608

5 years ago

7.2.591

5 years ago

7.2.435

5 years ago

7.2.407

5 years ago

7.2.358

5 years ago

7.2.291

5 years ago

7.2.290

5 years ago

6.0.498

5 years ago

6.0.496

5 years ago

6.0.477

5 years ago

7.0.165

5 years ago

7.0.163

5 years ago

7.0.151

5 years ago

6.0.455

6 years ago

7.0.25

6 years ago

7.0.22

6 years ago

7.0.16

6 years ago

6.0.401

6 years ago

6.0.383

6 years ago

6.0.341

6 years ago

6.0.264

6 years ago

6.0.293

6 years ago

6.0.287

6 years ago

6.0.238

6 years ago

6.0.232

6 years ago

6.0.230

6 years ago

6.0.229

6 years ago

6.0.224

6 years ago

6.0.223

6 years ago

6.0.185

6 years ago

6.0.178

6 years ago

6.0.162

6 years ago

6.0.159

6 years ago

6.0.157

6 years ago

6.0.155

6 years ago

6.0.154

6 years ago

6.0.152

6 years ago

6.0.149

6 years ago

6.0.132

6 years ago

6.0.126

6 years ago

6.0.120

6 years ago

6.0.119

6 years ago

6.0.118

6 years ago

6.0.112

6 years ago

6.0.108

6 years ago

6.0.107

6 years ago

6.0.75

6 years ago

6.0.66

6 years ago

6.0.54

6 years ago

6.0.42

6 years ago

6.0.39

6 years ago

6.0.17

6 years ago