Options
All
  • Public
  • Public/Protected
  • All
Menu

A handler object for dark color, used for variable-based dark color solution

Hierarchy

  • DarkColorHandler

Index

Methods

findLightColorFromDarkColor

  • findLightColorFromDarkColor(darkColor: string): string

getKnownColorsCopy

parseColorValue

  • Parse an existing color value, if it is in variable-based color format, extract color key, light color and query related dark color if any

    Parameters

    • color: string

      The color string to parse

    • Optional isInDarkMode: boolean

      Whether current content is in dark mode. When set to true, if the color value is not in dark var format, we will treat is as a dark mode color and try to find a matched dark mode color.

    Returns ColorKeyAndValue

registerColor

  • registerColor(lightModeColor: string, isDarkMode: boolean, darkModeColor?: string): string
  • Given a light mode color value and an optional dark mode color value, register this color so that editor can handle it, then return the CSS color value for current color mode.

    Parameters

    • lightModeColor: string

      Light mode color value

    • isDarkMode: boolean

      Whether current color mode is dark mode

    • Optional darkModeColor: string

      Optional dark mode color value. If not passed, we will calculate one.

    Returns string

reset

  • reset(): void

transformElementColor

  • transformElementColor(element: HTMLElement, fromDarkMode: boolean, toDarkMode: boolean): void
  • Transform element color, from dark to light or from light to dark

    Parameters

    • element: HTMLElement

      The element to transform color

    • fromDarkMode: boolean

      Whether this is transforming color from dark mode

    • toDarkMode: boolean

      Whether this is transforming color to dark mode

    Returns void

Generated using TypeDoc