Class: JsxRosetta::IR::CvaBinding

Inherits:
Data
  • Object
show all
Includes:
Node
Defined in:
lib/jsx_rosetta/ir/types.rb

Overview

A module-level call to ‘cva()` from class-variance-authority. shadcn components ubiquitously use this builder to attach a base class string plus per-axis variant maps to a JSX component. The translator recognizes the pattern at lowering time so backends can emit real Ruby constants (`FOO_BASE_CLASS`, `FOO_VARIANT_CLASSES`) instead of leaving the call as a TODO comment, and so the use-site `cn(fooVariants({ variant }), className)` translates to a proper Ruby string interpolation.

name : String — the const binding name (e.g. “buttonVariants”). base_class : String — the first string argument to cva(). variants : Hash[String => Hash[String => String]]

— { "variant" => { "default" => "...", "outline" => "..." } }

default_variants : Hash[String => String] — per-axis default value name

(matched against the variant axis keys).

compound_source : String | nil — INTENTIONALLY UNPARSED verbatim JS

source of any `compoundVariants` entry. Field name
reads structural; it isn't — backends only print
it as a TODO comment alongside the constants since
compoundVariants semantics aren't supported in the
first cut.

Instance Attribute Summary collapse

Instance Attribute Details

#base_classObject (readonly)

Returns the value of attribute base_class

Returns:

  • (Object)

    the current value of base_class



175
176
177
# File 'lib/jsx_rosetta/ir/types.rb', line 175

def base_class
  @base_class
end

#compound_sourceObject (readonly)

Returns the value of attribute compound_source

Returns:

  • (Object)

    the current value of compound_source



175
176
177
# File 'lib/jsx_rosetta/ir/types.rb', line 175

def compound_source
  @compound_source
end

#default_variantsObject (readonly)

Returns the value of attribute default_variants

Returns:

  • (Object)

    the current value of default_variants



175
176
177
# File 'lib/jsx_rosetta/ir/types.rb', line 175

def default_variants
  @default_variants
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



175
176
177
# File 'lib/jsx_rosetta/ir/types.rb', line 175

def name
  @name
end

#variantsObject (readonly)

Returns the value of attribute variants

Returns:

  • (Object)

    the current value of variants



175
176
177
# File 'lib/jsx_rosetta/ir/types.rb', line 175

def variants
  @variants
end