The ColorPalette atom.

Hierarchy (view full)

Implements

  • IColorPalette

Properties

defaultColorName: PropertyStringSelectable

The default color name property

key: string

The unique key for the node. It is unique from all other nodes in the ThemeBuilder

name: string

The name of the node, which is unique relative to it's siblings

required: boolean

Is this a required atom?

Methods

  • Add a color to the color palette.

    Parameters

    • name: string

      The name of the color to add to the palette

    • hex: string

      The hex value of the color to add to the palette

    Returns Color

    The color added to the palette

  • Get a color by name, or throw an exception if not found.

    Parameters

    • colorName: string

      The name of the color to return.

    Returns Color

    The color object

  • Return a 1-based index for this color in the palette.

    Parameters

    Returns number

    A 1-based index for this color

  • Get a list of all color names in the palette.

    Returns string[]

    Return a list of string names for the colors.

  • Return all light or dark mode colors which match the filter. If no filter is provided, return all.

    Parameters

    • type: string

      Either 'lm' for light mode or 'dm' for dark mode.

    • Optionalfilter: ShadeFilter

      An optional filter

    Returns Shade[][]

    Returns all light mode or dark mode colors which match the filter (if any).

  • Get all dark mode shades matching the filter

    Parameters

    • Optionalfilter: ShadeFilter

      An optional filter which must be matched

    Returns Shade[][]

    The matching dark mode shades

  • Get the default color name (if any).

    Returns undefined | string

    The default color name.

  • Get all light mode shades matching the filter

    Parameters

    • Optionalfilter: ShadeFilter

      An optional filter which must be matched

    Returns Shade[][]

    The matching light mode shades

  • Determine if this node is enabled. A node is enabled if all other nodes on which this node depends have been initialized.

    Returns boolean

    True if enabled, or false otherwise.

  • Determine if this node is initialized.

    If this node is a property, it is initialized if it is not required to have a value, or if it is required and has either a default or non-default value.

    Returns boolean

    True if initialized, or false otherwise.

  • Remove a color from the color palette.

    Parameters

    • name: string

      The name of the color to remove from the palette

    Returns void

  • Remove a listener by name.

    Parameters

    • name: string

      The name of the listener to remove

    Returns void

  • Set a color listener which is called when a color is added or removed from the palette.

    Parameters

    • name: string

      The name of the color listener.

    • cb: ColorListener

      The callback function to call when a color is added or removed.

    Returns void

  • Set a listener on this node

    Parameters

    • name: string

      The name of the listener.

    • callback: EventCallback

      The callback to call when an event occurs.

    • OptionaleventTypes: EventType[]

      The types of events to wait for. If none are specified, listen for all events.

    Returns ListenerSubscription

    The ListenerSubscription which should be canceled to stop listening.