module Barnardos::RubyDesignSystem::ComponentHelper

Provides helper methods available in the host app's server.

Usage: Add the following to `/app/helpers/application_helper.rb` within the module `ApplicationHelper`:

include Barnardos::RubyDesignSystem::ComponentHelper

Public Instance Methods

fieldset(legend: nil, hint: nil) { || ... } click to toggle source

Creates a FieldSet Component around passed in block. Also adds Fieldset-children inner wrapper around block

@param legend [String] outputs into a Fieldset-legend component within the Fieldset if set @param hint [String] outputs into a Hint component within the Fieldset if set @return [String] HTML containing the passed in block wrapped by a Fieldset Component and sub components

# File lib/barnardos/ruby_design_system/component_helper.rb, line 55
def fieldset(legend: nil, hint: nil)
  content_tag :fieldset, class: 'Fieldset' do
    concat(content_tag(:legend, legend, class: 'Fieldset-legend')) if legend
    concat(
      content_tag(:div, class: 'Fieldset-children') do
        concat(content_tag(:p, hint, class: 'Hint')) if hint
        concat(yield)
      end
    )
  end
end