File

src/styles/translator.ts

Description

Interface for logic that implements a mapping from a presentation style in Blueriq to a set of class names. When registered using BlueriqStyles.register each translator will be used from BqClassesDirective to translate all presentation styles of a given element to its corresponding class names.

Index

Methods

Methods

Abstract translate
translate(style: string, element: Element)

Called for each presentation style to translate. Should return a list of class names or undefined if no translation is available for the given presentation style. If no style translation exists for a given presentation style, i.e. all translators return undefined, then the presentation style in itself will be used as class name. When an empty list is returned from any translator, the original presentation style will not be used as class name.

Note that presentation styles are considered independent of each other. Hence, you should not inspect other styles that are present on the element. In fact, you should only use data that is guaranteed not to change, e.g. the element's type or content style. The reason is that the BqClassesDirective that keeps the presentation styles in sync with the class names on the corresponding DOM element will only perform the translation for newly added presentation styles.

Parameters :
Name Type Optional
style string No
element Element No
Returns : Styles

result-matching ""

    No results matching ""