Sha256: 1d66e6f355e9e8601ee872d0bba65ecbf6bdfe769b9027738be21079eeee5c59

Contents?: true

Size: 847 Bytes

Versions: 2

Compression:

Stored size: 847 Bytes

Contents

module GOVUKDesignSystemFormBuilder
  module Containers
    class Radios < Base
      include Traits::Hint

      def initialize(builder, inline:, small:, classes:)
        @builder = builder
        @inline  = inline
        @small   = small
        @classes = classes
      end

      def html
        content_tag('div', **options) { yield }
      end

    private

      def options
        {
          class: classes,
          data: { module: %(#{brand}-radios) }
        }
      end

      def classes
        [%(#{brand}-radios), inline_class, small_class, custom_classes].flatten.compact
      end

      def inline_class
        %(#{brand}-radios--inline) if @inline
      end

      def small_class
        %(#{brand}-radios--small)  if @small
      end

      def custom_classes
        Array.wrap(@classes)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-1.2.6 lib/govuk_design_system_formbuilder/containers/radios.rb
govuk_design_system_formbuilder-1.2.5 lib/govuk_design_system_formbuilder/containers/radios.rb