Module: FizzyApiClient::Colors

Defined in:
lib/fizzy_api_client/colors.rb

Overview

Color mappings for column colors.

Provides friendly named colors that map to the underlying CSS variable values expected by the Fizzy API.

Examples:

Using named colors

client.create_column(board_id: 'board_1', name: 'Review', color: :blue)
client.update_column('board_id', 'col_id', color: :lime)

Using CSS variable directly (still supported)

client.create_column(board_id: 'board_1', name: 'Review', color: 'var(--color-card-4)')

Constant Summary collapse

MAPPING =

Color name to CSS variable mapping

{
  blue: "var(--color-card-default)",
  gray: "var(--color-card-1)",
  tan: "var(--color-card-2)",
  yellow: "var(--color-card-3)",
  lime: "var(--color-card-4)",
  aqua: "var(--color-card-5)",
  violet: "var(--color-card-6)",
  purple: "var(--color-card-7)",
  pink: "var(--color-card-8)"
}.freeze
NAMES =

All available color names

MAPPING.keys.freeze
BLUE =

Individual color constants for convenience

MAPPING[:blue]
GRAY =
MAPPING[:gray]
TAN =
MAPPING[:tan]
YELLOW =
MAPPING[:yellow]
LIME =
MAPPING[:lime]
AQUA =
MAPPING[:aqua]
VIOLET =
MAPPING[:violet]
PURPLE =
MAPPING[:purple]
PINK =
MAPPING[:pink]

Class Method Summary collapse

Class Method Details

.resolve(color) ⇒ String?

Resolves a color value to its CSS variable representation.

Accepts:

  • Symbol color names (:blue, :lime, etc.)
  • String color names ("blue", "lime", etc.)
  • CSS variable strings (passed through unchanged)
  • nil (returns nil)

Examples:

Colors.resolve(:blue)        #=> "var(--color-card-default)"
Colors.resolve("lime")       #=> "var(--color-card-4)"
Colors.resolve("var(--color-card-3)")  #=> "var(--color-card-3)"
Colors.resolve(nil)          #=> nil

Parameters:

  • color (Symbol, String, nil)

    the color to resolve

Returns:

  • (String, nil)

    the CSS variable value or nil

Raises:

  • (ArgumentError)

    if the color name is not recognized



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fizzy_api_client/colors.rb', line 63

def resolve(color)
  return nil if color.nil?

  # If it's already a CSS variable, pass through unchanged
  return color.to_s if color.to_s.start_with?("var(")

  # Convert to symbol for lookup
  color_sym = color.to_s.downcase.to_sym

  unless MAPPING.key?(color_sym)
    raise ArgumentError, "Unknown color: #{color.inspect}. Valid colors: #{NAMES.join(', ')}"
  end

  MAPPING[color_sym]
end

.valid?(color) ⇒ Boolean

Checks if a color name is valid.

Parameters:

  • color (Symbol, String)

    the color name to check

Returns:

  • (Boolean)

    true if valid



84
85
86
87
88
# File 'lib/fizzy_api_client/colors.rb', line 84

def valid?(color)
  return true if color.to_s.start_with?("var(")

  MAPPING.key?(color.to_s.downcase.to_sym)
end