Class: DocsUI::Logo

Inherits:
Phlex::HTML
  • Object
show all
Includes:
Phlex::Rails::Helpers::ImageURL
Defined in:
app/components/docs_ui/logo.rb

Overview

Renders a DocsKit::BrandLogo (config.brand_logo / config.landing.logo) as the brand mark — an inline currentColor (theme-adaptive), a verbatim site-authored embed, or an .

render DocsUI::Logo.new(config., class: "h-6 w-auto", label: config.brand)

label: is the accessible-name fallback when the logo itself carries none (callers pass config.brand, so the mark always announces the site).

The svg:/paths: forms emit each path-d as an ordinary Phlex-escaped attribute — config free text never bypasses the escape. The markup:/file: forms DO embed markup verbatim via raw(safe(...)): that content is the site's own deliberately-configured SVG (its initializer / its asset file — the same trust domain as the site's own views, which can already render anything), not third-party free text, and DocsKit::BrandLogo shape-checks it to be an element at config time. That authored-by-the-trusting-site rationale is the same carve-out DocsUI::BrandMark uses for its gem-authored path constants.

Instance Method Summary collapse

Constructor Details

#initialize(logo, label: nil, **attributes) ⇒ Logo

Returns a new instance of Logo.



27
28
29
30
31
# File 'app/components/docs_ui/logo.rb', line 27

def initialize(, label: nil, **attributes)
  @logo = DocsKit::BrandLogo.from()
  @label = label
  @attributes = attributes
end

Instance Method Details

#view_templateObject



33
34
35
36
37
38
39
40
41
# File 'app/components/docs_ui/logo.rb', line 33

def view_template
  if @logo.image?
    img(src: resolved_src, alt: accessible_name.to_s, **@attributes)
  elsif @logo.embed?
    embedded_svg
  else
    inline_svg
  end
end