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(rebrand: false, use_logotype: true, use_tudor_crown: true) ⇒ Logo
constructor
A new instance of Logo.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Logo component.
Constructor Details
#initialize(rebrand: false, use_logotype: true, use_tudor_crown: true) ⇒ Logo
Returns a new instance of Logo.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ccs/components/govuk/logo.rb', line 36 def initialize(rebrand: false, use_logotype: true, use_tudor_crown: true, **) super(**) @rebrand = rebrand @use_logotype = use_logotype @use_tudor_crown = rebrand ? true : use_tudor_crown svg_width = @use_tudor_crown ? 32 : 36 svg_width = rebrand ? svg_width + 130 : svg_width + 116 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
59 60 61 62 63 64 65 |
# File 'lib/ccs/components/govuk/logo.rb', line 59 def render tag.svg(**[:attributes]) do concat(tag.title(@options[:attributes].dig(:aria, :label))) if @options[:attributes].dig(:aria, :label) concat(use_tudor_crown ? tudor_crown : st_edwards_crown) concat(rebrand ? dot_logotype : logotype) if use_logotype end end |