Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StyledElementFactory<T>

Util class making applying 'css in js' styles easy. Provides many features:

  • Attaching inline styles
  • Attaching styles by creating a new style ya in header with defined class
  • Conditionally attach styles
  • Factory does not mutate the input element

Type parameters

  • T: HTMLElement

    Element type

Hierarchy

  • StyledElementFactory

Index

Constructors

constructor

Properties

Private Readonly elementClone

elementClone: T

Static Private Readonly STYLES_ATTRIBUTE

STYLES_ATTRIBUTE: "data-hello-customer-styles" = "data-hello-customer-styles"

Accessors

styledElement

  • get styledElement(): T

Methods

applyClass

applyClassConditionally

  • applyClassConditionally(condition: boolean, name: string, style?: Partial<CSSStyleDeclaration>): StyledElementFactory<T>

applyInlineConditionally

  • applyInlineConditionally(condition: boolean, style?: Partial<CSSStyleDeclaration>): StyledElementFactory<T>

applyInlineStyle

attachCssClass

attachInlineRule

  • attachInlineRule(ruleName: keyof CSSStyleDeclaration, ruleValue: CSSStyleDeclaration[keyof CSSStyleDeclaration]): StyledElementFactory<T>

Static addMediaRule

  • addMediaRule(media: string, rules: Record<string, Partial<CSSStyleDeclaration>>): void

Static appendCssClassToHeader

  • appendCssClassToHeader(style: Partial<CSSStyleDeclaration>, name: string): void

Static Private getStyleElement

  • getStyleElement(): HTMLStyleElement

Static Private parseStyleToClass

  • parseStyleToClass(name: string, style: Partial<CSSStyleDeclaration>): string

Generated using TypeDoc