Class: DocsKit::LandingConfig::Logo

Inherits:
Data
  • Object
show all
Defined in:
lib/docs_kit/landing_config.rb

Overview

The hero brand logo — either an inline single-path SVG mark (svg = the <path d> data, viewbox = its viewBox) rendered with fill: currentColor so it adapts to the theme, OR an image (src = an asset path/URL, alt = its accessible name). label is the accessible name for the inline mark.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(svg: nil, viewbox: "0 0 24 24", src: nil, alt: nil, label: nil) ⇒ Logo

Returns a new instance of Logo.



142
143
144
# File 'lib/docs_kit/landing_config.rb', line 142

def initialize(svg: nil, viewbox: "0 0 24 24", src: nil, alt: nil, label: nil)
  super
end

Instance Attribute Details

#altObject (readonly)

Returns the value of attribute alt

Returns:

  • (Object)

    the current value of alt



141
142
143
# File 'lib/docs_kit/landing_config.rb', line 141

def alt
  @alt
end

#labelObject (readonly)

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



141
142
143
# File 'lib/docs_kit/landing_config.rb', line 141

def label
  @label
end

#srcObject (readonly)

Returns the value of attribute src

Returns:

  • (Object)

    the current value of src



141
142
143
# File 'lib/docs_kit/landing_config.rb', line 141

def src
  @src
end

#svgObject (readonly)

Returns the value of attribute svg

Returns:

  • (Object)

    the current value of svg



141
142
143
# File 'lib/docs_kit/landing_config.rb', line 141

def svg
  @svg
end

#viewboxObject (readonly)

Returns the value of attribute viewbox

Returns:

  • (Object)

    the current value of viewbox



141
142
143
# File 'lib/docs_kit/landing_config.rb', line 141

def viewbox
  @viewbox
end

Class Method Details

.from(logo) ⇒ Object



146
147
148
149
150
151
152
153
154
# File 'lib/docs_kit/landing_config.rb', line 146

def self.from()
  return  if .is_a?(self)

  attrs = .to_h.transform_keys(&:to_sym)
  new(
    svg: attrs[:svg], viewbox: attrs[:viewbox] || "0 0 24 24",
    src: attrs[:src], alt: attrs[:alt], label: attrs[:label]
  )
end

Instance Method Details

#inline?Boolean

An inline SVG mark (vs. an ). True when svg path data is present.

Returns:

  • (Boolean)


157
# File 'lib/docs_kit/landing_config.rb', line 157

def inline? = !svg.to_s.empty?