Class: Lutaml::Xsd::Spa::Svg::Renderers::AttributeRenderer
- Inherits:
-
ComponentRenderer
- Object
- ComponentRenderer
- Lutaml::Xsd::Spa::Svg::Renderers::AttributeRenderer
- Defined in:
- lib/lutaml/xsd/spa/svg/renderers/attribute_renderer.rb
Overview
Renders XSD attribute components
Instance Attribute Summary
Attributes inherited from ComponentRenderer
Instance Method Summary collapse
Methods inherited from ComponentRenderer
Constructor Details
This class inherits a constructor from Lutaml::Xsd::Spa::Svg::ComponentRenderer
Instance Method Details
#render(component_data, box) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/lutaml/xsd/spa/svg/renderers/attribute_renderer.rb', line 12 def render(component_data, box) name = component_data["name"] type = component_data["type"] parts = [] # Box fill = if config.effects.gradient_enabled? "url(#attributeGradient)" else config.colors.attribute.base end parts << create_box( box, fill, stroke: config.colors.ui.border, stroke_width: 1, ) # Attribute name with @ prefix parts << Utils::SvgBuilder.text( box.x + 5, box.y + 15, "@#{name}", { fill: "white", "font-size" => 12, }, ) # Type on second line if present if type parts << Utils::SvgBuilder.text( box.x + 5, box.y + 27, type, { fill: "white", "font-size" => 10, opacity: 0.8, }, ) end # Required indicator parts << render_required_indicator(box) if component_data["use"] == "required" Utils::SvgBuilder.group({ class: "attribute-box" }) { parts.join("\n") } end |