# frozen_string_literal: true module Ariadne # Add a general description of component here # Add additional usage considerations or best practices that may aid the user to use the component correctly. # @accessibility Add any accessibility considerations class RichTextAreaComponent < Ariadne::Component DEFAULT_TAG = :div DEFAULT_CLASSES = "ariadne-block ariadne-w-full ariadne-border-0 ariadne-py-3 focus:ariadne-ring-0 sm:ariadne-text-sm" # @example Default # # <%= render(Ariadne::RichTextAreaComponent.new(name: "bodytext", sr_label: "Enter message contents")) { "Example" } %> # # @param name [Symbol] Identifies the form/param name for this rich text area. # @param sr_label [String] A label to introduce these tabs for screen readers. # @param has_form [Boolean] Indicates whether this component is wrapped in a form. # @param classes [String] <%= link_to_classes_docs %> # @param attributes [Hash] <%= link_to_attributes_docs %> def initialize(name:, sr_label:, has_form: true, classes: "", attributes: {}) @tag = DEFAULT_TAG @name = name @sr_label = sr_label @has_form = has_form @classes = class_names( DEFAULT_CLASSES, classes, ) @attributes = attributes @attributes[:"data-controller"] = "rich-text-area-component" @attributes[:"data-has-form"] = true if @has_form end end end