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.
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
-
.resolve(color) ⇒ String?
Resolves a color value to its CSS variable representation.
-
.valid?(color) ⇒ Boolean
Checks if a color name is valid.
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)
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.
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 |