Class: Ariadne::RichTextAreaComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/ariadne/rich_text_area_component.rb

Overview

Add a general description of component here Add additional usage considerations or best practices that may aid the user to use the component correctly.

Constant Summary collapse

DEFAULT_TAG =
:div
DEFAULT_CLASSES =
"ariadne-block ariadne-w-full ariadne-border-0 ariadne-py-3 focus:ariadne-ring-0 sm:ariadne-text-sm"

Constants inherited from Component

Component::BASE_BODY_CLASSES, Component::BASE_HTML_CLASSES, Component::BASE_MAIN_CLASSES, Component::BASE_WRAPPER_CLASSES, Component::INVALID_ARIA_LABEL_TAGS

Constants included from ActionViewExtensions::FormHelper

ActionViewExtensions::FormHelper::DEFAULT_FORM_CLASSES

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE

Instance Method Summary collapse

Methods included from ActionViewExtensions::FormHelper

#ariadne_form_with

Methods included from ClassNameHelper

#class_names

Methods included from LoggerHelper

#logger, #silence_deprecations?, #silence_warnings?

Methods included from FetchOrFallbackHelper

#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer

Constructor Details

#initialize(name:, sr_label:, has_form: true, classes: "", attributes: {}) ⇒ RichTextAreaComponent

Returns a new instance of RichTextAreaComponent.

Examples:

Default


<%= render(Ariadne::RichTextAreaComponent.new(name: "bodytext", sr_label: "Enter message contents")) { "Example" } %>

Parameters:

  • name (Symbol)

    Identifies the form/param name for this rich text area.

  • sr_label (String)

    A label to introduce these tabs for screen readers.

  • has_form (Boolean) (defaults to: true)

    Indicates whether this component is wrapped in a form.

  • classes (String) (defaults to: "")

    <%= link_to_classes_docs %>

  • attributes (Hash) (defaults to: {})

    <%= link_to_attributes_docs %>



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/components/ariadne/rich_text_area_component.rb', line 20

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