DFE-Digital/govuk-formbuilder

View on GitHub
lib/govuk_design_system_formbuilder/containers/check_boxes.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
module GOVUKDesignSystemFormBuilder
  module Containers
    class CheckBoxes < Base
      include Traits::HTMLClasses
      include Traits::HTMLAttributes

      def initialize(builder, small:, **kwargs)
        super(builder, nil, nil)

        @small = small
        @html_attributes = kwargs
      end

      def html(&block)
        tag.div(**attributes(@html_attributes), &block)
      end

    private

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

      def classes
        build_classes(
          %(#{brand}-checkboxes),
          %(#{brand}-checkboxes--small) => @small,
        )
      end
    end
  end
end