Class: CCS::Components::GovUK::Logo
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/ccs/components/govuk/logo.rb
Overview
GOV.UK Logo
This is used to generate the logo component from the GDS - Macros - Logo
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the logo
{}.freeze
Instance Method Summary collapse
-
#initialize(use_logotype: true) ⇒ Logo
constructor
A new instance of Logo.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Logo component.
Constructor Details
#initialize(use_logotype: true) ⇒ Logo
Returns a new instance of Logo.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ccs/components/govuk/logo.rb', line 30 def initialize(use_logotype: true, **) super(**) @use_logotype = use_logotype svg_width = 32 svg_width += 130 if @use_logotype @options[:attributes][:focusable] = 'false' @options[:attributes][:role] = @options[:attributes].dig(:aria, :label) ? 'img' : 'presentation' @options[:attributes][:xmlns] = 'http://www.w3.org/2000/svg' @options[:attributes][:viewBox] = "0 0 #{svg_width * 2} 60" @options[:attributes][:height] = '30' @options[:attributes][:width] = svg_width.to_s @options[:attributes][:fill] = 'currentcolor' end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Logo component
51 52 53 54 55 56 57 |
# File 'lib/ccs/components/govuk/logo.rb', line 51 def render tag.svg(**[:attributes]) do concat(tag.title(@options[:attributes].dig(:aria, :label))) if @options[:attributes].dig(:aria, :label) concat(tudor_crown) concat(logotype) if use_logotype end end |